xref: /aosp_15_r20/hardware/ril/libril/ril_service.cpp (revision 062a843b36e31144e02d312b6b2de34642e6750e)
1*062a843bSAndroid Build Coastguard Worker /*
2*062a843bSAndroid Build Coastguard Worker  * Copyright (c) 2016 The Android Open Source Project
3*062a843bSAndroid Build Coastguard Worker  *
4*062a843bSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*062a843bSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*062a843bSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*062a843bSAndroid Build Coastguard Worker  *
8*062a843bSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*062a843bSAndroid Build Coastguard Worker  *
10*062a843bSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*062a843bSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*062a843bSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*062a843bSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*062a843bSAndroid Build Coastguard Worker  * limitations under the License.
15*062a843bSAndroid Build Coastguard Worker  */
16*062a843bSAndroid Build Coastguard Worker 
17*062a843bSAndroid Build Coastguard Worker #define LOG_TAG "RILC"
18*062a843bSAndroid Build Coastguard Worker 
19*062a843bSAndroid Build Coastguard Worker #include <android/hardware/radio/1.1/IRadio.h>
20*062a843bSAndroid Build Coastguard Worker #include <android/hardware/radio/1.1/IRadioResponse.h>
21*062a843bSAndroid Build Coastguard Worker #include <android/hardware/radio/1.1/IRadioIndication.h>
22*062a843bSAndroid Build Coastguard Worker #include <android/hardware/radio/1.1/types.h>
23*062a843bSAndroid Build Coastguard Worker 
24*062a843bSAndroid Build Coastguard Worker #include <hwbinder/IPCThreadState.h>
25*062a843bSAndroid Build Coastguard Worker #include <hwbinder/ProcessState.h>
26*062a843bSAndroid Build Coastguard Worker #include <telephony/ril.h>
27*062a843bSAndroid Build Coastguard Worker #include <telephony/ril_mnc.h>
28*062a843bSAndroid Build Coastguard Worker #include <telephony/ril_mcc.h>
29*062a843bSAndroid Build Coastguard Worker #include <ril_service.h>
30*062a843bSAndroid Build Coastguard Worker #include <hidl/HidlTransportSupport.h>
31*062a843bSAndroid Build Coastguard Worker #include <utils/SystemClock.h>
32*062a843bSAndroid Build Coastguard Worker #include <inttypes.h>
33*062a843bSAndroid Build Coastguard Worker 
34*062a843bSAndroid Build Coastguard Worker #define INVALID_HEX_CHAR 16
35*062a843bSAndroid Build Coastguard Worker 
36*062a843bSAndroid Build Coastguard Worker using namespace android::hardware::radio;
37*062a843bSAndroid Build Coastguard Worker using namespace android::hardware::radio::V1_0;
38*062a843bSAndroid Build Coastguard Worker using ::android::hardware::configureRpcThreadpool;
39*062a843bSAndroid Build Coastguard Worker using ::android::hardware::joinRpcThreadpool;
40*062a843bSAndroid Build Coastguard Worker using ::android::hardware::Return;
41*062a843bSAndroid Build Coastguard Worker using ::android::hardware::hidl_string;
42*062a843bSAndroid Build Coastguard Worker using ::android::hardware::hidl_vec;
43*062a843bSAndroid Build Coastguard Worker using ::android::hardware::hidl_array;
44*062a843bSAndroid Build Coastguard Worker using ::android::hardware::Void;
45*062a843bSAndroid Build Coastguard Worker using android::CommandInfo;
46*062a843bSAndroid Build Coastguard Worker using android::RequestInfo;
47*062a843bSAndroid Build Coastguard Worker using android::requestToString;
48*062a843bSAndroid Build Coastguard Worker using android::sp;
49*062a843bSAndroid Build Coastguard Worker 
50*062a843bSAndroid Build Coastguard Worker #define BOOL_TO_INT(x) (x ? 1 : 0)
51*062a843bSAndroid Build Coastguard Worker #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
52*062a843bSAndroid Build Coastguard Worker #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
53*062a843bSAndroid Build Coastguard Worker 
54*062a843bSAndroid Build Coastguard Worker #if defined(ANDROID_MULTI_SIM)
55*062a843bSAndroid Build Coastguard Worker #define CALL_ONREQUEST(a, b, c, d, e) \
56*062a843bSAndroid Build Coastguard Worker         s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
57*062a843bSAndroid Build Coastguard Worker #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
58*062a843bSAndroid Build Coastguard Worker #else
59*062a843bSAndroid Build Coastguard Worker #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
60*062a843bSAndroid Build Coastguard Worker #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
61*062a843bSAndroid Build Coastguard Worker #endif
62*062a843bSAndroid Build Coastguard Worker 
63*062a843bSAndroid Build Coastguard Worker RIL_RadioFunctions *s_vendorFunctions = NULL;
64*062a843bSAndroid Build Coastguard Worker static CommandInfo *s_commands;
65*062a843bSAndroid Build Coastguard Worker 
66*062a843bSAndroid Build Coastguard Worker struct RadioImpl;
67*062a843bSAndroid Build Coastguard Worker 
68*062a843bSAndroid Build Coastguard Worker #if (SIM_COUNT >= 2)
69*062a843bSAndroid Build Coastguard Worker sp<RadioImpl> radioService[SIM_COUNT];
70*062a843bSAndroid Build Coastguard Worker int64_t nitzTimeReceived[SIM_COUNT];
71*062a843bSAndroid Build Coastguard Worker // counter used for synchronization. It is incremented every time response callbacks are updated.
72*062a843bSAndroid Build Coastguard Worker volatile int32_t mCounterRadio[SIM_COUNT];
73*062a843bSAndroid Build Coastguard Worker #else
74*062a843bSAndroid Build Coastguard Worker sp<RadioImpl> radioService[1];
75*062a843bSAndroid Build Coastguard Worker int64_t nitzTimeReceived[1];
76*062a843bSAndroid Build Coastguard Worker // counter used for synchronization. It is incremented every time response callbacks are updated.
77*062a843bSAndroid Build Coastguard Worker volatile int32_t mCounterRadio[1];
78*062a843bSAndroid Build Coastguard Worker #endif
79*062a843bSAndroid Build Coastguard Worker 
80*062a843bSAndroid Build Coastguard Worker static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
81*062a843bSAndroid Build Coastguard Worker 
82*062a843bSAndroid Build Coastguard Worker #if (SIM_COUNT >= 2)
83*062a843bSAndroid Build Coastguard Worker static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
84*062a843bSAndroid Build Coastguard Worker #if (SIM_COUNT >= 3)
85*062a843bSAndroid Build Coastguard Worker static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
86*062a843bSAndroid Build Coastguard Worker #if (SIM_COUNT >= 4)
87*062a843bSAndroid Build Coastguard Worker static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
88*062a843bSAndroid Build Coastguard Worker #endif
89*062a843bSAndroid Build Coastguard Worker #endif
90*062a843bSAndroid Build Coastguard Worker #endif
91*062a843bSAndroid Build Coastguard Worker 
92*062a843bSAndroid Build Coastguard Worker void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
93*062a843bSAndroid Build Coastguard Worker         hidl_vec<HardwareConfig>& records);
94*062a843bSAndroid Build Coastguard Worker 
95*062a843bSAndroid Build Coastguard Worker void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
96*062a843bSAndroid Build Coastguard Worker 
97*062a843bSAndroid Build Coastguard Worker void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
98*062a843bSAndroid Build Coastguard Worker 
99*062a843bSAndroid Build Coastguard Worker void convertRilSignalStrengthToHal(void *response, size_t responseLen,
100*062a843bSAndroid Build Coastguard Worker         SignalStrength& signalStrength);
101*062a843bSAndroid Build Coastguard Worker 
102*062a843bSAndroid Build Coastguard Worker void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
103*062a843bSAndroid Build Coastguard Worker         SetupDataCallResult& dcResult);
104*062a843bSAndroid Build Coastguard Worker 
105*062a843bSAndroid Build Coastguard Worker void convertRilDataCallListToHal(void *response, size_t responseLen,
106*062a843bSAndroid Build Coastguard Worker         hidl_vec<SetupDataCallResult>& dcResultList);
107*062a843bSAndroid Build Coastguard Worker 
108*062a843bSAndroid Build Coastguard Worker void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
109*062a843bSAndroid Build Coastguard Worker 
110*062a843bSAndroid Build Coastguard Worker struct RadioImpl : public V1_1::IRadio {
111*062a843bSAndroid Build Coastguard Worker     int32_t mSlotId;
112*062a843bSAndroid Build Coastguard Worker     sp<IRadioResponse> mRadioResponse;
113*062a843bSAndroid Build Coastguard Worker     sp<IRadioIndication> mRadioIndication;
114*062a843bSAndroid Build Coastguard Worker     sp<V1_1::IRadioResponse> mRadioResponseV1_1;
115*062a843bSAndroid Build Coastguard Worker     sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
116*062a843bSAndroid Build Coastguard Worker 
117*062a843bSAndroid Build Coastguard Worker     Return<void> setResponseFunctions(
118*062a843bSAndroid Build Coastguard Worker             const ::android::sp<IRadioResponse>& radioResponse,
119*062a843bSAndroid Build Coastguard Worker             const ::android::sp<IRadioIndication>& radioIndication);
120*062a843bSAndroid Build Coastguard Worker 
121*062a843bSAndroid Build Coastguard Worker     Return<void> getIccCardStatus(int32_t serial);
122*062a843bSAndroid Build Coastguard Worker 
123*062a843bSAndroid Build Coastguard Worker     Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
124*062a843bSAndroid Build Coastguard Worker             const hidl_string& aid);
125*062a843bSAndroid Build Coastguard Worker 
126*062a843bSAndroid Build Coastguard Worker     Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
127*062a843bSAndroid Build Coastguard Worker             const hidl_string& pin, const hidl_string& aid);
128*062a843bSAndroid Build Coastguard Worker 
129*062a843bSAndroid Build Coastguard Worker     Return<void> supplyIccPin2ForApp(int32_t serial,
130*062a843bSAndroid Build Coastguard Worker             const hidl_string& pin2,
131*062a843bSAndroid Build Coastguard Worker             const hidl_string& aid);
132*062a843bSAndroid Build Coastguard Worker 
133*062a843bSAndroid Build Coastguard Worker     Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
134*062a843bSAndroid Build Coastguard Worker             const hidl_string& pin2, const hidl_string& aid);
135*062a843bSAndroid Build Coastguard Worker 
136*062a843bSAndroid Build Coastguard Worker     Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
137*062a843bSAndroid Build Coastguard Worker             const hidl_string& newPin, const hidl_string& aid);
138*062a843bSAndroid Build Coastguard Worker 
139*062a843bSAndroid Build Coastguard Worker     Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
140*062a843bSAndroid Build Coastguard Worker             const hidl_string& newPin2, const hidl_string& aid);
141*062a843bSAndroid Build Coastguard Worker 
142*062a843bSAndroid Build Coastguard Worker     Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
143*062a843bSAndroid Build Coastguard Worker 
144*062a843bSAndroid Build Coastguard Worker     Return<void> getCurrentCalls(int32_t serial);
145*062a843bSAndroid Build Coastguard Worker 
146*062a843bSAndroid Build Coastguard Worker     Return<void> dial(int32_t serial, const Dial& dialInfo);
147*062a843bSAndroid Build Coastguard Worker 
148*062a843bSAndroid Build Coastguard Worker     Return<void> getImsiForApp(int32_t serial,
149*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& aid);
150*062a843bSAndroid Build Coastguard Worker 
151*062a843bSAndroid Build Coastguard Worker     Return<void> hangup(int32_t serial, int32_t gsmIndex);
152*062a843bSAndroid Build Coastguard Worker 
153*062a843bSAndroid Build Coastguard Worker     Return<void> hangupWaitingOrBackground(int32_t serial);
154*062a843bSAndroid Build Coastguard Worker 
155*062a843bSAndroid Build Coastguard Worker     Return<void> hangupForegroundResumeBackground(int32_t serial);
156*062a843bSAndroid Build Coastguard Worker 
157*062a843bSAndroid Build Coastguard Worker     Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
158*062a843bSAndroid Build Coastguard Worker 
159*062a843bSAndroid Build Coastguard Worker     Return<void> conference(int32_t serial);
160*062a843bSAndroid Build Coastguard Worker 
161*062a843bSAndroid Build Coastguard Worker     Return<void> rejectCall(int32_t serial);
162*062a843bSAndroid Build Coastguard Worker 
163*062a843bSAndroid Build Coastguard Worker     Return<void> getLastCallFailCause(int32_t serial);
164*062a843bSAndroid Build Coastguard Worker 
165*062a843bSAndroid Build Coastguard Worker     Return<void> getSignalStrength(int32_t serial);
166*062a843bSAndroid Build Coastguard Worker 
167*062a843bSAndroid Build Coastguard Worker     Return<void> getVoiceRegistrationState(int32_t serial);
168*062a843bSAndroid Build Coastguard Worker 
169*062a843bSAndroid Build Coastguard Worker     Return<void> getDataRegistrationState(int32_t serial);
170*062a843bSAndroid Build Coastguard Worker 
171*062a843bSAndroid Build Coastguard Worker     Return<void> getOperator(int32_t serial);
172*062a843bSAndroid Build Coastguard Worker 
173*062a843bSAndroid Build Coastguard Worker     Return<void> setRadioPower(int32_t serial, bool on);
174*062a843bSAndroid Build Coastguard Worker 
175*062a843bSAndroid Build Coastguard Worker     Return<void> sendDtmf(int32_t serial,
176*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& s);
177*062a843bSAndroid Build Coastguard Worker 
178*062a843bSAndroid Build Coastguard Worker     Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
179*062a843bSAndroid Build Coastguard Worker 
180*062a843bSAndroid Build Coastguard Worker     Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
181*062a843bSAndroid Build Coastguard Worker 
182*062a843bSAndroid Build Coastguard Worker     Return<void> setupDataCall(int32_t serial,
183*062a843bSAndroid Build Coastguard Worker             RadioTechnology radioTechnology,
184*062a843bSAndroid Build Coastguard Worker             const DataProfileInfo& profileInfo,
185*062a843bSAndroid Build Coastguard Worker             bool modemCognitive,
186*062a843bSAndroid Build Coastguard Worker             bool roamingAllowed,
187*062a843bSAndroid Build Coastguard Worker             bool isRoaming);
188*062a843bSAndroid Build Coastguard Worker 
189*062a843bSAndroid Build Coastguard Worker     Return<void> iccIOForApp(int32_t serial,
190*062a843bSAndroid Build Coastguard Worker             const IccIo& iccIo);
191*062a843bSAndroid Build Coastguard Worker 
192*062a843bSAndroid Build Coastguard Worker     Return<void> sendUssd(int32_t serial,
193*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& ussd);
194*062a843bSAndroid Build Coastguard Worker 
195*062a843bSAndroid Build Coastguard Worker     Return<void> cancelPendingUssd(int32_t serial);
196*062a843bSAndroid Build Coastguard Worker 
197*062a843bSAndroid Build Coastguard Worker     Return<void> getClir(int32_t serial);
198*062a843bSAndroid Build Coastguard Worker 
199*062a843bSAndroid Build Coastguard Worker     Return<void> setClir(int32_t serial, int32_t status);
200*062a843bSAndroid Build Coastguard Worker 
201*062a843bSAndroid Build Coastguard Worker     Return<void> getCallForwardStatus(int32_t serial,
202*062a843bSAndroid Build Coastguard Worker             const CallForwardInfo& callInfo);
203*062a843bSAndroid Build Coastguard Worker 
204*062a843bSAndroid Build Coastguard Worker     Return<void> setCallForward(int32_t serial,
205*062a843bSAndroid Build Coastguard Worker             const CallForwardInfo& callInfo);
206*062a843bSAndroid Build Coastguard Worker 
207*062a843bSAndroid Build Coastguard Worker     Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
208*062a843bSAndroid Build Coastguard Worker 
209*062a843bSAndroid Build Coastguard Worker     Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
210*062a843bSAndroid Build Coastguard Worker 
211*062a843bSAndroid Build Coastguard Worker     Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
212*062a843bSAndroid Build Coastguard Worker             bool success, SmsAcknowledgeFailCause cause);
213*062a843bSAndroid Build Coastguard Worker 
214*062a843bSAndroid Build Coastguard Worker     Return<void> acceptCall(int32_t serial);
215*062a843bSAndroid Build Coastguard Worker 
216*062a843bSAndroid Build Coastguard Worker     Return<void> deactivateDataCall(int32_t serial,
217*062a843bSAndroid Build Coastguard Worker             int32_t cid, bool reasonRadioShutDown);
218*062a843bSAndroid Build Coastguard Worker 
219*062a843bSAndroid Build Coastguard Worker     Return<void> getFacilityLockForApp(int32_t serial,
220*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& facility,
221*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& password,
222*062a843bSAndroid Build Coastguard Worker             int32_t serviceClass,
223*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& appId);
224*062a843bSAndroid Build Coastguard Worker 
225*062a843bSAndroid Build Coastguard Worker     Return<void> setFacilityLockForApp(int32_t serial,
226*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& facility,
227*062a843bSAndroid Build Coastguard Worker             bool lockState,
228*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& password,
229*062a843bSAndroid Build Coastguard Worker             int32_t serviceClass,
230*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& appId);
231*062a843bSAndroid Build Coastguard Worker 
232*062a843bSAndroid Build Coastguard Worker     Return<void> setBarringPassword(int32_t serial,
233*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& facility,
234*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& oldPassword,
235*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& newPassword);
236*062a843bSAndroid Build Coastguard Worker 
237*062a843bSAndroid Build Coastguard Worker     Return<void> getNetworkSelectionMode(int32_t serial);
238*062a843bSAndroid Build Coastguard Worker 
239*062a843bSAndroid Build Coastguard Worker     Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
240*062a843bSAndroid Build Coastguard Worker 
241*062a843bSAndroid Build Coastguard Worker     Return<void> setNetworkSelectionModeManual(int32_t serial,
242*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& operatorNumeric);
243*062a843bSAndroid Build Coastguard Worker 
244*062a843bSAndroid Build Coastguard Worker     Return<void> getAvailableNetworks(int32_t serial);
245*062a843bSAndroid Build Coastguard Worker 
246*062a843bSAndroid Build Coastguard Worker     Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
247*062a843bSAndroid Build Coastguard Worker 
248*062a843bSAndroid Build Coastguard Worker     Return<void> stopNetworkScan(int32_t serial);
249*062a843bSAndroid Build Coastguard Worker 
250*062a843bSAndroid Build Coastguard Worker     Return<void> startDtmf(int32_t serial,
251*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& s);
252*062a843bSAndroid Build Coastguard Worker 
253*062a843bSAndroid Build Coastguard Worker     Return<void> stopDtmf(int32_t serial);
254*062a843bSAndroid Build Coastguard Worker 
255*062a843bSAndroid Build Coastguard Worker     Return<void> getBasebandVersion(int32_t serial);
256*062a843bSAndroid Build Coastguard Worker 
257*062a843bSAndroid Build Coastguard Worker     Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
258*062a843bSAndroid Build Coastguard Worker 
259*062a843bSAndroid Build Coastguard Worker     Return<void> setMute(int32_t serial, bool enable);
260*062a843bSAndroid Build Coastguard Worker 
261*062a843bSAndroid Build Coastguard Worker     Return<void> getMute(int32_t serial);
262*062a843bSAndroid Build Coastguard Worker 
263*062a843bSAndroid Build Coastguard Worker     Return<void> getClip(int32_t serial);
264*062a843bSAndroid Build Coastguard Worker 
265*062a843bSAndroid Build Coastguard Worker     Return<void> getDataCallList(int32_t serial);
266*062a843bSAndroid Build Coastguard Worker 
267*062a843bSAndroid Build Coastguard Worker     Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
268*062a843bSAndroid Build Coastguard Worker 
269*062a843bSAndroid Build Coastguard Worker     Return<void> writeSmsToSim(int32_t serial,
270*062a843bSAndroid Build Coastguard Worker             const SmsWriteArgs& smsWriteArgs);
271*062a843bSAndroid Build Coastguard Worker 
272*062a843bSAndroid Build Coastguard Worker     Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
273*062a843bSAndroid Build Coastguard Worker 
274*062a843bSAndroid Build Coastguard Worker     Return<void> setBandMode(int32_t serial, RadioBandMode mode);
275*062a843bSAndroid Build Coastguard Worker 
276*062a843bSAndroid Build Coastguard Worker     Return<void> getAvailableBandModes(int32_t serial);
277*062a843bSAndroid Build Coastguard Worker 
278*062a843bSAndroid Build Coastguard Worker     Return<void> sendEnvelope(int32_t serial,
279*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& command);
280*062a843bSAndroid Build Coastguard Worker 
281*062a843bSAndroid Build Coastguard Worker     Return<void> sendTerminalResponseToSim(int32_t serial,
282*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& commandResponse);
283*062a843bSAndroid Build Coastguard Worker 
284*062a843bSAndroid Build Coastguard Worker     Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
285*062a843bSAndroid Build Coastguard Worker 
286*062a843bSAndroid Build Coastguard Worker     Return<void> explicitCallTransfer(int32_t serial);
287*062a843bSAndroid Build Coastguard Worker 
288*062a843bSAndroid Build Coastguard Worker     Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
289*062a843bSAndroid Build Coastguard Worker 
290*062a843bSAndroid Build Coastguard Worker     Return<void> getPreferredNetworkType(int32_t serial);
291*062a843bSAndroid Build Coastguard Worker 
292*062a843bSAndroid Build Coastguard Worker     Return<void> getNeighboringCids(int32_t serial);
293*062a843bSAndroid Build Coastguard Worker 
294*062a843bSAndroid Build Coastguard Worker     Return<void> setLocationUpdates(int32_t serial, bool enable);
295*062a843bSAndroid Build Coastguard Worker 
296*062a843bSAndroid Build Coastguard Worker     Return<void> setCdmaSubscriptionSource(int32_t serial,
297*062a843bSAndroid Build Coastguard Worker             CdmaSubscriptionSource cdmaSub);
298*062a843bSAndroid Build Coastguard Worker 
299*062a843bSAndroid Build Coastguard Worker     Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
300*062a843bSAndroid Build Coastguard Worker 
301*062a843bSAndroid Build Coastguard Worker     Return<void> getCdmaRoamingPreference(int32_t serial);
302*062a843bSAndroid Build Coastguard Worker 
303*062a843bSAndroid Build Coastguard Worker     Return<void> setTTYMode(int32_t serial, TtyMode mode);
304*062a843bSAndroid Build Coastguard Worker 
305*062a843bSAndroid Build Coastguard Worker     Return<void> getTTYMode(int32_t serial);
306*062a843bSAndroid Build Coastguard Worker 
307*062a843bSAndroid Build Coastguard Worker     Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
308*062a843bSAndroid Build Coastguard Worker 
309*062a843bSAndroid Build Coastguard Worker     Return<void> getPreferredVoicePrivacy(int32_t serial);
310*062a843bSAndroid Build Coastguard Worker 
311*062a843bSAndroid Build Coastguard Worker     Return<void> sendCDMAFeatureCode(int32_t serial,
312*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& featureCode);
313*062a843bSAndroid Build Coastguard Worker 
314*062a843bSAndroid Build Coastguard Worker     Return<void> sendBurstDtmf(int32_t serial,
315*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& dtmf,
316*062a843bSAndroid Build Coastguard Worker             int32_t on,
317*062a843bSAndroid Build Coastguard Worker             int32_t off);
318*062a843bSAndroid Build Coastguard Worker 
319*062a843bSAndroid Build Coastguard Worker     Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
320*062a843bSAndroid Build Coastguard Worker 
321*062a843bSAndroid Build Coastguard Worker     Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
322*062a843bSAndroid Build Coastguard Worker             const CdmaSmsAck& smsAck);
323*062a843bSAndroid Build Coastguard Worker 
324*062a843bSAndroid Build Coastguard Worker     Return<void> getGsmBroadcastConfig(int32_t serial);
325*062a843bSAndroid Build Coastguard Worker 
326*062a843bSAndroid Build Coastguard Worker     Return<void> setGsmBroadcastConfig(int32_t serial,
327*062a843bSAndroid Build Coastguard Worker             const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
328*062a843bSAndroid Build Coastguard Worker 
329*062a843bSAndroid Build Coastguard Worker     Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
330*062a843bSAndroid Build Coastguard Worker 
331*062a843bSAndroid Build Coastguard Worker     Return<void> getCdmaBroadcastConfig(int32_t serial);
332*062a843bSAndroid Build Coastguard Worker 
333*062a843bSAndroid Build Coastguard Worker     Return<void> setCdmaBroadcastConfig(int32_t serial,
334*062a843bSAndroid Build Coastguard Worker             const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
335*062a843bSAndroid Build Coastguard Worker 
336*062a843bSAndroid Build Coastguard Worker     Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
337*062a843bSAndroid Build Coastguard Worker 
338*062a843bSAndroid Build Coastguard Worker     Return<void> getCDMASubscription(int32_t serial);
339*062a843bSAndroid Build Coastguard Worker 
340*062a843bSAndroid Build Coastguard Worker     Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
341*062a843bSAndroid Build Coastguard Worker 
342*062a843bSAndroid Build Coastguard Worker     Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
343*062a843bSAndroid Build Coastguard Worker 
344*062a843bSAndroid Build Coastguard Worker     Return<void> getDeviceIdentity(int32_t serial);
345*062a843bSAndroid Build Coastguard Worker 
346*062a843bSAndroid Build Coastguard Worker     Return<void> exitEmergencyCallbackMode(int32_t serial);
347*062a843bSAndroid Build Coastguard Worker 
348*062a843bSAndroid Build Coastguard Worker     Return<void> getSmscAddress(int32_t serial);
349*062a843bSAndroid Build Coastguard Worker 
350*062a843bSAndroid Build Coastguard Worker     Return<void> setSmscAddress(int32_t serial,
351*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& smsc);
352*062a843bSAndroid Build Coastguard Worker 
353*062a843bSAndroid Build Coastguard Worker     Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
354*062a843bSAndroid Build Coastguard Worker 
355*062a843bSAndroid Build Coastguard Worker     Return<void> reportStkServiceIsRunning(int32_t serial);
356*062a843bSAndroid Build Coastguard Worker 
357*062a843bSAndroid Build Coastguard Worker     Return<void> getCdmaSubscriptionSource(int32_t serial);
358*062a843bSAndroid Build Coastguard Worker 
359*062a843bSAndroid Build Coastguard Worker     Return<void> requestIsimAuthentication(int32_t serial,
360*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& challenge);
361*062a843bSAndroid Build Coastguard Worker 
362*062a843bSAndroid Build Coastguard Worker     Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
363*062a843bSAndroid Build Coastguard Worker             bool success,
364*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& ackPdu);
365*062a843bSAndroid Build Coastguard Worker 
366*062a843bSAndroid Build Coastguard Worker     Return<void> sendEnvelopeWithStatus(int32_t serial,
367*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& contents);
368*062a843bSAndroid Build Coastguard Worker 
369*062a843bSAndroid Build Coastguard Worker     Return<void> getVoiceRadioTechnology(int32_t serial);
370*062a843bSAndroid Build Coastguard Worker 
371*062a843bSAndroid Build Coastguard Worker     Return<void> getCellInfoList(int32_t serial);
372*062a843bSAndroid Build Coastguard Worker 
373*062a843bSAndroid Build Coastguard Worker     Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
374*062a843bSAndroid Build Coastguard Worker 
375*062a843bSAndroid Build Coastguard Worker     Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
376*062a843bSAndroid Build Coastguard Worker             bool modemCognitive, bool isRoaming);
377*062a843bSAndroid Build Coastguard Worker 
378*062a843bSAndroid Build Coastguard Worker     Return<void> getImsRegistrationState(int32_t serial);
379*062a843bSAndroid Build Coastguard Worker 
380*062a843bSAndroid Build Coastguard Worker     Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
381*062a843bSAndroid Build Coastguard Worker 
382*062a843bSAndroid Build Coastguard Worker     Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
383*062a843bSAndroid Build Coastguard Worker 
384*062a843bSAndroid Build Coastguard Worker     Return<void> iccOpenLogicalChannel(int32_t serial,
385*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& aid, int32_t p2);
386*062a843bSAndroid Build Coastguard Worker 
387*062a843bSAndroid Build Coastguard Worker     Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
388*062a843bSAndroid Build Coastguard Worker 
389*062a843bSAndroid Build Coastguard Worker     Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
390*062a843bSAndroid Build Coastguard Worker 
391*062a843bSAndroid Build Coastguard Worker     Return<void> nvReadItem(int32_t serial, NvItem itemId);
392*062a843bSAndroid Build Coastguard Worker 
393*062a843bSAndroid Build Coastguard Worker     Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
394*062a843bSAndroid Build Coastguard Worker 
395*062a843bSAndroid Build Coastguard Worker     Return<void> nvWriteCdmaPrl(int32_t serial,
396*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_vec<uint8_t>& prl);
397*062a843bSAndroid Build Coastguard Worker 
398*062a843bSAndroid Build Coastguard Worker     Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
399*062a843bSAndroid Build Coastguard Worker 
400*062a843bSAndroid Build Coastguard Worker     Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
401*062a843bSAndroid Build Coastguard Worker 
402*062a843bSAndroid Build Coastguard Worker     Return<void> setDataAllowed(int32_t serial, bool allow);
403*062a843bSAndroid Build Coastguard Worker 
404*062a843bSAndroid Build Coastguard Worker     Return<void> getHardwareConfig(int32_t serial);
405*062a843bSAndroid Build Coastguard Worker 
406*062a843bSAndroid Build Coastguard Worker     Return<void> requestIccSimAuthentication(int32_t serial,
407*062a843bSAndroid Build Coastguard Worker             int32_t authContext,
408*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& authData,
409*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_string& aid);
410*062a843bSAndroid Build Coastguard Worker 
411*062a843bSAndroid Build Coastguard Worker     Return<void> setDataProfile(int32_t serial,
412*062a843bSAndroid Build Coastguard Worker             const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
413*062a843bSAndroid Build Coastguard Worker 
414*062a843bSAndroid Build Coastguard Worker     Return<void> requestShutdown(int32_t serial);
415*062a843bSAndroid Build Coastguard Worker 
416*062a843bSAndroid Build Coastguard Worker     Return<void> getRadioCapability(int32_t serial);
417*062a843bSAndroid Build Coastguard Worker 
418*062a843bSAndroid Build Coastguard Worker     Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
419*062a843bSAndroid Build Coastguard Worker 
420*062a843bSAndroid Build Coastguard Worker     Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
421*062a843bSAndroid Build Coastguard Worker 
422*062a843bSAndroid Build Coastguard Worker     Return<void> stopLceService(int32_t serial);
423*062a843bSAndroid Build Coastguard Worker 
424*062a843bSAndroid Build Coastguard Worker     Return<void> pullLceData(int32_t serial);
425*062a843bSAndroid Build Coastguard Worker 
426*062a843bSAndroid Build Coastguard Worker     Return<void> getModemActivityInfo(int32_t serial);
427*062a843bSAndroid Build Coastguard Worker 
428*062a843bSAndroid Build Coastguard Worker     Return<void> setAllowedCarriers(int32_t serial,
429*062a843bSAndroid Build Coastguard Worker             bool allAllowed,
430*062a843bSAndroid Build Coastguard Worker             const CarrierRestrictions& carriers);
431*062a843bSAndroid Build Coastguard Worker 
432*062a843bSAndroid Build Coastguard Worker     Return<void> getAllowedCarriers(int32_t serial);
433*062a843bSAndroid Build Coastguard Worker 
434*062a843bSAndroid Build Coastguard Worker     Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
435*062a843bSAndroid Build Coastguard Worker 
436*062a843bSAndroid Build Coastguard Worker     Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
437*062a843bSAndroid Build Coastguard Worker 
438*062a843bSAndroid Build Coastguard Worker     Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
439*062a843bSAndroid Build Coastguard Worker 
440*062a843bSAndroid Build Coastguard Worker     Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
441*062a843bSAndroid Build Coastguard Worker 
442*062a843bSAndroid Build Coastguard Worker     Return<void> setSimCardPower(int32_t serial, bool powerUp);
443*062a843bSAndroid Build Coastguard Worker     Return<void> setSimCardPower_1_1(int32_t serial,
444*062a843bSAndroid Build Coastguard Worker             const V1_1::CardPowerState state);
445*062a843bSAndroid Build Coastguard Worker 
446*062a843bSAndroid Build Coastguard Worker     Return<void> responseAcknowledgement();
447*062a843bSAndroid Build Coastguard Worker 
448*062a843bSAndroid Build Coastguard Worker     Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
449*062a843bSAndroid Build Coastguard Worker             const V1_1::ImsiEncryptionInfo& message);
450*062a843bSAndroid Build Coastguard Worker 
451*062a843bSAndroid Build Coastguard Worker     void checkReturnStatus(Return<void>& ret);
452*062a843bSAndroid Build Coastguard Worker };
453*062a843bSAndroid Build Coastguard Worker 
memsetAndFreeStrings(int numPointers,...)454*062a843bSAndroid Build Coastguard Worker void memsetAndFreeStrings(int numPointers, ...) {
455*062a843bSAndroid Build Coastguard Worker     va_list ap;
456*062a843bSAndroid Build Coastguard Worker     va_start(ap, numPointers);
457*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < numPointers; i++) {
458*062a843bSAndroid Build Coastguard Worker         char *ptr = va_arg(ap, char *);
459*062a843bSAndroid Build Coastguard Worker         if (ptr) {
460*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
461*062a843bSAndroid Build Coastguard Worker #define MAX_STRING_LENGTH 4096
462*062a843bSAndroid Build Coastguard Worker             memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
463*062a843bSAndroid Build Coastguard Worker #endif
464*062a843bSAndroid Build Coastguard Worker             free(ptr);
465*062a843bSAndroid Build Coastguard Worker         }
466*062a843bSAndroid Build Coastguard Worker     }
467*062a843bSAndroid Build Coastguard Worker     va_end(ap);
468*062a843bSAndroid Build Coastguard Worker }
469*062a843bSAndroid Build Coastguard Worker 
sendErrorResponse(RequestInfo * pRI,RIL_Errno err)470*062a843bSAndroid Build Coastguard Worker void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
471*062a843bSAndroid Build Coastguard Worker     pRI->pCI->responseFunction((int) pRI->socket_id,
472*062a843bSAndroid Build Coastguard Worker             (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
473*062a843bSAndroid Build Coastguard Worker }
474*062a843bSAndroid Build Coastguard Worker 
475*062a843bSAndroid Build Coastguard Worker /**
476*062a843bSAndroid Build Coastguard Worker  * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
477*062a843bSAndroid Build Coastguard Worker  * request with error RIL_E_NO_MEMORY. The size() method is used to determine the size of the
478*062a843bSAndroid Build Coastguard Worker  * destination buffer into which the HIDL string is copied. If there is a discrepancy between
479*062a843bSAndroid Build Coastguard Worker  * the string length reported by the size() method, and the length of the string returned by
480*062a843bSAndroid Build Coastguard Worker  * the c_str() method, the function will return false indicating a failure.
481*062a843bSAndroid Build Coastguard Worker  *
482*062a843bSAndroid Build Coastguard Worker  * Returns true on success, and false on failure.
483*062a843bSAndroid Build Coastguard Worker  */
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI,bool allowEmpty)484*062a843bSAndroid Build Coastguard Worker bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
485*062a843bSAndroid Build Coastguard Worker     size_t len = src.size();
486*062a843bSAndroid Build Coastguard Worker     if (len == 0 && !allowEmpty) {
487*062a843bSAndroid Build Coastguard Worker         *dest = NULL;
488*062a843bSAndroid Build Coastguard Worker         return true;
489*062a843bSAndroid Build Coastguard Worker     }
490*062a843bSAndroid Build Coastguard Worker     *dest = (char *) calloc(len + 1, sizeof(char));
491*062a843bSAndroid Build Coastguard Worker     if (*dest == NULL) {
492*062a843bSAndroid Build Coastguard Worker         RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
493*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
494*062a843bSAndroid Build Coastguard Worker         return false;
495*062a843bSAndroid Build Coastguard Worker     }
496*062a843bSAndroid Build Coastguard Worker     if (strlcpy(*dest, src.c_str(), len + 1) >= (len + 1)) {
497*062a843bSAndroid Build Coastguard Worker         RLOGE("Copy of the HIDL string has been truncated, as "
498*062a843bSAndroid Build Coastguard Worker               "the string length reported by size() does not "
499*062a843bSAndroid Build Coastguard Worker               "match the length of string returned by c_str().");
500*062a843bSAndroid Build Coastguard Worker         free(*dest);
501*062a843bSAndroid Build Coastguard Worker         *dest = NULL;
502*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_INTERNAL_ERR);
503*062a843bSAndroid Build Coastguard Worker         return false;
504*062a843bSAndroid Build Coastguard Worker     }
505*062a843bSAndroid Build Coastguard Worker     return true;
506*062a843bSAndroid Build Coastguard Worker }
507*062a843bSAndroid Build Coastguard Worker 
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI)508*062a843bSAndroid Build Coastguard Worker bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
509*062a843bSAndroid Build Coastguard Worker     return copyHidlStringToRil(dest, src, pRI, false);
510*062a843bSAndroid Build Coastguard Worker }
511*062a843bSAndroid Build Coastguard Worker 
convertCharPtrToHidlString(const char * ptr)512*062a843bSAndroid Build Coastguard Worker hidl_string convertCharPtrToHidlString(const char *ptr) {
513*062a843bSAndroid Build Coastguard Worker     hidl_string ret;
514*062a843bSAndroid Build Coastguard Worker     if (ptr != NULL) {
515*062a843bSAndroid Build Coastguard Worker         // TODO: replace this with strnlen
516*062a843bSAndroid Build Coastguard Worker         ret.setToExternal(ptr, strlen(ptr));
517*062a843bSAndroid Build Coastguard Worker     }
518*062a843bSAndroid Build Coastguard Worker     return ret;
519*062a843bSAndroid Build Coastguard Worker }
520*062a843bSAndroid Build Coastguard Worker 
dispatchVoid(int serial,int slotId,int request)521*062a843bSAndroid Build Coastguard Worker bool dispatchVoid(int serial, int slotId, int request) {
522*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
523*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
524*062a843bSAndroid Build Coastguard Worker         return false;
525*062a843bSAndroid Build Coastguard Worker     }
526*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
527*062a843bSAndroid Build Coastguard Worker     return true;
528*062a843bSAndroid Build Coastguard Worker }
529*062a843bSAndroid Build Coastguard Worker 
dispatchString(int serial,int slotId,int request,const char * str)530*062a843bSAndroid Build Coastguard Worker bool dispatchString(int serial, int slotId, int request, const char * str) {
531*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
532*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
533*062a843bSAndroid Build Coastguard Worker         return false;
534*062a843bSAndroid Build Coastguard Worker     }
535*062a843bSAndroid Build Coastguard Worker 
536*062a843bSAndroid Build Coastguard Worker     char *pString;
537*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&pString, str, pRI)) {
538*062a843bSAndroid Build Coastguard Worker         return false;
539*062a843bSAndroid Build Coastguard Worker     }
540*062a843bSAndroid Build Coastguard Worker 
541*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
542*062a843bSAndroid Build Coastguard Worker 
543*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(1, pString);
544*062a843bSAndroid Build Coastguard Worker     return true;
545*062a843bSAndroid Build Coastguard Worker }
546*062a843bSAndroid Build Coastguard Worker 
dispatchStrings(int serial,int slotId,int request,bool allowEmpty,int countStrings,...)547*062a843bSAndroid Build Coastguard Worker bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
548*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
549*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
550*062a843bSAndroid Build Coastguard Worker         return false;
551*062a843bSAndroid Build Coastguard Worker     }
552*062a843bSAndroid Build Coastguard Worker 
553*062a843bSAndroid Build Coastguard Worker     char **pStrings;
554*062a843bSAndroid Build Coastguard Worker     pStrings = (char **)calloc(countStrings, sizeof(char *));
555*062a843bSAndroid Build Coastguard Worker     if (pStrings == NULL) {
556*062a843bSAndroid Build Coastguard Worker         RLOGE("Memory allocation failed for request %s", requestToString(request));
557*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
558*062a843bSAndroid Build Coastguard Worker         return false;
559*062a843bSAndroid Build Coastguard Worker     }
560*062a843bSAndroid Build Coastguard Worker     va_list ap;
561*062a843bSAndroid Build Coastguard Worker     va_start(ap, countStrings);
562*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < countStrings; i++) {
563*062a843bSAndroid Build Coastguard Worker         const char* str = va_arg(ap, const char *);
564*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
565*062a843bSAndroid Build Coastguard Worker             va_end(ap);
566*062a843bSAndroid Build Coastguard Worker             for (int j = 0; j < i; j++) {
567*062a843bSAndroid Build Coastguard Worker                 memsetAndFreeStrings(1, pStrings[j]);
568*062a843bSAndroid Build Coastguard Worker             }
569*062a843bSAndroid Build Coastguard Worker             free(pStrings);
570*062a843bSAndroid Build Coastguard Worker             return false;
571*062a843bSAndroid Build Coastguard Worker         }
572*062a843bSAndroid Build Coastguard Worker     }
573*062a843bSAndroid Build Coastguard Worker     va_end(ap);
574*062a843bSAndroid Build Coastguard Worker 
575*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
576*062a843bSAndroid Build Coastguard Worker 
577*062a843bSAndroid Build Coastguard Worker     if (pStrings != NULL) {
578*062a843bSAndroid Build Coastguard Worker         for (int i = 0 ; i < countStrings ; i++) {
579*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(1, pStrings[i]);
580*062a843bSAndroid Build Coastguard Worker         }
581*062a843bSAndroid Build Coastguard Worker 
582*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
583*062a843bSAndroid Build Coastguard Worker         memset(pStrings, 0, countStrings * sizeof(char *));
584*062a843bSAndroid Build Coastguard Worker #endif
585*062a843bSAndroid Build Coastguard Worker         free(pStrings);
586*062a843bSAndroid Build Coastguard Worker     }
587*062a843bSAndroid Build Coastguard Worker     return true;
588*062a843bSAndroid Build Coastguard Worker }
589*062a843bSAndroid Build Coastguard Worker 
dispatchStrings(int serial,int slotId,int request,const hidl_vec<hidl_string> & data)590*062a843bSAndroid Build Coastguard Worker bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
591*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
592*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
593*062a843bSAndroid Build Coastguard Worker         return false;
594*062a843bSAndroid Build Coastguard Worker     }
595*062a843bSAndroid Build Coastguard Worker 
596*062a843bSAndroid Build Coastguard Worker     int countStrings = data.size();
597*062a843bSAndroid Build Coastguard Worker     char **pStrings;
598*062a843bSAndroid Build Coastguard Worker     pStrings = (char **)calloc(countStrings, sizeof(char *));
599*062a843bSAndroid Build Coastguard Worker     if (pStrings == NULL) {
600*062a843bSAndroid Build Coastguard Worker         RLOGE("Memory allocation failed for request %s", requestToString(request));
601*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
602*062a843bSAndroid Build Coastguard Worker         return false;
603*062a843bSAndroid Build Coastguard Worker     }
604*062a843bSAndroid Build Coastguard Worker 
605*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < countStrings; i++) {
606*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
607*062a843bSAndroid Build Coastguard Worker             for (int j = 0; j < i; j++) {
608*062a843bSAndroid Build Coastguard Worker                 memsetAndFreeStrings(1, pStrings[j]);
609*062a843bSAndroid Build Coastguard Worker             }
610*062a843bSAndroid Build Coastguard Worker             free(pStrings);
611*062a843bSAndroid Build Coastguard Worker             return false;
612*062a843bSAndroid Build Coastguard Worker         }
613*062a843bSAndroid Build Coastguard Worker     }
614*062a843bSAndroid Build Coastguard Worker 
615*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
616*062a843bSAndroid Build Coastguard Worker 
617*062a843bSAndroid Build Coastguard Worker     if (pStrings != NULL) {
618*062a843bSAndroid Build Coastguard Worker         for (int i = 0 ; i < countStrings ; i++) {
619*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(1, pStrings[i]);
620*062a843bSAndroid Build Coastguard Worker         }
621*062a843bSAndroid Build Coastguard Worker 
622*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
623*062a843bSAndroid Build Coastguard Worker         memset(pStrings, 0, countStrings * sizeof(char *));
624*062a843bSAndroid Build Coastguard Worker #endif
625*062a843bSAndroid Build Coastguard Worker         free(pStrings);
626*062a843bSAndroid Build Coastguard Worker     }
627*062a843bSAndroid Build Coastguard Worker     return true;
628*062a843bSAndroid Build Coastguard Worker }
629*062a843bSAndroid Build Coastguard Worker 
dispatchInts(int serial,int slotId,int request,int countInts,...)630*062a843bSAndroid Build Coastguard Worker bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
631*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
632*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
633*062a843bSAndroid Build Coastguard Worker         return false;
634*062a843bSAndroid Build Coastguard Worker     }
635*062a843bSAndroid Build Coastguard Worker 
636*062a843bSAndroid Build Coastguard Worker     int *pInts = (int *)calloc(countInts, sizeof(int));
637*062a843bSAndroid Build Coastguard Worker 
638*062a843bSAndroid Build Coastguard Worker     if (pInts == NULL) {
639*062a843bSAndroid Build Coastguard Worker         RLOGE("Memory allocation failed for request %s", requestToString(request));
640*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
641*062a843bSAndroid Build Coastguard Worker         return false;
642*062a843bSAndroid Build Coastguard Worker     }
643*062a843bSAndroid Build Coastguard Worker     va_list ap;
644*062a843bSAndroid Build Coastguard Worker     va_start(ap, countInts);
645*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < countInts; i++) {
646*062a843bSAndroid Build Coastguard Worker         pInts[i] = va_arg(ap, int);
647*062a843bSAndroid Build Coastguard Worker     }
648*062a843bSAndroid Build Coastguard Worker     va_end(ap);
649*062a843bSAndroid Build Coastguard Worker 
650*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
651*062a843bSAndroid Build Coastguard Worker 
652*062a843bSAndroid Build Coastguard Worker     if (pInts != NULL) {
653*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
654*062a843bSAndroid Build Coastguard Worker         memset(pInts, 0, countInts * sizeof(int));
655*062a843bSAndroid Build Coastguard Worker #endif
656*062a843bSAndroid Build Coastguard Worker         free(pInts);
657*062a843bSAndroid Build Coastguard Worker     }
658*062a843bSAndroid Build Coastguard Worker     return true;
659*062a843bSAndroid Build Coastguard Worker }
660*062a843bSAndroid Build Coastguard Worker 
dispatchCallForwardStatus(int serial,int slotId,int request,const CallForwardInfo & callInfo)661*062a843bSAndroid Build Coastguard Worker bool dispatchCallForwardStatus(int serial, int slotId, int request,
662*062a843bSAndroid Build Coastguard Worker                               const CallForwardInfo& callInfo) {
663*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
664*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
665*062a843bSAndroid Build Coastguard Worker         return false;
666*062a843bSAndroid Build Coastguard Worker     }
667*062a843bSAndroid Build Coastguard Worker 
668*062a843bSAndroid Build Coastguard Worker     RIL_CallForwardInfo cf;
669*062a843bSAndroid Build Coastguard Worker     cf.status = (int) callInfo.status;
670*062a843bSAndroid Build Coastguard Worker     cf.reason = callInfo.reason;
671*062a843bSAndroid Build Coastguard Worker     cf.serviceClass = callInfo.serviceClass;
672*062a843bSAndroid Build Coastguard Worker     cf.toa = callInfo.toa;
673*062a843bSAndroid Build Coastguard Worker     cf.timeSeconds = callInfo.timeSeconds;
674*062a843bSAndroid Build Coastguard Worker 
675*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
676*062a843bSAndroid Build Coastguard Worker         return false;
677*062a843bSAndroid Build Coastguard Worker     }
678*062a843bSAndroid Build Coastguard Worker 
679*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
680*062a843bSAndroid Build Coastguard Worker 
681*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(1, cf.number);
682*062a843bSAndroid Build Coastguard Worker 
683*062a843bSAndroid Build Coastguard Worker     return true;
684*062a843bSAndroid Build Coastguard Worker }
685*062a843bSAndroid Build Coastguard Worker 
dispatchRaw(int serial,int slotId,int request,const hidl_vec<uint8_t> & rawBytes)686*062a843bSAndroid Build Coastguard Worker bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
687*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
688*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
689*062a843bSAndroid Build Coastguard Worker         return false;
690*062a843bSAndroid Build Coastguard Worker     }
691*062a843bSAndroid Build Coastguard Worker 
692*062a843bSAndroid Build Coastguard Worker     const uint8_t *uData = rawBytes.data();
693*062a843bSAndroid Build Coastguard Worker 
694*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
695*062a843bSAndroid Build Coastguard Worker 
696*062a843bSAndroid Build Coastguard Worker     return true;
697*062a843bSAndroid Build Coastguard Worker }
698*062a843bSAndroid Build Coastguard Worker 
dispatchIccApdu(int serial,int slotId,int request,const SimApdu & message)699*062a843bSAndroid Build Coastguard Worker bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
700*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
701*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
702*062a843bSAndroid Build Coastguard Worker         return false;
703*062a843bSAndroid Build Coastguard Worker     }
704*062a843bSAndroid Build Coastguard Worker 
705*062a843bSAndroid Build Coastguard Worker     RIL_SIM_APDU apdu = {};
706*062a843bSAndroid Build Coastguard Worker 
707*062a843bSAndroid Build Coastguard Worker     apdu.sessionid = message.sessionId;
708*062a843bSAndroid Build Coastguard Worker     apdu.cla = message.cla;
709*062a843bSAndroid Build Coastguard Worker     apdu.instruction = message.instruction;
710*062a843bSAndroid Build Coastguard Worker     apdu.p1 = message.p1;
711*062a843bSAndroid Build Coastguard Worker     apdu.p2 = message.p2;
712*062a843bSAndroid Build Coastguard Worker     apdu.p3 = message.p3;
713*062a843bSAndroid Build Coastguard Worker 
714*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
715*062a843bSAndroid Build Coastguard Worker         return false;
716*062a843bSAndroid Build Coastguard Worker     }
717*062a843bSAndroid Build Coastguard Worker 
718*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
719*062a843bSAndroid Build Coastguard Worker 
720*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(1, apdu.data);
721*062a843bSAndroid Build Coastguard Worker 
722*062a843bSAndroid Build Coastguard Worker     return true;
723*062a843bSAndroid Build Coastguard Worker }
724*062a843bSAndroid Build Coastguard Worker 
checkReturnStatus(int32_t slotId,Return<void> & ret,bool isRadioService)725*062a843bSAndroid Build Coastguard Worker void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
726*062a843bSAndroid Build Coastguard Worker     if (ret.isOk() == false) {
727*062a843bSAndroid Build Coastguard Worker         RLOGE("checkReturnStatus: unable to call response/indication callback");
728*062a843bSAndroid Build Coastguard Worker         // Remote process hosting the callbacks must be dead. Reset the callback objects;
729*062a843bSAndroid Build Coastguard Worker         // there's no other recovery to be done here. When the client process is back up, it will
730*062a843bSAndroid Build Coastguard Worker         // call setResponseFunctions()
731*062a843bSAndroid Build Coastguard Worker 
732*062a843bSAndroid Build Coastguard Worker         // Caller should already hold rdlock, release that first
733*062a843bSAndroid Build Coastguard Worker         // note the current counter to avoid overwriting updates made by another thread before
734*062a843bSAndroid Build Coastguard Worker         // write lock is acquired.
735*062a843bSAndroid Build Coastguard Worker         int counter = mCounterRadio[slotId];
736*062a843bSAndroid Build Coastguard Worker         pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
737*062a843bSAndroid Build Coastguard Worker         int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
738*062a843bSAndroid Build Coastguard Worker         assert(ret == 0);
739*062a843bSAndroid Build Coastguard Worker 
740*062a843bSAndroid Build Coastguard Worker         // acquire wrlock
741*062a843bSAndroid Build Coastguard Worker         ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
742*062a843bSAndroid Build Coastguard Worker         assert(ret == 0);
743*062a843bSAndroid Build Coastguard Worker 
744*062a843bSAndroid Build Coastguard Worker         // make sure the counter value has not changed
745*062a843bSAndroid Build Coastguard Worker         if (counter == mCounterRadio[slotId]) {
746*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->mRadioResponse = NULL;
747*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->mRadioIndication = NULL;
748*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->mRadioResponseV1_1 = NULL;
749*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->mRadioIndicationV1_1 = NULL;
750*062a843bSAndroid Build Coastguard Worker             mCounterRadio[slotId]++;
751*062a843bSAndroid Build Coastguard Worker         } else {
752*062a843bSAndroid Build Coastguard Worker             RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
753*062a843bSAndroid Build Coastguard Worker                     "got updated on another thread");
754*062a843bSAndroid Build Coastguard Worker         }
755*062a843bSAndroid Build Coastguard Worker 
756*062a843bSAndroid Build Coastguard Worker         // release wrlock
757*062a843bSAndroid Build Coastguard Worker         ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
758*062a843bSAndroid Build Coastguard Worker         assert(ret == 0);
759*062a843bSAndroid Build Coastguard Worker 
760*062a843bSAndroid Build Coastguard Worker         // Reacquire rdlock
761*062a843bSAndroid Build Coastguard Worker         ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
762*062a843bSAndroid Build Coastguard Worker         assert(ret == 0);
763*062a843bSAndroid Build Coastguard Worker     }
764*062a843bSAndroid Build Coastguard Worker }
765*062a843bSAndroid Build Coastguard Worker 
checkReturnStatus(Return<void> & ret)766*062a843bSAndroid Build Coastguard Worker void RadioImpl::checkReturnStatus(Return<void>& ret) {
767*062a843bSAndroid Build Coastguard Worker     ::checkReturnStatus(mSlotId, ret, true);
768*062a843bSAndroid Build Coastguard Worker }
769*062a843bSAndroid Build Coastguard Worker 
setResponseFunctions(const::android::sp<IRadioResponse> & radioResponseParam,const::android::sp<IRadioIndication> & radioIndicationParam)770*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setResponseFunctions(
771*062a843bSAndroid Build Coastguard Worker         const ::android::sp<IRadioResponse>& radioResponseParam,
772*062a843bSAndroid Build Coastguard Worker         const ::android::sp<IRadioIndication>& radioIndicationParam) {
773*062a843bSAndroid Build Coastguard Worker     RLOGD("setResponseFunctions");
774*062a843bSAndroid Build Coastguard Worker 
775*062a843bSAndroid Build Coastguard Worker     pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
776*062a843bSAndroid Build Coastguard Worker     int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
777*062a843bSAndroid Build Coastguard Worker     assert(ret == 0);
778*062a843bSAndroid Build Coastguard Worker 
779*062a843bSAndroid Build Coastguard Worker     mRadioResponse = radioResponseParam;
780*062a843bSAndroid Build Coastguard Worker     mRadioIndication = radioIndicationParam;
781*062a843bSAndroid Build Coastguard Worker     mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
782*062a843bSAndroid Build Coastguard Worker     mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
783*062a843bSAndroid Build Coastguard Worker     if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
784*062a843bSAndroid Build Coastguard Worker         mRadioResponseV1_1 = nullptr;
785*062a843bSAndroid Build Coastguard Worker         mRadioIndicationV1_1 = nullptr;
786*062a843bSAndroid Build Coastguard Worker     }
787*062a843bSAndroid Build Coastguard Worker 
788*062a843bSAndroid Build Coastguard Worker     mCounterRadio[mSlotId]++;
789*062a843bSAndroid Build Coastguard Worker 
790*062a843bSAndroid Build Coastguard Worker     ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
791*062a843bSAndroid Build Coastguard Worker     assert(ret == 0);
792*062a843bSAndroid Build Coastguard Worker 
793*062a843bSAndroid Build Coastguard Worker     // client is connected. Send initial indications.
794*062a843bSAndroid Build Coastguard Worker     android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
795*062a843bSAndroid Build Coastguard Worker 
796*062a843bSAndroid Build Coastguard Worker     return Void();
797*062a843bSAndroid Build Coastguard Worker }
798*062a843bSAndroid Build Coastguard Worker 
getIccCardStatus(int32_t serial)799*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
800*062a843bSAndroid Build Coastguard Worker #if VDBG
801*062a843bSAndroid Build Coastguard Worker     RLOGD("getIccCardStatus: serial %d", serial);
802*062a843bSAndroid Build Coastguard Worker #endif
803*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
804*062a843bSAndroid Build Coastguard Worker     return Void();
805*062a843bSAndroid Build Coastguard Worker }
806*062a843bSAndroid Build Coastguard Worker 
supplyIccPinForApp(int32_t serial,const hidl_string & pin,const hidl_string & aid)807*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
808*062a843bSAndroid Build Coastguard Worker         const hidl_string& aid) {
809*062a843bSAndroid Build Coastguard Worker #if VDBG
810*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPinForApp: serial %d", serial);
811*062a843bSAndroid Build Coastguard Worker #endif
812*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
813*062a843bSAndroid Build Coastguard Worker             2, pin.c_str(), aid.c_str());
814*062a843bSAndroid Build Coastguard Worker     return Void();
815*062a843bSAndroid Build Coastguard Worker }
816*062a843bSAndroid Build Coastguard Worker 
supplyIccPukForApp(int32_t serial,const hidl_string & puk,const hidl_string & pin,const hidl_string & aid)817*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
818*062a843bSAndroid Build Coastguard Worker                                            const hidl_string& pin, const hidl_string& aid) {
819*062a843bSAndroid Build Coastguard Worker #if VDBG
820*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPukForApp: serial %d", serial);
821*062a843bSAndroid Build Coastguard Worker #endif
822*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
823*062a843bSAndroid Build Coastguard Worker             3, puk.c_str(), pin.c_str(), aid.c_str());
824*062a843bSAndroid Build Coastguard Worker     return Void();
825*062a843bSAndroid Build Coastguard Worker }
826*062a843bSAndroid Build Coastguard Worker 
supplyIccPin2ForApp(int32_t serial,const hidl_string & pin2,const hidl_string & aid)827*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
828*062a843bSAndroid Build Coastguard Worker                                             const hidl_string& aid) {
829*062a843bSAndroid Build Coastguard Worker #if VDBG
830*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPin2ForApp: serial %d", serial);
831*062a843bSAndroid Build Coastguard Worker #endif
832*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
833*062a843bSAndroid Build Coastguard Worker             2, pin2.c_str(), aid.c_str());
834*062a843bSAndroid Build Coastguard Worker     return Void();
835*062a843bSAndroid Build Coastguard Worker }
836*062a843bSAndroid Build Coastguard Worker 
supplyIccPuk2ForApp(int32_t serial,const hidl_string & puk2,const hidl_string & pin2,const hidl_string & aid)837*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
838*062a843bSAndroid Build Coastguard Worker                                             const hidl_string& pin2, const hidl_string& aid) {
839*062a843bSAndroid Build Coastguard Worker #if VDBG
840*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPuk2ForApp: serial %d", serial);
841*062a843bSAndroid Build Coastguard Worker #endif
842*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
843*062a843bSAndroid Build Coastguard Worker             3, puk2.c_str(), pin2.c_str(), aid.c_str());
844*062a843bSAndroid Build Coastguard Worker     return Void();
845*062a843bSAndroid Build Coastguard Worker }
846*062a843bSAndroid Build Coastguard Worker 
changeIccPinForApp(int32_t serial,const hidl_string & oldPin,const hidl_string & newPin,const hidl_string & aid)847*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
848*062a843bSAndroid Build Coastguard Worker                                            const hidl_string& newPin, const hidl_string& aid) {
849*062a843bSAndroid Build Coastguard Worker #if VDBG
850*062a843bSAndroid Build Coastguard Worker     RLOGD("changeIccPinForApp: serial %d", serial);
851*062a843bSAndroid Build Coastguard Worker #endif
852*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
853*062a843bSAndroid Build Coastguard Worker             3, oldPin.c_str(), newPin.c_str(), aid.c_str());
854*062a843bSAndroid Build Coastguard Worker     return Void();
855*062a843bSAndroid Build Coastguard Worker }
856*062a843bSAndroid Build Coastguard Worker 
changeIccPin2ForApp(int32_t serial,const hidl_string & oldPin2,const hidl_string & newPin2,const hidl_string & aid)857*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
858*062a843bSAndroid Build Coastguard Worker                                             const hidl_string& newPin2, const hidl_string& aid) {
859*062a843bSAndroid Build Coastguard Worker #if VDBG
860*062a843bSAndroid Build Coastguard Worker     RLOGD("changeIccPin2ForApp: serial %d", serial);
861*062a843bSAndroid Build Coastguard Worker #endif
862*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
863*062a843bSAndroid Build Coastguard Worker             3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
864*062a843bSAndroid Build Coastguard Worker     return Void();
865*062a843bSAndroid Build Coastguard Worker }
866*062a843bSAndroid Build Coastguard Worker 
supplyNetworkDepersonalization(int32_t serial,const hidl_string & netPin)867*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
868*062a843bSAndroid Build Coastguard Worker                                                        const hidl_string& netPin) {
869*062a843bSAndroid Build Coastguard Worker #if VDBG
870*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyNetworkDepersonalization: serial %d", serial);
871*062a843bSAndroid Build Coastguard Worker #endif
872*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
873*062a843bSAndroid Build Coastguard Worker             1, netPin.c_str());
874*062a843bSAndroid Build Coastguard Worker     return Void();
875*062a843bSAndroid Build Coastguard Worker }
876*062a843bSAndroid Build Coastguard Worker 
getCurrentCalls(int32_t serial)877*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
878*062a843bSAndroid Build Coastguard Worker #if VDBG
879*062a843bSAndroid Build Coastguard Worker     RLOGD("getCurrentCalls: serial %d", serial);
880*062a843bSAndroid Build Coastguard Worker #endif
881*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
882*062a843bSAndroid Build Coastguard Worker     return Void();
883*062a843bSAndroid Build Coastguard Worker }
884*062a843bSAndroid Build Coastguard Worker 
dial(int32_t serial,const Dial & dialInfo)885*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
886*062a843bSAndroid Build Coastguard Worker #if VDBG
887*062a843bSAndroid Build Coastguard Worker     RLOGD("dial: serial %d", serial);
888*062a843bSAndroid Build Coastguard Worker #endif
889*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
890*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
891*062a843bSAndroid Build Coastguard Worker         return Void();
892*062a843bSAndroid Build Coastguard Worker     }
893*062a843bSAndroid Build Coastguard Worker     RIL_Dial dial = {};
894*062a843bSAndroid Build Coastguard Worker     RIL_UUS_Info uusInfo = {};
895*062a843bSAndroid Build Coastguard Worker     int32_t sizeOfDial = sizeof(dial);
896*062a843bSAndroid Build Coastguard Worker 
897*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
898*062a843bSAndroid Build Coastguard Worker         return Void();
899*062a843bSAndroid Build Coastguard Worker     }
900*062a843bSAndroid Build Coastguard Worker     dial.clir = (int) dialInfo.clir;
901*062a843bSAndroid Build Coastguard Worker 
902*062a843bSAndroid Build Coastguard Worker     if (dialInfo.uusInfo.size() != 0) {
903*062a843bSAndroid Build Coastguard Worker         uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
904*062a843bSAndroid Build Coastguard Worker         uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
905*062a843bSAndroid Build Coastguard Worker 
906*062a843bSAndroid Build Coastguard Worker         if (dialInfo.uusInfo[0].uusData.size() == 0) {
907*062a843bSAndroid Build Coastguard Worker             uusInfo.uusData = NULL;
908*062a843bSAndroid Build Coastguard Worker             uusInfo.uusLength = 0;
909*062a843bSAndroid Build Coastguard Worker         } else {
910*062a843bSAndroid Build Coastguard Worker             if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
911*062a843bSAndroid Build Coastguard Worker                 memsetAndFreeStrings(1, dial.address);
912*062a843bSAndroid Build Coastguard Worker                 return Void();
913*062a843bSAndroid Build Coastguard Worker             }
914*062a843bSAndroid Build Coastguard Worker             uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
915*062a843bSAndroid Build Coastguard Worker         }
916*062a843bSAndroid Build Coastguard Worker 
917*062a843bSAndroid Build Coastguard Worker         dial.uusInfo = &uusInfo;
918*062a843bSAndroid Build Coastguard Worker     }
919*062a843bSAndroid Build Coastguard Worker 
920*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
921*062a843bSAndroid Build Coastguard Worker 
922*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
923*062a843bSAndroid Build Coastguard Worker 
924*062a843bSAndroid Build Coastguard Worker     return Void();
925*062a843bSAndroid Build Coastguard Worker }
926*062a843bSAndroid Build Coastguard Worker 
getImsiForApp(int32_t serial,const hidl_string & aid)927*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
928*062a843bSAndroid Build Coastguard Worker #if VDBG
929*062a843bSAndroid Build Coastguard Worker     RLOGD("getImsiForApp: serial %d", serial);
930*062a843bSAndroid Build Coastguard Worker #endif
931*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
932*062a843bSAndroid Build Coastguard Worker             1, aid.c_str());
933*062a843bSAndroid Build Coastguard Worker     return Void();
934*062a843bSAndroid Build Coastguard Worker }
935*062a843bSAndroid Build Coastguard Worker 
hangup(int32_t serial,int32_t gsmIndex)936*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
937*062a843bSAndroid Build Coastguard Worker #if VDBG
938*062a843bSAndroid Build Coastguard Worker     RLOGD("hangup: serial %d", serial);
939*062a843bSAndroid Build Coastguard Worker #endif
940*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
941*062a843bSAndroid Build Coastguard Worker     return Void();
942*062a843bSAndroid Build Coastguard Worker }
943*062a843bSAndroid Build Coastguard Worker 
hangupWaitingOrBackground(int32_t serial)944*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
945*062a843bSAndroid Build Coastguard Worker #if VDBG
946*062a843bSAndroid Build Coastguard Worker     RLOGD("hangupWaitingOrBackground: serial %d", serial);
947*062a843bSAndroid Build Coastguard Worker #endif
948*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
949*062a843bSAndroid Build Coastguard Worker     return Void();
950*062a843bSAndroid Build Coastguard Worker }
951*062a843bSAndroid Build Coastguard Worker 
hangupForegroundResumeBackground(int32_t serial)952*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
953*062a843bSAndroid Build Coastguard Worker #if VDBG
954*062a843bSAndroid Build Coastguard Worker     RLOGD("hangupForegroundResumeBackground: serial %d", serial);
955*062a843bSAndroid Build Coastguard Worker #endif
956*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
957*062a843bSAndroid Build Coastguard Worker     return Void();
958*062a843bSAndroid Build Coastguard Worker }
959*062a843bSAndroid Build Coastguard Worker 
switchWaitingOrHoldingAndActive(int32_t serial)960*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
961*062a843bSAndroid Build Coastguard Worker #if VDBG
962*062a843bSAndroid Build Coastguard Worker     RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
963*062a843bSAndroid Build Coastguard Worker #endif
964*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
965*062a843bSAndroid Build Coastguard Worker     return Void();
966*062a843bSAndroid Build Coastguard Worker }
967*062a843bSAndroid Build Coastguard Worker 
conference(int32_t serial)968*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::conference(int32_t serial) {
969*062a843bSAndroid Build Coastguard Worker #if VDBG
970*062a843bSAndroid Build Coastguard Worker     RLOGD("conference: serial %d", serial);
971*062a843bSAndroid Build Coastguard Worker #endif
972*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
973*062a843bSAndroid Build Coastguard Worker     return Void();
974*062a843bSAndroid Build Coastguard Worker }
975*062a843bSAndroid Build Coastguard Worker 
rejectCall(int32_t serial)976*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::rejectCall(int32_t serial) {
977*062a843bSAndroid Build Coastguard Worker #if VDBG
978*062a843bSAndroid Build Coastguard Worker     RLOGD("rejectCall: serial %d", serial);
979*062a843bSAndroid Build Coastguard Worker #endif
980*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
981*062a843bSAndroid Build Coastguard Worker     return Void();
982*062a843bSAndroid Build Coastguard Worker }
983*062a843bSAndroid Build Coastguard Worker 
getLastCallFailCause(int32_t serial)984*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
985*062a843bSAndroid Build Coastguard Worker #if VDBG
986*062a843bSAndroid Build Coastguard Worker     RLOGD("getLastCallFailCause: serial %d", serial);
987*062a843bSAndroid Build Coastguard Worker #endif
988*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
989*062a843bSAndroid Build Coastguard Worker     return Void();
990*062a843bSAndroid Build Coastguard Worker }
991*062a843bSAndroid Build Coastguard Worker 
getSignalStrength(int32_t serial)992*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getSignalStrength(int32_t serial) {
993*062a843bSAndroid Build Coastguard Worker #if VDBG
994*062a843bSAndroid Build Coastguard Worker     RLOGD("getSignalStrength: serial %d", serial);
995*062a843bSAndroid Build Coastguard Worker #endif
996*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
997*062a843bSAndroid Build Coastguard Worker     return Void();
998*062a843bSAndroid Build Coastguard Worker }
999*062a843bSAndroid Build Coastguard Worker 
getVoiceRegistrationState(int32_t serial)1000*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
1001*062a843bSAndroid Build Coastguard Worker #if VDBG
1002*062a843bSAndroid Build Coastguard Worker     RLOGD("getVoiceRegistrationState: serial %d", serial);
1003*062a843bSAndroid Build Coastguard Worker #endif
1004*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1005*062a843bSAndroid Build Coastguard Worker     return Void();
1006*062a843bSAndroid Build Coastguard Worker }
1007*062a843bSAndroid Build Coastguard Worker 
getDataRegistrationState(int32_t serial)1008*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
1009*062a843bSAndroid Build Coastguard Worker #if VDBG
1010*062a843bSAndroid Build Coastguard Worker     RLOGD("getDataRegistrationState: serial %d", serial);
1011*062a843bSAndroid Build Coastguard Worker #endif
1012*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1013*062a843bSAndroid Build Coastguard Worker     return Void();
1014*062a843bSAndroid Build Coastguard Worker }
1015*062a843bSAndroid Build Coastguard Worker 
getOperator(int32_t serial)1016*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getOperator(int32_t serial) {
1017*062a843bSAndroid Build Coastguard Worker #if VDBG
1018*062a843bSAndroid Build Coastguard Worker     RLOGD("getOperator: serial %d", serial);
1019*062a843bSAndroid Build Coastguard Worker #endif
1020*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1021*062a843bSAndroid Build Coastguard Worker     return Void();
1022*062a843bSAndroid Build Coastguard Worker }
1023*062a843bSAndroid Build Coastguard Worker 
setRadioPower(int32_t serial,bool on)1024*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1025*062a843bSAndroid Build Coastguard Worker     RLOGD("setRadioPower: serial %d on %d", serial, on);
1026*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1027*062a843bSAndroid Build Coastguard Worker     return Void();
1028*062a843bSAndroid Build Coastguard Worker }
1029*062a843bSAndroid Build Coastguard Worker 
sendDtmf(int32_t serial,const hidl_string & s)1030*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1031*062a843bSAndroid Build Coastguard Worker #if VDBG
1032*062a843bSAndroid Build Coastguard Worker     RLOGD("sendDtmf: serial %d", serial);
1033*062a843bSAndroid Build Coastguard Worker #endif
1034*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1035*062a843bSAndroid Build Coastguard Worker     return Void();
1036*062a843bSAndroid Build Coastguard Worker }
1037*062a843bSAndroid Build Coastguard Worker 
sendSms(int32_t serial,const GsmSmsMessage & message)1038*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1039*062a843bSAndroid Build Coastguard Worker #if VDBG
1040*062a843bSAndroid Build Coastguard Worker     RLOGD("sendSms: serial %d", serial);
1041*062a843bSAndroid Build Coastguard Worker #endif
1042*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1043*062a843bSAndroid Build Coastguard Worker             2, message.smscPdu.c_str(), message.pdu.c_str());
1044*062a843bSAndroid Build Coastguard Worker     return Void();
1045*062a843bSAndroid Build Coastguard Worker }
1046*062a843bSAndroid Build Coastguard Worker 
sendSMSExpectMore(int32_t serial,const GsmSmsMessage & message)1047*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1048*062a843bSAndroid Build Coastguard Worker #if VDBG
1049*062a843bSAndroid Build Coastguard Worker     RLOGD("sendSMSExpectMore: serial %d", serial);
1050*062a843bSAndroid Build Coastguard Worker #endif
1051*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1052*062a843bSAndroid Build Coastguard Worker             2, message.smscPdu.c_str(), message.pdu.c_str());
1053*062a843bSAndroid Build Coastguard Worker     return Void();
1054*062a843bSAndroid Build Coastguard Worker }
1055*062a843bSAndroid Build Coastguard Worker 
convertMvnoTypeToString(MvnoType type,char * & str)1056*062a843bSAndroid Build Coastguard Worker static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1057*062a843bSAndroid Build Coastguard Worker     switch (type) {
1058*062a843bSAndroid Build Coastguard Worker         case MvnoType::IMSI:
1059*062a843bSAndroid Build Coastguard Worker             str = (char *)"imsi";
1060*062a843bSAndroid Build Coastguard Worker             return true;
1061*062a843bSAndroid Build Coastguard Worker         case MvnoType::GID:
1062*062a843bSAndroid Build Coastguard Worker             str = (char *)"gid";
1063*062a843bSAndroid Build Coastguard Worker             return true;
1064*062a843bSAndroid Build Coastguard Worker         case MvnoType::SPN:
1065*062a843bSAndroid Build Coastguard Worker             str = (char *)"spn";
1066*062a843bSAndroid Build Coastguard Worker             return true;
1067*062a843bSAndroid Build Coastguard Worker         case MvnoType::NONE:
1068*062a843bSAndroid Build Coastguard Worker             str = (char *)"";
1069*062a843bSAndroid Build Coastguard Worker             return true;
1070*062a843bSAndroid Build Coastguard Worker     }
1071*062a843bSAndroid Build Coastguard Worker     return false;
1072*062a843bSAndroid Build Coastguard Worker }
1073*062a843bSAndroid Build Coastguard Worker 
setupDataCall(int32_t serial,RadioTechnology radioTechnology,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool roamingAllowed,bool isRoaming)1074*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1075*062a843bSAndroid Build Coastguard Worker                                       const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1076*062a843bSAndroid Build Coastguard Worker                                       bool roamingAllowed, bool isRoaming) {
1077*062a843bSAndroid Build Coastguard Worker 
1078*062a843bSAndroid Build Coastguard Worker #if VDBG
1079*062a843bSAndroid Build Coastguard Worker     RLOGD("setupDataCall: serial %d", serial);
1080*062a843bSAndroid Build Coastguard Worker #endif
1081*062a843bSAndroid Build Coastguard Worker 
1082*062a843bSAndroid Build Coastguard Worker     if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1083*062a843bSAndroid Build Coastguard Worker         const hidl_string &protocol =
1084*062a843bSAndroid Build Coastguard Worker                 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1085*062a843bSAndroid Build Coastguard Worker         dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1086*062a843bSAndroid Build Coastguard Worker             std::to_string((int) radioTechnology + 2).c_str(),
1087*062a843bSAndroid Build Coastguard Worker             std::to_string((int) dataProfileInfo.profileId).c_str(),
1088*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.apn.c_str(),
1089*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.user.c_str(),
1090*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.password.c_str(),
1091*062a843bSAndroid Build Coastguard Worker             std::to_string((int) dataProfileInfo.authType).c_str(),
1092*062a843bSAndroid Build Coastguard Worker             protocol.c_str());
1093*062a843bSAndroid Build Coastguard Worker     } else if (s_vendorFunctions->version >= 15) {
1094*062a843bSAndroid Build Coastguard Worker         char *mvnoTypeStr = NULL;
1095*062a843bSAndroid Build Coastguard Worker         if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1096*062a843bSAndroid Build Coastguard Worker             RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1097*062a843bSAndroid Build Coastguard Worker                     RIL_REQUEST_SETUP_DATA_CALL);
1098*062a843bSAndroid Build Coastguard Worker             if (pRI != NULL) {
1099*062a843bSAndroid Build Coastguard Worker                 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1100*062a843bSAndroid Build Coastguard Worker             }
1101*062a843bSAndroid Build Coastguard Worker             return Void();
1102*062a843bSAndroid Build Coastguard Worker         }
1103*062a843bSAndroid Build Coastguard Worker         dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1104*062a843bSAndroid Build Coastguard Worker             std::to_string((int) radioTechnology + 2).c_str(),
1105*062a843bSAndroid Build Coastguard Worker             std::to_string((int) dataProfileInfo.profileId).c_str(),
1106*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.apn.c_str(),
1107*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.user.c_str(),
1108*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.password.c_str(),
1109*062a843bSAndroid Build Coastguard Worker             std::to_string((int) dataProfileInfo.authType).c_str(),
1110*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.protocol.c_str(),
1111*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.roamingProtocol.c_str(),
1112*062a843bSAndroid Build Coastguard Worker             std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1113*062a843bSAndroid Build Coastguard Worker             std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1114*062a843bSAndroid Build Coastguard Worker             modemCognitive ? "1" : "0",
1115*062a843bSAndroid Build Coastguard Worker             std::to_string(dataProfileInfo.mtu).c_str(),
1116*062a843bSAndroid Build Coastguard Worker             mvnoTypeStr,
1117*062a843bSAndroid Build Coastguard Worker             dataProfileInfo.mvnoMatchData.c_str(),
1118*062a843bSAndroid Build Coastguard Worker             roamingAllowed ? "1" : "0");
1119*062a843bSAndroid Build Coastguard Worker     } else {
1120*062a843bSAndroid Build Coastguard Worker         RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1121*062a843bSAndroid Build Coastguard Worker         RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1122*062a843bSAndroid Build Coastguard Worker                 RIL_REQUEST_SETUP_DATA_CALL);
1123*062a843bSAndroid Build Coastguard Worker         if (pRI != NULL) {
1124*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1125*062a843bSAndroid Build Coastguard Worker         }
1126*062a843bSAndroid Build Coastguard Worker     }
1127*062a843bSAndroid Build Coastguard Worker     return Void();
1128*062a843bSAndroid Build Coastguard Worker }
1129*062a843bSAndroid Build Coastguard Worker 
iccIOForApp(int32_t serial,const IccIo & iccIo)1130*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1131*062a843bSAndroid Build Coastguard Worker #if VDBG
1132*062a843bSAndroid Build Coastguard Worker     RLOGD("iccIOForApp: serial %d", serial);
1133*062a843bSAndroid Build Coastguard Worker #endif
1134*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1135*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1136*062a843bSAndroid Build Coastguard Worker         return Void();
1137*062a843bSAndroid Build Coastguard Worker     }
1138*062a843bSAndroid Build Coastguard Worker 
1139*062a843bSAndroid Build Coastguard Worker     RIL_SIM_IO_v6 rilIccIo = {};
1140*062a843bSAndroid Build Coastguard Worker     rilIccIo.command = iccIo.command;
1141*062a843bSAndroid Build Coastguard Worker     rilIccIo.fileid = iccIo.fileId;
1142*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1143*062a843bSAndroid Build Coastguard Worker         return Void();
1144*062a843bSAndroid Build Coastguard Worker     }
1145*062a843bSAndroid Build Coastguard Worker 
1146*062a843bSAndroid Build Coastguard Worker     rilIccIo.p1 = iccIo.p1;
1147*062a843bSAndroid Build Coastguard Worker     rilIccIo.p2 = iccIo.p2;
1148*062a843bSAndroid Build Coastguard Worker     rilIccIo.p3 = iccIo.p3;
1149*062a843bSAndroid Build Coastguard Worker 
1150*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1151*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(1, rilIccIo.path);
1152*062a843bSAndroid Build Coastguard Worker         return Void();
1153*062a843bSAndroid Build Coastguard Worker     }
1154*062a843bSAndroid Build Coastguard Worker 
1155*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1156*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1157*062a843bSAndroid Build Coastguard Worker         return Void();
1158*062a843bSAndroid Build Coastguard Worker     }
1159*062a843bSAndroid Build Coastguard Worker 
1160*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1161*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1162*062a843bSAndroid Build Coastguard Worker         return Void();
1163*062a843bSAndroid Build Coastguard Worker     }
1164*062a843bSAndroid Build Coastguard Worker 
1165*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1166*062a843bSAndroid Build Coastguard Worker 
1167*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1168*062a843bSAndroid Build Coastguard Worker 
1169*062a843bSAndroid Build Coastguard Worker     return Void();
1170*062a843bSAndroid Build Coastguard Worker }
1171*062a843bSAndroid Build Coastguard Worker 
sendUssd(int32_t serial,const hidl_string & ussd)1172*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1173*062a843bSAndroid Build Coastguard Worker #if VDBG
1174*062a843bSAndroid Build Coastguard Worker     RLOGD("sendUssd: serial %d", serial);
1175*062a843bSAndroid Build Coastguard Worker #endif
1176*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1177*062a843bSAndroid Build Coastguard Worker     return Void();
1178*062a843bSAndroid Build Coastguard Worker }
1179*062a843bSAndroid Build Coastguard Worker 
cancelPendingUssd(int32_t serial)1180*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1181*062a843bSAndroid Build Coastguard Worker #if VDBG
1182*062a843bSAndroid Build Coastguard Worker     RLOGD("cancelPendingUssd: serial %d", serial);
1183*062a843bSAndroid Build Coastguard Worker #endif
1184*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1185*062a843bSAndroid Build Coastguard Worker     return Void();
1186*062a843bSAndroid Build Coastguard Worker }
1187*062a843bSAndroid Build Coastguard Worker 
getClir(int32_t serial)1188*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getClir(int32_t serial) {
1189*062a843bSAndroid Build Coastguard Worker #if VDBG
1190*062a843bSAndroid Build Coastguard Worker     RLOGD("getClir: serial %d", serial);
1191*062a843bSAndroid Build Coastguard Worker #endif
1192*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1193*062a843bSAndroid Build Coastguard Worker     return Void();
1194*062a843bSAndroid Build Coastguard Worker }
1195*062a843bSAndroid Build Coastguard Worker 
setClir(int32_t serial,int32_t status)1196*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1197*062a843bSAndroid Build Coastguard Worker #if VDBG
1198*062a843bSAndroid Build Coastguard Worker     RLOGD("setClir: serial %d", serial);
1199*062a843bSAndroid Build Coastguard Worker #endif
1200*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1201*062a843bSAndroid Build Coastguard Worker     return Void();
1202*062a843bSAndroid Build Coastguard Worker }
1203*062a843bSAndroid Build Coastguard Worker 
getCallForwardStatus(int32_t serial,const CallForwardInfo & callInfo)1204*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1205*062a843bSAndroid Build Coastguard Worker #if VDBG
1206*062a843bSAndroid Build Coastguard Worker     RLOGD("getCallForwardStatus: serial %d", serial);
1207*062a843bSAndroid Build Coastguard Worker #endif
1208*062a843bSAndroid Build Coastguard Worker     dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1209*062a843bSAndroid Build Coastguard Worker             callInfo);
1210*062a843bSAndroid Build Coastguard Worker     return Void();
1211*062a843bSAndroid Build Coastguard Worker }
1212*062a843bSAndroid Build Coastguard Worker 
setCallForward(int32_t serial,const CallForwardInfo & callInfo)1213*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1214*062a843bSAndroid Build Coastguard Worker #if VDBG
1215*062a843bSAndroid Build Coastguard Worker     RLOGD("setCallForward: serial %d", serial);
1216*062a843bSAndroid Build Coastguard Worker #endif
1217*062a843bSAndroid Build Coastguard Worker     dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1218*062a843bSAndroid Build Coastguard Worker             callInfo);
1219*062a843bSAndroid Build Coastguard Worker     return Void();
1220*062a843bSAndroid Build Coastguard Worker }
1221*062a843bSAndroid Build Coastguard Worker 
getCallWaiting(int32_t serial,int32_t serviceClass)1222*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1223*062a843bSAndroid Build Coastguard Worker #if VDBG
1224*062a843bSAndroid Build Coastguard Worker     RLOGD("getCallWaiting: serial %d", serial);
1225*062a843bSAndroid Build Coastguard Worker #endif
1226*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1227*062a843bSAndroid Build Coastguard Worker     return Void();
1228*062a843bSAndroid Build Coastguard Worker }
1229*062a843bSAndroid Build Coastguard Worker 
setCallWaiting(int32_t serial,bool enable,int32_t serviceClass)1230*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1231*062a843bSAndroid Build Coastguard Worker #if VDBG
1232*062a843bSAndroid Build Coastguard Worker     RLOGD("setCallWaiting: serial %d", serial);
1233*062a843bSAndroid Build Coastguard Worker #endif
1234*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1235*062a843bSAndroid Build Coastguard Worker             serviceClass);
1236*062a843bSAndroid Build Coastguard Worker     return Void();
1237*062a843bSAndroid Build Coastguard Worker }
1238*062a843bSAndroid Build Coastguard Worker 
acknowledgeLastIncomingGsmSms(int32_t serial,bool success,SmsAcknowledgeFailCause cause)1239*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1240*062a843bSAndroid Build Coastguard Worker                                                       bool success, SmsAcknowledgeFailCause cause) {
1241*062a843bSAndroid Build Coastguard Worker #if VDBG
1242*062a843bSAndroid Build Coastguard Worker     RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1243*062a843bSAndroid Build Coastguard Worker #endif
1244*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1245*062a843bSAndroid Build Coastguard Worker             cause);
1246*062a843bSAndroid Build Coastguard Worker     return Void();
1247*062a843bSAndroid Build Coastguard Worker }
1248*062a843bSAndroid Build Coastguard Worker 
acceptCall(int32_t serial)1249*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::acceptCall(int32_t serial) {
1250*062a843bSAndroid Build Coastguard Worker #if VDBG
1251*062a843bSAndroid Build Coastguard Worker     RLOGD("acceptCall: serial %d", serial);
1252*062a843bSAndroid Build Coastguard Worker #endif
1253*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1254*062a843bSAndroid Build Coastguard Worker     return Void();
1255*062a843bSAndroid Build Coastguard Worker }
1256*062a843bSAndroid Build Coastguard Worker 
deactivateDataCall(int32_t serial,int32_t cid,bool reasonRadioShutDown)1257*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1258*062a843bSAndroid Build Coastguard Worker                                            int32_t cid, bool reasonRadioShutDown) {
1259*062a843bSAndroid Build Coastguard Worker #if VDBG
1260*062a843bSAndroid Build Coastguard Worker     RLOGD("deactivateDataCall: serial %d", serial);
1261*062a843bSAndroid Build Coastguard Worker #endif
1262*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1263*062a843bSAndroid Build Coastguard Worker             2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1264*062a843bSAndroid Build Coastguard Worker     return Void();
1265*062a843bSAndroid Build Coastguard Worker }
1266*062a843bSAndroid Build Coastguard Worker 
getFacilityLockForApp(int32_t serial,const hidl_string & facility,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1267*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1268*062a843bSAndroid Build Coastguard Worker                                               const hidl_string& password, int32_t serviceClass,
1269*062a843bSAndroid Build Coastguard Worker                                               const hidl_string& appId) {
1270*062a843bSAndroid Build Coastguard Worker #if VDBG
1271*062a843bSAndroid Build Coastguard Worker     RLOGD("getFacilityLockForApp: serial %d", serial);
1272*062a843bSAndroid Build Coastguard Worker #endif
1273*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1274*062a843bSAndroid Build Coastguard Worker             4, facility.c_str(), password.c_str(),
1275*062a843bSAndroid Build Coastguard Worker             (std::to_string(serviceClass)).c_str(), appId.c_str());
1276*062a843bSAndroid Build Coastguard Worker     return Void();
1277*062a843bSAndroid Build Coastguard Worker }
1278*062a843bSAndroid Build Coastguard Worker 
setFacilityLockForApp(int32_t serial,const hidl_string & facility,bool lockState,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1279*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1280*062a843bSAndroid Build Coastguard Worker                                               bool lockState, const hidl_string& password,
1281*062a843bSAndroid Build Coastguard Worker                                               int32_t serviceClass, const hidl_string& appId) {
1282*062a843bSAndroid Build Coastguard Worker #if VDBG
1283*062a843bSAndroid Build Coastguard Worker     RLOGD("setFacilityLockForApp: serial %d", serial);
1284*062a843bSAndroid Build Coastguard Worker #endif
1285*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1286*062a843bSAndroid Build Coastguard Worker             5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1287*062a843bSAndroid Build Coastguard Worker             (std::to_string(serviceClass)).c_str(), appId.c_str() );
1288*062a843bSAndroid Build Coastguard Worker     return Void();
1289*062a843bSAndroid Build Coastguard Worker }
1290*062a843bSAndroid Build Coastguard Worker 
setBarringPassword(int32_t serial,const hidl_string & facility,const hidl_string & oldPassword,const hidl_string & newPassword)1291*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1292*062a843bSAndroid Build Coastguard Worker                                            const hidl_string& oldPassword,
1293*062a843bSAndroid Build Coastguard Worker                                            const hidl_string& newPassword) {
1294*062a843bSAndroid Build Coastguard Worker #if VDBG
1295*062a843bSAndroid Build Coastguard Worker     RLOGD("setBarringPassword: serial %d", serial);
1296*062a843bSAndroid Build Coastguard Worker #endif
1297*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1298*062a843bSAndroid Build Coastguard Worker             3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1299*062a843bSAndroid Build Coastguard Worker     return Void();
1300*062a843bSAndroid Build Coastguard Worker }
1301*062a843bSAndroid Build Coastguard Worker 
getNetworkSelectionMode(int32_t serial)1302*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1303*062a843bSAndroid Build Coastguard Worker #if VDBG
1304*062a843bSAndroid Build Coastguard Worker     RLOGD("getNetworkSelectionMode: serial %d", serial);
1305*062a843bSAndroid Build Coastguard Worker #endif
1306*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1307*062a843bSAndroid Build Coastguard Worker     return Void();
1308*062a843bSAndroid Build Coastguard Worker }
1309*062a843bSAndroid Build Coastguard Worker 
setNetworkSelectionModeAutomatic(int32_t serial)1310*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1311*062a843bSAndroid Build Coastguard Worker #if VDBG
1312*062a843bSAndroid Build Coastguard Worker     RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1313*062a843bSAndroid Build Coastguard Worker #endif
1314*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1315*062a843bSAndroid Build Coastguard Worker     return Void();
1316*062a843bSAndroid Build Coastguard Worker }
1317*062a843bSAndroid Build Coastguard Worker 
setNetworkSelectionModeManual(int32_t serial,const hidl_string & operatorNumeric)1318*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1319*062a843bSAndroid Build Coastguard Worker                                                       const hidl_string& operatorNumeric) {
1320*062a843bSAndroid Build Coastguard Worker #if VDBG
1321*062a843bSAndroid Build Coastguard Worker     RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1322*062a843bSAndroid Build Coastguard Worker #endif
1323*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1324*062a843bSAndroid Build Coastguard Worker             operatorNumeric.c_str());
1325*062a843bSAndroid Build Coastguard Worker     return Void();
1326*062a843bSAndroid Build Coastguard Worker }
1327*062a843bSAndroid Build Coastguard Worker 
getAvailableNetworks(int32_t serial)1328*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1329*062a843bSAndroid Build Coastguard Worker #if VDBG
1330*062a843bSAndroid Build Coastguard Worker     RLOGD("getAvailableNetworks: serial %d", serial);
1331*062a843bSAndroid Build Coastguard Worker #endif
1332*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1333*062a843bSAndroid Build Coastguard Worker     return Void();
1334*062a843bSAndroid Build Coastguard Worker }
1335*062a843bSAndroid Build Coastguard Worker 
startNetworkScan(int32_t serial,const V1_1::NetworkScanRequest & request)1336*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1337*062a843bSAndroid Build Coastguard Worker #if VDBG
1338*062a843bSAndroid Build Coastguard Worker     RLOGD("startNetworkScan: serial %d", serial);
1339*062a843bSAndroid Build Coastguard Worker #endif
1340*062a843bSAndroid Build Coastguard Worker 
1341*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1342*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1343*062a843bSAndroid Build Coastguard Worker         return Void();
1344*062a843bSAndroid Build Coastguard Worker     }
1345*062a843bSAndroid Build Coastguard Worker 
1346*062a843bSAndroid Build Coastguard Worker     if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1347*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1348*062a843bSAndroid Build Coastguard Worker         return Void();
1349*062a843bSAndroid Build Coastguard Worker     }
1350*062a843bSAndroid Build Coastguard Worker 
1351*062a843bSAndroid Build Coastguard Worker     RIL_NetworkScanRequest scan_request = {};
1352*062a843bSAndroid Build Coastguard Worker 
1353*062a843bSAndroid Build Coastguard Worker     scan_request.type = (RIL_ScanType) request.type;
1354*062a843bSAndroid Build Coastguard Worker     scan_request.interval = request.interval;
1355*062a843bSAndroid Build Coastguard Worker     scan_request.specifiers_length = request.specifiers.size();
1356*062a843bSAndroid Build Coastguard Worker     for (size_t i = 0; i < request.specifiers.size(); ++i) {
1357*062a843bSAndroid Build Coastguard Worker         if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1358*062a843bSAndroid Build Coastguard Worker             request.specifiers[i].utranBands.size() > MAX_BANDS ||
1359*062a843bSAndroid Build Coastguard Worker             request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1360*062a843bSAndroid Build Coastguard Worker             request.specifiers[i].channels.size() > MAX_CHANNELS) {
1361*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1362*062a843bSAndroid Build Coastguard Worker             return Void();
1363*062a843bSAndroid Build Coastguard Worker         }
1364*062a843bSAndroid Build Coastguard Worker         const V1_1::RadioAccessSpecifier& ras_from =
1365*062a843bSAndroid Build Coastguard Worker                 request.specifiers[i];
1366*062a843bSAndroid Build Coastguard Worker         RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1367*062a843bSAndroid Build Coastguard Worker 
1368*062a843bSAndroid Build Coastguard Worker         ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1369*062a843bSAndroid Build Coastguard Worker         ras_to.channels_length = ras_from.channels.size();
1370*062a843bSAndroid Build Coastguard Worker 
1371*062a843bSAndroid Build Coastguard Worker         std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1372*062a843bSAndroid Build Coastguard Worker         const std::vector<uint32_t> * bands = nullptr;
1373*062a843bSAndroid Build Coastguard Worker         switch (request.specifiers[i].radioAccessNetwork) {
1374*062a843bSAndroid Build Coastguard Worker             case V1_1::RadioAccessNetworks::GERAN:
1375*062a843bSAndroid Build Coastguard Worker                 ras_to.bands_length = ras_from.geranBands.size();
1376*062a843bSAndroid Build Coastguard Worker                 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1377*062a843bSAndroid Build Coastguard Worker                 break;
1378*062a843bSAndroid Build Coastguard Worker             case V1_1::RadioAccessNetworks::UTRAN:
1379*062a843bSAndroid Build Coastguard Worker                 ras_to.bands_length = ras_from.utranBands.size();
1380*062a843bSAndroid Build Coastguard Worker                 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1381*062a843bSAndroid Build Coastguard Worker                 break;
1382*062a843bSAndroid Build Coastguard Worker             case V1_1::RadioAccessNetworks::EUTRAN:
1383*062a843bSAndroid Build Coastguard Worker                 ras_to.bands_length = ras_from.eutranBands.size();
1384*062a843bSAndroid Build Coastguard Worker                 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1385*062a843bSAndroid Build Coastguard Worker                 break;
1386*062a843bSAndroid Build Coastguard Worker             default:
1387*062a843bSAndroid Build Coastguard Worker                 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1388*062a843bSAndroid Build Coastguard Worker                 return Void();
1389*062a843bSAndroid Build Coastguard Worker         }
1390*062a843bSAndroid Build Coastguard Worker         // safe to copy to geran_bands because it's a union member
1391*062a843bSAndroid Build Coastguard Worker         for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1392*062a843bSAndroid Build Coastguard Worker             ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1393*062a843bSAndroid Build Coastguard Worker         }
1394*062a843bSAndroid Build Coastguard Worker     }
1395*062a843bSAndroid Build Coastguard Worker 
1396*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1397*062a843bSAndroid Build Coastguard Worker             mSlotId);
1398*062a843bSAndroid Build Coastguard Worker 
1399*062a843bSAndroid Build Coastguard Worker     return Void();
1400*062a843bSAndroid Build Coastguard Worker }
1401*062a843bSAndroid Build Coastguard Worker 
stopNetworkScan(int32_t serial)1402*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1403*062a843bSAndroid Build Coastguard Worker #if VDBG
1404*062a843bSAndroid Build Coastguard Worker     RLOGD("stopNetworkScan: serial %d", serial);
1405*062a843bSAndroid Build Coastguard Worker #endif
1406*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1407*062a843bSAndroid Build Coastguard Worker     return Void();
1408*062a843bSAndroid Build Coastguard Worker }
1409*062a843bSAndroid Build Coastguard Worker 
startDtmf(int32_t serial,const hidl_string & s)1410*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1411*062a843bSAndroid Build Coastguard Worker #if VDBG
1412*062a843bSAndroid Build Coastguard Worker     RLOGD("startDtmf: serial %d", serial);
1413*062a843bSAndroid Build Coastguard Worker #endif
1414*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1415*062a843bSAndroid Build Coastguard Worker             s.c_str());
1416*062a843bSAndroid Build Coastguard Worker     return Void();
1417*062a843bSAndroid Build Coastguard Worker }
1418*062a843bSAndroid Build Coastguard Worker 
stopDtmf(int32_t serial)1419*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::stopDtmf(int32_t serial) {
1420*062a843bSAndroid Build Coastguard Worker #if VDBG
1421*062a843bSAndroid Build Coastguard Worker     RLOGD("stopDtmf: serial %d", serial);
1422*062a843bSAndroid Build Coastguard Worker #endif
1423*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1424*062a843bSAndroid Build Coastguard Worker     return Void();
1425*062a843bSAndroid Build Coastguard Worker }
1426*062a843bSAndroid Build Coastguard Worker 
getBasebandVersion(int32_t serial)1427*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1428*062a843bSAndroid Build Coastguard Worker #if VDBG
1429*062a843bSAndroid Build Coastguard Worker     RLOGD("getBasebandVersion: serial %d", serial);
1430*062a843bSAndroid Build Coastguard Worker #endif
1431*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1432*062a843bSAndroid Build Coastguard Worker     return Void();
1433*062a843bSAndroid Build Coastguard Worker }
1434*062a843bSAndroid Build Coastguard Worker 
separateConnection(int32_t serial,int32_t gsmIndex)1435*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1436*062a843bSAndroid Build Coastguard Worker #if VDBG
1437*062a843bSAndroid Build Coastguard Worker     RLOGD("separateConnection: serial %d", serial);
1438*062a843bSAndroid Build Coastguard Worker #endif
1439*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1440*062a843bSAndroid Build Coastguard Worker     return Void();
1441*062a843bSAndroid Build Coastguard Worker }
1442*062a843bSAndroid Build Coastguard Worker 
setMute(int32_t serial,bool enable)1443*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1444*062a843bSAndroid Build Coastguard Worker #if VDBG
1445*062a843bSAndroid Build Coastguard Worker     RLOGD("setMute: serial %d", serial);
1446*062a843bSAndroid Build Coastguard Worker #endif
1447*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1448*062a843bSAndroid Build Coastguard Worker     return Void();
1449*062a843bSAndroid Build Coastguard Worker }
1450*062a843bSAndroid Build Coastguard Worker 
getMute(int32_t serial)1451*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getMute(int32_t serial) {
1452*062a843bSAndroid Build Coastguard Worker #if VDBG
1453*062a843bSAndroid Build Coastguard Worker     RLOGD("getMute: serial %d", serial);
1454*062a843bSAndroid Build Coastguard Worker #endif
1455*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1456*062a843bSAndroid Build Coastguard Worker     return Void();
1457*062a843bSAndroid Build Coastguard Worker }
1458*062a843bSAndroid Build Coastguard Worker 
getClip(int32_t serial)1459*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getClip(int32_t serial) {
1460*062a843bSAndroid Build Coastguard Worker #if VDBG
1461*062a843bSAndroid Build Coastguard Worker     RLOGD("getClip: serial %d", serial);
1462*062a843bSAndroid Build Coastguard Worker #endif
1463*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1464*062a843bSAndroid Build Coastguard Worker     return Void();
1465*062a843bSAndroid Build Coastguard Worker }
1466*062a843bSAndroid Build Coastguard Worker 
getDataCallList(int32_t serial)1467*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getDataCallList(int32_t serial) {
1468*062a843bSAndroid Build Coastguard Worker #if VDBG
1469*062a843bSAndroid Build Coastguard Worker     RLOGD("getDataCallList: serial %d", serial);
1470*062a843bSAndroid Build Coastguard Worker #endif
1471*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1472*062a843bSAndroid Build Coastguard Worker     return Void();
1473*062a843bSAndroid Build Coastguard Worker }
1474*062a843bSAndroid Build Coastguard Worker 
setSuppServiceNotifications(int32_t serial,bool enable)1475*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1476*062a843bSAndroid Build Coastguard Worker #if VDBG
1477*062a843bSAndroid Build Coastguard Worker     RLOGD("setSuppServiceNotifications: serial %d", serial);
1478*062a843bSAndroid Build Coastguard Worker #endif
1479*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1480*062a843bSAndroid Build Coastguard Worker             BOOL_TO_INT(enable));
1481*062a843bSAndroid Build Coastguard Worker     return Void();
1482*062a843bSAndroid Build Coastguard Worker }
1483*062a843bSAndroid Build Coastguard Worker 
writeSmsToSim(int32_t serial,const SmsWriteArgs & smsWriteArgs)1484*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1485*062a843bSAndroid Build Coastguard Worker #if VDBG
1486*062a843bSAndroid Build Coastguard Worker     RLOGD("writeSmsToSim: serial %d", serial);
1487*062a843bSAndroid Build Coastguard Worker #endif
1488*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1489*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1490*062a843bSAndroid Build Coastguard Worker         return Void();
1491*062a843bSAndroid Build Coastguard Worker     }
1492*062a843bSAndroid Build Coastguard Worker 
1493*062a843bSAndroid Build Coastguard Worker     RIL_SMS_WriteArgs args;
1494*062a843bSAndroid Build Coastguard Worker     args.status = (int) smsWriteArgs.status;
1495*062a843bSAndroid Build Coastguard Worker 
1496*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1497*062a843bSAndroid Build Coastguard Worker         return Void();
1498*062a843bSAndroid Build Coastguard Worker     }
1499*062a843bSAndroid Build Coastguard Worker 
1500*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1501*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(1, args.pdu);
1502*062a843bSAndroid Build Coastguard Worker         return Void();
1503*062a843bSAndroid Build Coastguard Worker     }
1504*062a843bSAndroid Build Coastguard Worker 
1505*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1506*062a843bSAndroid Build Coastguard Worker 
1507*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(2, args.smsc, args.pdu);
1508*062a843bSAndroid Build Coastguard Worker 
1509*062a843bSAndroid Build Coastguard Worker     return Void();
1510*062a843bSAndroid Build Coastguard Worker }
1511*062a843bSAndroid Build Coastguard Worker 
deleteSmsOnSim(int32_t serial,int32_t index)1512*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1513*062a843bSAndroid Build Coastguard Worker #if VDBG
1514*062a843bSAndroid Build Coastguard Worker     RLOGD("deleteSmsOnSim: serial %d", serial);
1515*062a843bSAndroid Build Coastguard Worker #endif
1516*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1517*062a843bSAndroid Build Coastguard Worker     return Void();
1518*062a843bSAndroid Build Coastguard Worker }
1519*062a843bSAndroid Build Coastguard Worker 
setBandMode(int32_t serial,RadioBandMode mode)1520*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1521*062a843bSAndroid Build Coastguard Worker #if VDBG
1522*062a843bSAndroid Build Coastguard Worker     RLOGD("setBandMode: serial %d", serial);
1523*062a843bSAndroid Build Coastguard Worker #endif
1524*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1525*062a843bSAndroid Build Coastguard Worker     return Void();
1526*062a843bSAndroid Build Coastguard Worker }
1527*062a843bSAndroid Build Coastguard Worker 
getAvailableBandModes(int32_t serial)1528*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1529*062a843bSAndroid Build Coastguard Worker #if VDBG
1530*062a843bSAndroid Build Coastguard Worker     RLOGD("getAvailableBandModes: serial %d", serial);
1531*062a843bSAndroid Build Coastguard Worker #endif
1532*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1533*062a843bSAndroid Build Coastguard Worker     return Void();
1534*062a843bSAndroid Build Coastguard Worker }
1535*062a843bSAndroid Build Coastguard Worker 
sendEnvelope(int32_t serial,const hidl_string & command)1536*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1537*062a843bSAndroid Build Coastguard Worker #if VDBG
1538*062a843bSAndroid Build Coastguard Worker     RLOGD("sendEnvelope: serial %d", serial);
1539*062a843bSAndroid Build Coastguard Worker #endif
1540*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1541*062a843bSAndroid Build Coastguard Worker             command.c_str());
1542*062a843bSAndroid Build Coastguard Worker     return Void();
1543*062a843bSAndroid Build Coastguard Worker }
1544*062a843bSAndroid Build Coastguard Worker 
sendTerminalResponseToSim(int32_t serial,const hidl_string & commandResponse)1545*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1546*062a843bSAndroid Build Coastguard Worker                                                   const hidl_string& commandResponse) {
1547*062a843bSAndroid Build Coastguard Worker #if VDBG
1548*062a843bSAndroid Build Coastguard Worker     RLOGD("sendTerminalResponseToSim: serial %d", serial);
1549*062a843bSAndroid Build Coastguard Worker #endif
1550*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1551*062a843bSAndroid Build Coastguard Worker             commandResponse.c_str());
1552*062a843bSAndroid Build Coastguard Worker     return Void();
1553*062a843bSAndroid Build Coastguard Worker }
1554*062a843bSAndroid Build Coastguard Worker 
handleStkCallSetupRequestFromSim(int32_t serial,bool accept)1555*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1556*062a843bSAndroid Build Coastguard Worker #if VDBG
1557*062a843bSAndroid Build Coastguard Worker     RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1558*062a843bSAndroid Build Coastguard Worker #endif
1559*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1560*062a843bSAndroid Build Coastguard Worker             1, BOOL_TO_INT(accept));
1561*062a843bSAndroid Build Coastguard Worker     return Void();
1562*062a843bSAndroid Build Coastguard Worker }
1563*062a843bSAndroid Build Coastguard Worker 
explicitCallTransfer(int32_t serial)1564*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1565*062a843bSAndroid Build Coastguard Worker #if VDBG
1566*062a843bSAndroid Build Coastguard Worker     RLOGD("explicitCallTransfer: serial %d", serial);
1567*062a843bSAndroid Build Coastguard Worker #endif
1568*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1569*062a843bSAndroid Build Coastguard Worker     return Void();
1570*062a843bSAndroid Build Coastguard Worker }
1571*062a843bSAndroid Build Coastguard Worker 
setPreferredNetworkType(int32_t serial,PreferredNetworkType nwType)1572*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1573*062a843bSAndroid Build Coastguard Worker #if VDBG
1574*062a843bSAndroid Build Coastguard Worker     RLOGD("setPreferredNetworkType: serial %d", serial);
1575*062a843bSAndroid Build Coastguard Worker #endif
1576*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1577*062a843bSAndroid Build Coastguard Worker     return Void();
1578*062a843bSAndroid Build Coastguard Worker }
1579*062a843bSAndroid Build Coastguard Worker 
getPreferredNetworkType(int32_t serial)1580*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1581*062a843bSAndroid Build Coastguard Worker #if VDBG
1582*062a843bSAndroid Build Coastguard Worker     RLOGD("getPreferredNetworkType: serial %d", serial);
1583*062a843bSAndroid Build Coastguard Worker #endif
1584*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1585*062a843bSAndroid Build Coastguard Worker     return Void();
1586*062a843bSAndroid Build Coastguard Worker }
1587*062a843bSAndroid Build Coastguard Worker 
getNeighboringCids(int32_t serial)1588*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1589*062a843bSAndroid Build Coastguard Worker #if VDBG
1590*062a843bSAndroid Build Coastguard Worker     RLOGD("getNeighboringCids: serial %d", serial);
1591*062a843bSAndroid Build Coastguard Worker #endif
1592*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1593*062a843bSAndroid Build Coastguard Worker     return Void();
1594*062a843bSAndroid Build Coastguard Worker }
1595*062a843bSAndroid Build Coastguard Worker 
setLocationUpdates(int32_t serial,bool enable)1596*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1597*062a843bSAndroid Build Coastguard Worker #if VDBG
1598*062a843bSAndroid Build Coastguard Worker     RLOGD("setLocationUpdates: serial %d", serial);
1599*062a843bSAndroid Build Coastguard Worker #endif
1600*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1601*062a843bSAndroid Build Coastguard Worker     return Void();
1602*062a843bSAndroid Build Coastguard Worker }
1603*062a843bSAndroid Build Coastguard Worker 
setCdmaSubscriptionSource(int32_t serial,CdmaSubscriptionSource cdmaSub)1604*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1605*062a843bSAndroid Build Coastguard Worker #if VDBG
1606*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1607*062a843bSAndroid Build Coastguard Worker #endif
1608*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1609*062a843bSAndroid Build Coastguard Worker     return Void();
1610*062a843bSAndroid Build Coastguard Worker }
1611*062a843bSAndroid Build Coastguard Worker 
setCdmaRoamingPreference(int32_t serial,CdmaRoamingType type)1612*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1613*062a843bSAndroid Build Coastguard Worker #if VDBG
1614*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaRoamingPreference: serial %d", serial);
1615*062a843bSAndroid Build Coastguard Worker #endif
1616*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1617*062a843bSAndroid Build Coastguard Worker     return Void();
1618*062a843bSAndroid Build Coastguard Worker }
1619*062a843bSAndroid Build Coastguard Worker 
getCdmaRoamingPreference(int32_t serial)1620*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1621*062a843bSAndroid Build Coastguard Worker #if VDBG
1622*062a843bSAndroid Build Coastguard Worker     RLOGD("getCdmaRoamingPreference: serial %d", serial);
1623*062a843bSAndroid Build Coastguard Worker #endif
1624*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1625*062a843bSAndroid Build Coastguard Worker     return Void();
1626*062a843bSAndroid Build Coastguard Worker }
1627*062a843bSAndroid Build Coastguard Worker 
setTTYMode(int32_t serial,TtyMode mode)1628*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1629*062a843bSAndroid Build Coastguard Worker #if VDBG
1630*062a843bSAndroid Build Coastguard Worker     RLOGD("setTTYMode: serial %d", serial);
1631*062a843bSAndroid Build Coastguard Worker #endif
1632*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1633*062a843bSAndroid Build Coastguard Worker     return Void();
1634*062a843bSAndroid Build Coastguard Worker }
1635*062a843bSAndroid Build Coastguard Worker 
getTTYMode(int32_t serial)1636*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getTTYMode(int32_t serial) {
1637*062a843bSAndroid Build Coastguard Worker #if VDBG
1638*062a843bSAndroid Build Coastguard Worker     RLOGD("getTTYMode: serial %d", serial);
1639*062a843bSAndroid Build Coastguard Worker #endif
1640*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1641*062a843bSAndroid Build Coastguard Worker     return Void();
1642*062a843bSAndroid Build Coastguard Worker }
1643*062a843bSAndroid Build Coastguard Worker 
setPreferredVoicePrivacy(int32_t serial,bool enable)1644*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1645*062a843bSAndroid Build Coastguard Worker #if VDBG
1646*062a843bSAndroid Build Coastguard Worker     RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1647*062a843bSAndroid Build Coastguard Worker #endif
1648*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1649*062a843bSAndroid Build Coastguard Worker             1, BOOL_TO_INT(enable));
1650*062a843bSAndroid Build Coastguard Worker     return Void();
1651*062a843bSAndroid Build Coastguard Worker }
1652*062a843bSAndroid Build Coastguard Worker 
getPreferredVoicePrivacy(int32_t serial)1653*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1654*062a843bSAndroid Build Coastguard Worker #if VDBG
1655*062a843bSAndroid Build Coastguard Worker     RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1656*062a843bSAndroid Build Coastguard Worker #endif
1657*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1658*062a843bSAndroid Build Coastguard Worker     return Void();
1659*062a843bSAndroid Build Coastguard Worker }
1660*062a843bSAndroid Build Coastguard Worker 
sendCDMAFeatureCode(int32_t serial,const hidl_string & featureCode)1661*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1662*062a843bSAndroid Build Coastguard Worker #if VDBG
1663*062a843bSAndroid Build Coastguard Worker     RLOGD("sendCDMAFeatureCode: serial %d", serial);
1664*062a843bSAndroid Build Coastguard Worker #endif
1665*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1666*062a843bSAndroid Build Coastguard Worker             featureCode.c_str());
1667*062a843bSAndroid Build Coastguard Worker     return Void();
1668*062a843bSAndroid Build Coastguard Worker }
1669*062a843bSAndroid Build Coastguard Worker 
sendBurstDtmf(int32_t serial,const hidl_string & dtmf,int32_t on,int32_t off)1670*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1671*062a843bSAndroid Build Coastguard Worker                                       int32_t off) {
1672*062a843bSAndroid Build Coastguard Worker #if VDBG
1673*062a843bSAndroid Build Coastguard Worker     RLOGD("sendBurstDtmf: serial %d", serial);
1674*062a843bSAndroid Build Coastguard Worker #endif
1675*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
1676*062a843bSAndroid Build Coastguard Worker             3, dtmf.c_str(), (std::to_string(on)).c_str(),
1677*062a843bSAndroid Build Coastguard Worker             (std::to_string(off)).c_str());
1678*062a843bSAndroid Build Coastguard Worker     return Void();
1679*062a843bSAndroid Build Coastguard Worker }
1680*062a843bSAndroid Build Coastguard Worker 
constructCdmaSms(RIL_CDMA_SMS_Message & rcsm,const CdmaSmsMessage & sms)1681*062a843bSAndroid Build Coastguard Worker void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1682*062a843bSAndroid Build Coastguard Worker     rcsm.uTeleserviceID = sms.teleserviceId;
1683*062a843bSAndroid Build Coastguard Worker     rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1684*062a843bSAndroid Build Coastguard Worker     rcsm.uServicecategory = sms.serviceCategory;
1685*062a843bSAndroid Build Coastguard Worker     rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1686*062a843bSAndroid Build Coastguard Worker     rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1687*062a843bSAndroid Build Coastguard Worker     rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1688*062a843bSAndroid Build Coastguard Worker     rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1689*062a843bSAndroid Build Coastguard Worker 
1690*062a843bSAndroid Build Coastguard Worker     rcsm.sAddress.number_of_digits = sms.address.digits.size();
1691*062a843bSAndroid Build Coastguard Worker     int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1692*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < digitLimit; i++) {
1693*062a843bSAndroid Build Coastguard Worker         rcsm.sAddress.digits[i] = sms.address.digits[i];
1694*062a843bSAndroid Build Coastguard Worker     }
1695*062a843bSAndroid Build Coastguard Worker 
1696*062a843bSAndroid Build Coastguard Worker     rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1697*062a843bSAndroid Build Coastguard Worker     rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1698*062a843bSAndroid Build Coastguard Worker 
1699*062a843bSAndroid Build Coastguard Worker     rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1700*062a843bSAndroid Build Coastguard Worker     digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1701*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < digitLimit; i++) {
1702*062a843bSAndroid Build Coastguard Worker         rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1703*062a843bSAndroid Build Coastguard Worker     }
1704*062a843bSAndroid Build Coastguard Worker 
1705*062a843bSAndroid Build Coastguard Worker     rcsm.uBearerDataLen = sms.bearerData.size();
1706*062a843bSAndroid Build Coastguard Worker     digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1707*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < digitLimit; i++) {
1708*062a843bSAndroid Build Coastguard Worker         rcsm.aBearerData[i] = sms.bearerData[i];
1709*062a843bSAndroid Build Coastguard Worker     }
1710*062a843bSAndroid Build Coastguard Worker }
1711*062a843bSAndroid Build Coastguard Worker 
sendCdmaSms(int32_t serial,const CdmaSmsMessage & sms)1712*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1713*062a843bSAndroid Build Coastguard Worker #if VDBG
1714*062a843bSAndroid Build Coastguard Worker     RLOGD("sendCdmaSms: serial %d", serial);
1715*062a843bSAndroid Build Coastguard Worker #endif
1716*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1717*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1718*062a843bSAndroid Build Coastguard Worker         return Void();
1719*062a843bSAndroid Build Coastguard Worker     }
1720*062a843bSAndroid Build Coastguard Worker 
1721*062a843bSAndroid Build Coastguard Worker     RIL_CDMA_SMS_Message rcsm = {};
1722*062a843bSAndroid Build Coastguard Worker     constructCdmaSms(rcsm, sms);
1723*062a843bSAndroid Build Coastguard Worker 
1724*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1725*062a843bSAndroid Build Coastguard Worker     return Void();
1726*062a843bSAndroid Build Coastguard Worker }
1727*062a843bSAndroid Build Coastguard Worker 
acknowledgeLastIncomingCdmaSms(int32_t serial,const CdmaSmsAck & smsAck)1728*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1729*062a843bSAndroid Build Coastguard Worker #if VDBG
1730*062a843bSAndroid Build Coastguard Worker     RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1731*062a843bSAndroid Build Coastguard Worker #endif
1732*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1733*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1734*062a843bSAndroid Build Coastguard Worker         return Void();
1735*062a843bSAndroid Build Coastguard Worker     }
1736*062a843bSAndroid Build Coastguard Worker 
1737*062a843bSAndroid Build Coastguard Worker     RIL_CDMA_SMS_Ack rcsa = {};
1738*062a843bSAndroid Build Coastguard Worker 
1739*062a843bSAndroid Build Coastguard Worker     rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1740*062a843bSAndroid Build Coastguard Worker     rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1741*062a843bSAndroid Build Coastguard Worker 
1742*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1743*062a843bSAndroid Build Coastguard Worker     return Void();
1744*062a843bSAndroid Build Coastguard Worker }
1745*062a843bSAndroid Build Coastguard Worker 
getGsmBroadcastConfig(int32_t serial)1746*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1747*062a843bSAndroid Build Coastguard Worker #if VDBG
1748*062a843bSAndroid Build Coastguard Worker     RLOGD("getGsmBroadcastConfig: serial %d", serial);
1749*062a843bSAndroid Build Coastguard Worker #endif
1750*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1751*062a843bSAndroid Build Coastguard Worker     return Void();
1752*062a843bSAndroid Build Coastguard Worker }
1753*062a843bSAndroid Build Coastguard Worker 
setGsmBroadcastConfig(int32_t serial,const hidl_vec<GsmBroadcastSmsConfigInfo> & configInfo)1754*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1755*062a843bSAndroid Build Coastguard Worker                                               const hidl_vec<GsmBroadcastSmsConfigInfo>&
1756*062a843bSAndroid Build Coastguard Worker                                               configInfo) {
1757*062a843bSAndroid Build Coastguard Worker #if VDBG
1758*062a843bSAndroid Build Coastguard Worker     RLOGD("setGsmBroadcastConfig: serial %d", serial);
1759*062a843bSAndroid Build Coastguard Worker #endif
1760*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1761*062a843bSAndroid Build Coastguard Worker             RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1762*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1763*062a843bSAndroid Build Coastguard Worker         return Void();
1764*062a843bSAndroid Build Coastguard Worker     }
1765*062a843bSAndroid Build Coastguard Worker 
1766*062a843bSAndroid Build Coastguard Worker     uint32_t num = configInfo.size();
1767*062a843bSAndroid Build Coastguard Worker     if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
1768*062a843bSAndroid Build Coastguard Worker         RLOGE("setGsmBroadcastConfig: Invalid configInfo length %s",
1769*062a843bSAndroid Build Coastguard Worker                 requestToString(pRI->pCI->requestNumber));
1770*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1771*062a843bSAndroid Build Coastguard Worker         return Void();
1772*062a843bSAndroid Build Coastguard Worker     }
1773*062a843bSAndroid Build Coastguard Worker     auto gsmBci = new RIL_GSM_BroadcastSmsConfigInfo[num];
1774*062a843bSAndroid Build Coastguard Worker     if (gsmBci == nullptr) {
1775*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1776*062a843bSAndroid Build Coastguard Worker         return Void();
1777*062a843bSAndroid Build Coastguard Worker     }
1778*062a843bSAndroid Build Coastguard Worker     std::vector<RIL_GSM_BroadcastSmsConfigInfo*> gsmBciPtrs(num);
1779*062a843bSAndroid Build Coastguard Worker 
1780*062a843bSAndroid Build Coastguard Worker     for (uint32_t i = 0 ; i < num ; i++ ) {
1781*062a843bSAndroid Build Coastguard Worker         gsmBciPtrs[i] = &gsmBci[i];
1782*062a843bSAndroid Build Coastguard Worker         gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1783*062a843bSAndroid Build Coastguard Worker         gsmBci[i].toServiceId = configInfo[i].toServiceId;
1784*062a843bSAndroid Build Coastguard Worker         gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1785*062a843bSAndroid Build Coastguard Worker         gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1786*062a843bSAndroid Build Coastguard Worker         gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1787*062a843bSAndroid Build Coastguard Worker     }
1788*062a843bSAndroid Build Coastguard Worker 
1789*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs.data(),
1790*062a843bSAndroid Build Coastguard Worker             num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1791*062a843bSAndroid Build Coastguard Worker 
1792*062a843bSAndroid Build Coastguard Worker     delete []gsmBci;
1793*062a843bSAndroid Build Coastguard Worker     return Void();
1794*062a843bSAndroid Build Coastguard Worker }
1795*062a843bSAndroid Build Coastguard Worker 
setGsmBroadcastActivation(int32_t serial,bool activate)1796*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1797*062a843bSAndroid Build Coastguard Worker #if VDBG
1798*062a843bSAndroid Build Coastguard Worker     RLOGD("setGsmBroadcastActivation: serial %d", serial);
1799*062a843bSAndroid Build Coastguard Worker #endif
1800*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1801*062a843bSAndroid Build Coastguard Worker             1, BOOL_TO_INT(!activate));
1802*062a843bSAndroid Build Coastguard Worker     return Void();
1803*062a843bSAndroid Build Coastguard Worker }
1804*062a843bSAndroid Build Coastguard Worker 
getCdmaBroadcastConfig(int32_t serial)1805*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1806*062a843bSAndroid Build Coastguard Worker #if VDBG
1807*062a843bSAndroid Build Coastguard Worker     RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1808*062a843bSAndroid Build Coastguard Worker #endif
1809*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1810*062a843bSAndroid Build Coastguard Worker     return Void();
1811*062a843bSAndroid Build Coastguard Worker }
1812*062a843bSAndroid Build Coastguard Worker 
setCdmaBroadcastConfig(int32_t serial,const hidl_vec<CdmaBroadcastSmsConfigInfo> & configInfo)1813*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1814*062a843bSAndroid Build Coastguard Worker                                                const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1815*062a843bSAndroid Build Coastguard Worker                                                configInfo) {
1816*062a843bSAndroid Build Coastguard Worker #if VDBG
1817*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1818*062a843bSAndroid Build Coastguard Worker #endif
1819*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1820*062a843bSAndroid Build Coastguard Worker             RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1821*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1822*062a843bSAndroid Build Coastguard Worker         return Void();
1823*062a843bSAndroid Build Coastguard Worker     }
1824*062a843bSAndroid Build Coastguard Worker 
1825*062a843bSAndroid Build Coastguard Worker     uint32_t num = configInfo.size();
1826*062a843bSAndroid Build Coastguard Worker     if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
1827*062a843bSAndroid Build Coastguard Worker         RLOGE("setCdmaBroadcastConfig: Invalid configInfo length %s",
1828*062a843bSAndroid Build Coastguard Worker                 requestToString(pRI->pCI->requestNumber));
1829*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1830*062a843bSAndroid Build Coastguard Worker         return Void();
1831*062a843bSAndroid Build Coastguard Worker     }
1832*062a843bSAndroid Build Coastguard Worker     auto cdmaBci = new RIL_CDMA_BroadcastSmsConfigInfo[num];
1833*062a843bSAndroid Build Coastguard Worker     if (cdmaBci == nullptr) {
1834*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1835*062a843bSAndroid Build Coastguard Worker         return Void();
1836*062a843bSAndroid Build Coastguard Worker     }
1837*062a843bSAndroid Build Coastguard Worker     std::vector<RIL_CDMA_BroadcastSmsConfigInfo*> cdmaBciPtrs(num);
1838*062a843bSAndroid Build Coastguard Worker     for (uint32_t i = 0 ; i < num ; i++ ) {
1839*062a843bSAndroid Build Coastguard Worker         cdmaBciPtrs[i] = &cdmaBci[i];
1840*062a843bSAndroid Build Coastguard Worker         cdmaBci[i].service_category = configInfo[i].serviceCategory;
1841*062a843bSAndroid Build Coastguard Worker         cdmaBci[i].language = configInfo[i].language;
1842*062a843bSAndroid Build Coastguard Worker         cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1843*062a843bSAndroid Build Coastguard Worker     }
1844*062a843bSAndroid Build Coastguard Worker 
1845*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs.data(),
1846*062a843bSAndroid Build Coastguard Worker             num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1847*062a843bSAndroid Build Coastguard Worker 
1848*062a843bSAndroid Build Coastguard Worker     delete []cdmaBci;
1849*062a843bSAndroid Build Coastguard Worker     return Void();
1850*062a843bSAndroid Build Coastguard Worker }
1851*062a843bSAndroid Build Coastguard Worker 
setCdmaBroadcastActivation(int32_t serial,bool activate)1852*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1853*062a843bSAndroid Build Coastguard Worker #if VDBG
1854*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1855*062a843bSAndroid Build Coastguard Worker #endif
1856*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1857*062a843bSAndroid Build Coastguard Worker             1, BOOL_TO_INT(!activate));
1858*062a843bSAndroid Build Coastguard Worker     return Void();
1859*062a843bSAndroid Build Coastguard Worker }
1860*062a843bSAndroid Build Coastguard Worker 
getCDMASubscription(int32_t serial)1861*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1862*062a843bSAndroid Build Coastguard Worker #if VDBG
1863*062a843bSAndroid Build Coastguard Worker     RLOGD("getCDMASubscription: serial %d", serial);
1864*062a843bSAndroid Build Coastguard Worker #endif
1865*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1866*062a843bSAndroid Build Coastguard Worker     return Void();
1867*062a843bSAndroid Build Coastguard Worker }
1868*062a843bSAndroid Build Coastguard Worker 
writeSmsToRuim(int32_t serial,const CdmaSmsWriteArgs & cdmaSms)1869*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1870*062a843bSAndroid Build Coastguard Worker #if VDBG
1871*062a843bSAndroid Build Coastguard Worker     RLOGD("writeSmsToRuim: serial %d", serial);
1872*062a843bSAndroid Build Coastguard Worker #endif
1873*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1874*062a843bSAndroid Build Coastguard Worker             RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1875*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
1876*062a843bSAndroid Build Coastguard Worker         return Void();
1877*062a843bSAndroid Build Coastguard Worker     }
1878*062a843bSAndroid Build Coastguard Worker 
1879*062a843bSAndroid Build Coastguard Worker     RIL_CDMA_SMS_WriteArgs rcsw = {};
1880*062a843bSAndroid Build Coastguard Worker     rcsw.status = (int) cdmaSms.status;
1881*062a843bSAndroid Build Coastguard Worker     constructCdmaSms(rcsw.message, cdmaSms.message);
1882*062a843bSAndroid Build Coastguard Worker 
1883*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1884*062a843bSAndroid Build Coastguard Worker     return Void();
1885*062a843bSAndroid Build Coastguard Worker }
1886*062a843bSAndroid Build Coastguard Worker 
deleteSmsOnRuim(int32_t serial,int32_t index)1887*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1888*062a843bSAndroid Build Coastguard Worker #if VDBG
1889*062a843bSAndroid Build Coastguard Worker     RLOGD("deleteSmsOnRuim: serial %d", serial);
1890*062a843bSAndroid Build Coastguard Worker #endif
1891*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1892*062a843bSAndroid Build Coastguard Worker     return Void();
1893*062a843bSAndroid Build Coastguard Worker }
1894*062a843bSAndroid Build Coastguard Worker 
getDeviceIdentity(int32_t serial)1895*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1896*062a843bSAndroid Build Coastguard Worker #if VDBG
1897*062a843bSAndroid Build Coastguard Worker     RLOGD("getDeviceIdentity: serial %d", serial);
1898*062a843bSAndroid Build Coastguard Worker #endif
1899*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1900*062a843bSAndroid Build Coastguard Worker     return Void();
1901*062a843bSAndroid Build Coastguard Worker }
1902*062a843bSAndroid Build Coastguard Worker 
exitEmergencyCallbackMode(int32_t serial)1903*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1904*062a843bSAndroid Build Coastguard Worker #if VDBG
1905*062a843bSAndroid Build Coastguard Worker     RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1906*062a843bSAndroid Build Coastguard Worker #endif
1907*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1908*062a843bSAndroid Build Coastguard Worker     return Void();
1909*062a843bSAndroid Build Coastguard Worker }
1910*062a843bSAndroid Build Coastguard Worker 
getSmscAddress(int32_t serial)1911*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1912*062a843bSAndroid Build Coastguard Worker #if VDBG
1913*062a843bSAndroid Build Coastguard Worker     RLOGD("getSmscAddress: serial %d", serial);
1914*062a843bSAndroid Build Coastguard Worker #endif
1915*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1916*062a843bSAndroid Build Coastguard Worker     return Void();
1917*062a843bSAndroid Build Coastguard Worker }
1918*062a843bSAndroid Build Coastguard Worker 
setSmscAddress(int32_t serial,const hidl_string & smsc)1919*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1920*062a843bSAndroid Build Coastguard Worker #if VDBG
1921*062a843bSAndroid Build Coastguard Worker     RLOGD("setSmscAddress: serial %d", serial);
1922*062a843bSAndroid Build Coastguard Worker #endif
1923*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1924*062a843bSAndroid Build Coastguard Worker             smsc.c_str());
1925*062a843bSAndroid Build Coastguard Worker     return Void();
1926*062a843bSAndroid Build Coastguard Worker }
1927*062a843bSAndroid Build Coastguard Worker 
reportSmsMemoryStatus(int32_t serial,bool available)1928*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1929*062a843bSAndroid Build Coastguard Worker #if VDBG
1930*062a843bSAndroid Build Coastguard Worker     RLOGD("reportSmsMemoryStatus: serial %d", serial);
1931*062a843bSAndroid Build Coastguard Worker #endif
1932*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1933*062a843bSAndroid Build Coastguard Worker             BOOL_TO_INT(available));
1934*062a843bSAndroid Build Coastguard Worker     return Void();
1935*062a843bSAndroid Build Coastguard Worker }
1936*062a843bSAndroid Build Coastguard Worker 
reportStkServiceIsRunning(int32_t serial)1937*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1938*062a843bSAndroid Build Coastguard Worker #if VDBG
1939*062a843bSAndroid Build Coastguard Worker     RLOGD("reportStkServiceIsRunning: serial %d", serial);
1940*062a843bSAndroid Build Coastguard Worker #endif
1941*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1942*062a843bSAndroid Build Coastguard Worker     return Void();
1943*062a843bSAndroid Build Coastguard Worker }
1944*062a843bSAndroid Build Coastguard Worker 
getCdmaSubscriptionSource(int32_t serial)1945*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1946*062a843bSAndroid Build Coastguard Worker #if VDBG
1947*062a843bSAndroid Build Coastguard Worker     RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1948*062a843bSAndroid Build Coastguard Worker #endif
1949*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1950*062a843bSAndroid Build Coastguard Worker     return Void();
1951*062a843bSAndroid Build Coastguard Worker }
1952*062a843bSAndroid Build Coastguard Worker 
requestIsimAuthentication(int32_t serial,const hidl_string & challenge)1953*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1954*062a843bSAndroid Build Coastguard Worker #if VDBG
1955*062a843bSAndroid Build Coastguard Worker     RLOGD("requestIsimAuthentication: serial %d", serial);
1956*062a843bSAndroid Build Coastguard Worker #endif
1957*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1958*062a843bSAndroid Build Coastguard Worker             challenge.c_str());
1959*062a843bSAndroid Build Coastguard Worker     return Void();
1960*062a843bSAndroid Build Coastguard Worker }
1961*062a843bSAndroid Build Coastguard Worker 
acknowledgeIncomingGsmSmsWithPdu(int32_t serial,bool success,const hidl_string & ackPdu)1962*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1963*062a843bSAndroid Build Coastguard Worker                                                          const hidl_string& ackPdu) {
1964*062a843bSAndroid Build Coastguard Worker #if VDBG
1965*062a843bSAndroid Build Coastguard Worker     RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1966*062a843bSAndroid Build Coastguard Worker #endif
1967*062a843bSAndroid Build Coastguard Worker     dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
1968*062a843bSAndroid Build Coastguard Worker             2, success ? "1" : "0", ackPdu.c_str());
1969*062a843bSAndroid Build Coastguard Worker     return Void();
1970*062a843bSAndroid Build Coastguard Worker }
1971*062a843bSAndroid Build Coastguard Worker 
sendEnvelopeWithStatus(int32_t serial,const hidl_string & contents)1972*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1973*062a843bSAndroid Build Coastguard Worker #if VDBG
1974*062a843bSAndroid Build Coastguard Worker     RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1975*062a843bSAndroid Build Coastguard Worker #endif
1976*062a843bSAndroid Build Coastguard Worker     dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1977*062a843bSAndroid Build Coastguard Worker             contents.c_str());
1978*062a843bSAndroid Build Coastguard Worker     return Void();
1979*062a843bSAndroid Build Coastguard Worker }
1980*062a843bSAndroid Build Coastguard Worker 
getVoiceRadioTechnology(int32_t serial)1981*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1982*062a843bSAndroid Build Coastguard Worker #if VDBG
1983*062a843bSAndroid Build Coastguard Worker     RLOGD("getVoiceRadioTechnology: serial %d", serial);
1984*062a843bSAndroid Build Coastguard Worker #endif
1985*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1986*062a843bSAndroid Build Coastguard Worker     return Void();
1987*062a843bSAndroid Build Coastguard Worker }
1988*062a843bSAndroid Build Coastguard Worker 
getCellInfoList(int32_t serial)1989*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1990*062a843bSAndroid Build Coastguard Worker #if VDBG
1991*062a843bSAndroid Build Coastguard Worker     RLOGD("getCellInfoList: serial %d", serial);
1992*062a843bSAndroid Build Coastguard Worker #endif
1993*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1994*062a843bSAndroid Build Coastguard Worker     return Void();
1995*062a843bSAndroid Build Coastguard Worker }
1996*062a843bSAndroid Build Coastguard Worker 
setCellInfoListRate(int32_t serial,int32_t rate)1997*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1998*062a843bSAndroid Build Coastguard Worker #if VDBG
1999*062a843bSAndroid Build Coastguard Worker     RLOGD("setCellInfoListRate: serial %d", serial);
2000*062a843bSAndroid Build Coastguard Worker #endif
2001*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
2002*062a843bSAndroid Build Coastguard Worker     return Void();
2003*062a843bSAndroid Build Coastguard Worker }
2004*062a843bSAndroid Build Coastguard Worker 
setInitialAttachApn(int32_t serial,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool isRoaming)2005*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
2006*062a843bSAndroid Build Coastguard Worker                                             bool modemCognitive, bool isRoaming) {
2007*062a843bSAndroid Build Coastguard Worker #if VDBG
2008*062a843bSAndroid Build Coastguard Worker     RLOGD("setInitialAttachApn: serial %d", serial);
2009*062a843bSAndroid Build Coastguard Worker #endif
2010*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2011*062a843bSAndroid Build Coastguard Worker             RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2012*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2013*062a843bSAndroid Build Coastguard Worker         return Void();
2014*062a843bSAndroid Build Coastguard Worker     }
2015*062a843bSAndroid Build Coastguard Worker 
2016*062a843bSAndroid Build Coastguard Worker     if (s_vendorFunctions->version <= 14) {
2017*062a843bSAndroid Build Coastguard Worker         RIL_InitialAttachApn iaa = {};
2018*062a843bSAndroid Build Coastguard Worker 
2019*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2020*062a843bSAndroid Build Coastguard Worker             return Void();
2021*062a843bSAndroid Build Coastguard Worker         }
2022*062a843bSAndroid Build Coastguard Worker 
2023*062a843bSAndroid Build Coastguard Worker         const hidl_string &protocol =
2024*062a843bSAndroid Build Coastguard Worker                 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2025*062a843bSAndroid Build Coastguard Worker 
2026*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2027*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(1, iaa.apn);
2028*062a843bSAndroid Build Coastguard Worker             return Void();
2029*062a843bSAndroid Build Coastguard Worker         }
2030*062a843bSAndroid Build Coastguard Worker         iaa.authtype = (int) dataProfileInfo.authType;
2031*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2032*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2033*062a843bSAndroid Build Coastguard Worker             return Void();
2034*062a843bSAndroid Build Coastguard Worker         }
2035*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2036*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2037*062a843bSAndroid Build Coastguard Worker             return Void();
2038*062a843bSAndroid Build Coastguard Worker         }
2039*062a843bSAndroid Build Coastguard Worker 
2040*062a843bSAndroid Build Coastguard Worker         CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2041*062a843bSAndroid Build Coastguard Worker 
2042*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2043*062a843bSAndroid Build Coastguard Worker     } else {
2044*062a843bSAndroid Build Coastguard Worker         RIL_InitialAttachApn_v15 iaa = {};
2045*062a843bSAndroid Build Coastguard Worker 
2046*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2047*062a843bSAndroid Build Coastguard Worker             return Void();
2048*062a843bSAndroid Build Coastguard Worker         }
2049*062a843bSAndroid Build Coastguard Worker 
2050*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2051*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(1, iaa.apn);
2052*062a843bSAndroid Build Coastguard Worker             return Void();
2053*062a843bSAndroid Build Coastguard Worker         }
2054*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2055*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2056*062a843bSAndroid Build Coastguard Worker             return Void();
2057*062a843bSAndroid Build Coastguard Worker         }
2058*062a843bSAndroid Build Coastguard Worker         iaa.authtype = (int) dataProfileInfo.authType;
2059*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2060*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2061*062a843bSAndroid Build Coastguard Worker             return Void();
2062*062a843bSAndroid Build Coastguard Worker         }
2063*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2064*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2065*062a843bSAndroid Build Coastguard Worker             return Void();
2066*062a843bSAndroid Build Coastguard Worker         }
2067*062a843bSAndroid Build Coastguard Worker         iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2068*062a843bSAndroid Build Coastguard Worker         iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2069*062a843bSAndroid Build Coastguard Worker         iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2070*062a843bSAndroid Build Coastguard Worker         iaa.mtu = dataProfileInfo.mtu;
2071*062a843bSAndroid Build Coastguard Worker 
2072*062a843bSAndroid Build Coastguard Worker         if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2073*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2074*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2075*062a843bSAndroid Build Coastguard Worker                     iaa.password);
2076*062a843bSAndroid Build Coastguard Worker             return Void();
2077*062a843bSAndroid Build Coastguard Worker         }
2078*062a843bSAndroid Build Coastguard Worker 
2079*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2080*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2081*062a843bSAndroid Build Coastguard Worker                     iaa.password);
2082*062a843bSAndroid Build Coastguard Worker             return Void();
2083*062a843bSAndroid Build Coastguard Worker         }
2084*062a843bSAndroid Build Coastguard Worker 
2085*062a843bSAndroid Build Coastguard Worker         CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2086*062a843bSAndroid Build Coastguard Worker 
2087*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2088*062a843bSAndroid Build Coastguard Worker                 iaa.password, iaa.mvnoMatchData);
2089*062a843bSAndroid Build Coastguard Worker     }
2090*062a843bSAndroid Build Coastguard Worker 
2091*062a843bSAndroid Build Coastguard Worker     return Void();
2092*062a843bSAndroid Build Coastguard Worker }
2093*062a843bSAndroid Build Coastguard Worker 
getImsRegistrationState(int32_t serial)2094*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2095*062a843bSAndroid Build Coastguard Worker #if VDBG
2096*062a843bSAndroid Build Coastguard Worker     RLOGD("getImsRegistrationState: serial %d", serial);
2097*062a843bSAndroid Build Coastguard Worker #endif
2098*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2099*062a843bSAndroid Build Coastguard Worker     return Void();
2100*062a843bSAndroid Build Coastguard Worker }
2101*062a843bSAndroid Build Coastguard Worker 
dispatchImsGsmSms(const ImsSmsMessage & message,RequestInfo * pRI)2102*062a843bSAndroid Build Coastguard Worker bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2103*062a843bSAndroid Build Coastguard Worker     RIL_IMS_SMS_Message rism = {};
2104*062a843bSAndroid Build Coastguard Worker     char **pStrings;
2105*062a843bSAndroid Build Coastguard Worker     int countStrings = 2;
2106*062a843bSAndroid Build Coastguard Worker     int dataLen = sizeof(char *) * countStrings;
2107*062a843bSAndroid Build Coastguard Worker 
2108*062a843bSAndroid Build Coastguard Worker     rism.tech = RADIO_TECH_3GPP;
2109*062a843bSAndroid Build Coastguard Worker     rism.retry = BOOL_TO_INT(message.retry);
2110*062a843bSAndroid Build Coastguard Worker     rism.messageRef = message.messageRef;
2111*062a843bSAndroid Build Coastguard Worker 
2112*062a843bSAndroid Build Coastguard Worker     if (message.gsmMessage.size() != 1) {
2113*062a843bSAndroid Build Coastguard Worker         RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2114*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2115*062a843bSAndroid Build Coastguard Worker         return false;
2116*062a843bSAndroid Build Coastguard Worker     }
2117*062a843bSAndroid Build Coastguard Worker 
2118*062a843bSAndroid Build Coastguard Worker     pStrings = (char **)calloc(countStrings, sizeof(char *));
2119*062a843bSAndroid Build Coastguard Worker     if (pStrings == NULL) {
2120*062a843bSAndroid Build Coastguard Worker         RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2121*062a843bSAndroid Build Coastguard Worker                 requestToString(pRI->pCI->requestNumber));
2122*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2123*062a843bSAndroid Build Coastguard Worker         return false;
2124*062a843bSAndroid Build Coastguard Worker     }
2125*062a843bSAndroid Build Coastguard Worker 
2126*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2127*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
2128*062a843bSAndroid Build Coastguard Worker         memset(pStrings, 0, dataLen);
2129*062a843bSAndroid Build Coastguard Worker #endif
2130*062a843bSAndroid Build Coastguard Worker         free(pStrings);
2131*062a843bSAndroid Build Coastguard Worker         return false;
2132*062a843bSAndroid Build Coastguard Worker     }
2133*062a843bSAndroid Build Coastguard Worker 
2134*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2135*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(1, pStrings[0]);
2136*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
2137*062a843bSAndroid Build Coastguard Worker         memset(pStrings, 0, dataLen);
2138*062a843bSAndroid Build Coastguard Worker #endif
2139*062a843bSAndroid Build Coastguard Worker         free(pStrings);
2140*062a843bSAndroid Build Coastguard Worker         return false;
2141*062a843bSAndroid Build Coastguard Worker     }
2142*062a843bSAndroid Build Coastguard Worker 
2143*062a843bSAndroid Build Coastguard Worker     rism.message.gsmMessage = pStrings;
2144*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2145*062a843bSAndroid Build Coastguard Worker             sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2146*062a843bSAndroid Build Coastguard Worker 
2147*062a843bSAndroid Build Coastguard Worker     for (int i = 0 ; i < countStrings ; i++) {
2148*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(1, pStrings[i]);
2149*062a843bSAndroid Build Coastguard Worker     }
2150*062a843bSAndroid Build Coastguard Worker 
2151*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
2152*062a843bSAndroid Build Coastguard Worker     memset(pStrings, 0, dataLen);
2153*062a843bSAndroid Build Coastguard Worker #endif
2154*062a843bSAndroid Build Coastguard Worker     free(pStrings);
2155*062a843bSAndroid Build Coastguard Worker 
2156*062a843bSAndroid Build Coastguard Worker     return true;
2157*062a843bSAndroid Build Coastguard Worker }
2158*062a843bSAndroid Build Coastguard Worker 
2159*062a843bSAndroid Build Coastguard Worker struct ImsCdmaSms {
2160*062a843bSAndroid Build Coastguard Worker     RIL_IMS_SMS_Message imsSms;
2161*062a843bSAndroid Build Coastguard Worker     RIL_CDMA_SMS_Message cdmaSms;
2162*062a843bSAndroid Build Coastguard Worker };
2163*062a843bSAndroid Build Coastguard Worker 
dispatchImsCdmaSms(const ImsSmsMessage & message,RequestInfo * pRI)2164*062a843bSAndroid Build Coastguard Worker bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2165*062a843bSAndroid Build Coastguard Worker     ImsCdmaSms temp = {};
2166*062a843bSAndroid Build Coastguard Worker 
2167*062a843bSAndroid Build Coastguard Worker     if (message.cdmaMessage.size() != 1) {
2168*062a843bSAndroid Build Coastguard Worker         RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2169*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2170*062a843bSAndroid Build Coastguard Worker         return false;
2171*062a843bSAndroid Build Coastguard Worker     }
2172*062a843bSAndroid Build Coastguard Worker 
2173*062a843bSAndroid Build Coastguard Worker     temp.imsSms.tech = RADIO_TECH_3GPP2;
2174*062a843bSAndroid Build Coastguard Worker     temp.imsSms.retry = BOOL_TO_INT(message.retry);
2175*062a843bSAndroid Build Coastguard Worker     temp.imsSms.messageRef = message.messageRef;
2176*062a843bSAndroid Build Coastguard Worker     temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2177*062a843bSAndroid Build Coastguard Worker 
2178*062a843bSAndroid Build Coastguard Worker     constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2179*062a843bSAndroid Build Coastguard Worker 
2180*062a843bSAndroid Build Coastguard Worker     // Vendor code expects payload length to include actual msg payload
2181*062a843bSAndroid Build Coastguard Worker     // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2182*062a843bSAndroid Build Coastguard Worker     // RIL_IMS_SMS_Message
2183*062a843bSAndroid Build Coastguard Worker     int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2184*062a843bSAndroid Build Coastguard Worker             + sizeof(RIL_CDMA_SMS_Message);
2185*062a843bSAndroid Build Coastguard Worker 
2186*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2187*062a843bSAndroid Build Coastguard Worker 
2188*062a843bSAndroid Build Coastguard Worker     return true;
2189*062a843bSAndroid Build Coastguard Worker }
2190*062a843bSAndroid Build Coastguard Worker 
sendImsSms(int32_t serial,const ImsSmsMessage & message)2191*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2192*062a843bSAndroid Build Coastguard Worker #if VDBG
2193*062a843bSAndroid Build Coastguard Worker     RLOGD("sendImsSms: serial %d", serial);
2194*062a843bSAndroid Build Coastguard Worker #endif
2195*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2196*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2197*062a843bSAndroid Build Coastguard Worker         return Void();
2198*062a843bSAndroid Build Coastguard Worker     }
2199*062a843bSAndroid Build Coastguard Worker 
2200*062a843bSAndroid Build Coastguard Worker     if (RadioTechnologyFamily::THREE_GPP == message.tech) {
2201*062a843bSAndroid Build Coastguard Worker         dispatchImsGsmSms(message, pRI);
2202*062a843bSAndroid Build Coastguard Worker     } else if (RadioTechnologyFamily::THREE_GPP2 == message.tech) {
2203*062a843bSAndroid Build Coastguard Worker         dispatchImsCdmaSms(message, pRI);
2204*062a843bSAndroid Build Coastguard Worker     } else {
2205*062a843bSAndroid Build Coastguard Worker         RLOGE("sendImsSms: Invalid radio tech %s",
2206*062a843bSAndroid Build Coastguard Worker                 requestToString(pRI->pCI->requestNumber));
2207*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2208*062a843bSAndroid Build Coastguard Worker     }
2209*062a843bSAndroid Build Coastguard Worker     return Void();
2210*062a843bSAndroid Build Coastguard Worker }
2211*062a843bSAndroid Build Coastguard Worker 
iccTransmitApduBasicChannel(int32_t serial,const SimApdu & message)2212*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2213*062a843bSAndroid Build Coastguard Worker #if VDBG
2214*062a843bSAndroid Build Coastguard Worker     RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2215*062a843bSAndroid Build Coastguard Worker #endif
2216*062a843bSAndroid Build Coastguard Worker     dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2217*062a843bSAndroid Build Coastguard Worker     return Void();
2218*062a843bSAndroid Build Coastguard Worker }
2219*062a843bSAndroid Build Coastguard Worker 
iccOpenLogicalChannel(int32_t serial,const hidl_string & aid,int32_t p2)2220*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2221*062a843bSAndroid Build Coastguard Worker #if VDBG
2222*062a843bSAndroid Build Coastguard Worker     RLOGD("iccOpenLogicalChannel: serial %d", serial);
2223*062a843bSAndroid Build Coastguard Worker #endif
2224*062a843bSAndroid Build Coastguard Worker     if (s_vendorFunctions->version < 15) {
2225*062a843bSAndroid Build Coastguard Worker         dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2226*062a843bSAndroid Build Coastguard Worker     } else {
2227*062a843bSAndroid Build Coastguard Worker         RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2228*062a843bSAndroid Build Coastguard Worker         if (pRI == NULL) {
2229*062a843bSAndroid Build Coastguard Worker             return Void();
2230*062a843bSAndroid Build Coastguard Worker         }
2231*062a843bSAndroid Build Coastguard Worker 
2232*062a843bSAndroid Build Coastguard Worker         RIL_OpenChannelParams params = {};
2233*062a843bSAndroid Build Coastguard Worker 
2234*062a843bSAndroid Build Coastguard Worker         params.p2 = p2;
2235*062a843bSAndroid Build Coastguard Worker 
2236*062a843bSAndroid Build Coastguard Worker         if (!copyHidlStringToRil(&params.aidPtr, aid, pRI)) {
2237*062a843bSAndroid Build Coastguard Worker             return Void();
2238*062a843bSAndroid Build Coastguard Worker         }
2239*062a843bSAndroid Build Coastguard Worker 
2240*062a843bSAndroid Build Coastguard Worker         CALL_ONREQUEST(pRI->pCI->requestNumber, &params, sizeof(params), pRI, mSlotId);
2241*062a843bSAndroid Build Coastguard Worker 
2242*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(1, params.aidPtr);
2243*062a843bSAndroid Build Coastguard Worker     }
2244*062a843bSAndroid Build Coastguard Worker     return Void();
2245*062a843bSAndroid Build Coastguard Worker }
2246*062a843bSAndroid Build Coastguard Worker 
iccCloseLogicalChannel(int32_t serial,int32_t channelId)2247*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2248*062a843bSAndroid Build Coastguard Worker #if VDBG
2249*062a843bSAndroid Build Coastguard Worker     RLOGD("iccCloseLogicalChannel: serial %d", serial);
2250*062a843bSAndroid Build Coastguard Worker #endif
2251*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2252*062a843bSAndroid Build Coastguard Worker     return Void();
2253*062a843bSAndroid Build Coastguard Worker }
2254*062a843bSAndroid Build Coastguard Worker 
iccTransmitApduLogicalChannel(int32_t serial,const SimApdu & message)2255*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2256*062a843bSAndroid Build Coastguard Worker #if VDBG
2257*062a843bSAndroid Build Coastguard Worker     RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2258*062a843bSAndroid Build Coastguard Worker #endif
2259*062a843bSAndroid Build Coastguard Worker     dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2260*062a843bSAndroid Build Coastguard Worker     return Void();
2261*062a843bSAndroid Build Coastguard Worker }
2262*062a843bSAndroid Build Coastguard Worker 
nvReadItem(int32_t serial,NvItem itemId)2263*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2264*062a843bSAndroid Build Coastguard Worker #if VDBG
2265*062a843bSAndroid Build Coastguard Worker     RLOGD("nvReadItem: serial %d", serial);
2266*062a843bSAndroid Build Coastguard Worker #endif
2267*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2268*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2269*062a843bSAndroid Build Coastguard Worker         return Void();
2270*062a843bSAndroid Build Coastguard Worker     }
2271*062a843bSAndroid Build Coastguard Worker 
2272*062a843bSAndroid Build Coastguard Worker     RIL_NV_ReadItem nvri = {};
2273*062a843bSAndroid Build Coastguard Worker     nvri.itemID = (RIL_NV_Item) itemId;
2274*062a843bSAndroid Build Coastguard Worker 
2275*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2276*062a843bSAndroid Build Coastguard Worker     return Void();
2277*062a843bSAndroid Build Coastguard Worker }
2278*062a843bSAndroid Build Coastguard Worker 
nvWriteItem(int32_t serial,const NvWriteItem & item)2279*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2280*062a843bSAndroid Build Coastguard Worker #if VDBG
2281*062a843bSAndroid Build Coastguard Worker     RLOGD("nvWriteItem: serial %d", serial);
2282*062a843bSAndroid Build Coastguard Worker #endif
2283*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2284*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2285*062a843bSAndroid Build Coastguard Worker         return Void();
2286*062a843bSAndroid Build Coastguard Worker     }
2287*062a843bSAndroid Build Coastguard Worker 
2288*062a843bSAndroid Build Coastguard Worker     RIL_NV_WriteItem nvwi = {};
2289*062a843bSAndroid Build Coastguard Worker 
2290*062a843bSAndroid Build Coastguard Worker     nvwi.itemID = (RIL_NV_Item) item.itemId;
2291*062a843bSAndroid Build Coastguard Worker 
2292*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2293*062a843bSAndroid Build Coastguard Worker         return Void();
2294*062a843bSAndroid Build Coastguard Worker     }
2295*062a843bSAndroid Build Coastguard Worker 
2296*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2297*062a843bSAndroid Build Coastguard Worker 
2298*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(1, nvwi.value);
2299*062a843bSAndroid Build Coastguard Worker     return Void();
2300*062a843bSAndroid Build Coastguard Worker }
2301*062a843bSAndroid Build Coastguard Worker 
nvWriteCdmaPrl(int32_t serial,const hidl_vec<uint8_t> & prl)2302*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2303*062a843bSAndroid Build Coastguard Worker #if VDBG
2304*062a843bSAndroid Build Coastguard Worker     RLOGD("nvWriteCdmaPrl: serial %d", serial);
2305*062a843bSAndroid Build Coastguard Worker #endif
2306*062a843bSAndroid Build Coastguard Worker     dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2307*062a843bSAndroid Build Coastguard Worker     return Void();
2308*062a843bSAndroid Build Coastguard Worker }
2309*062a843bSAndroid Build Coastguard Worker 
nvResetConfig(int32_t serial,ResetNvType resetType)2310*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2311*062a843bSAndroid Build Coastguard Worker     int rilResetType = -1;
2312*062a843bSAndroid Build Coastguard Worker #if VDBG
2313*062a843bSAndroid Build Coastguard Worker     RLOGD("nvResetConfig: serial %d", serial);
2314*062a843bSAndroid Build Coastguard Worker #endif
2315*062a843bSAndroid Build Coastguard Worker     /* Convert ResetNvType to RIL.h values
2316*062a843bSAndroid Build Coastguard Worker      * RIL_REQUEST_NV_RESET_CONFIG
2317*062a843bSAndroid Build Coastguard Worker      * 1 - reload all NV items
2318*062a843bSAndroid Build Coastguard Worker      * 2 - erase NV reset (SCRTN)
2319*062a843bSAndroid Build Coastguard Worker      * 3 - factory reset (RTN)
2320*062a843bSAndroid Build Coastguard Worker      */
2321*062a843bSAndroid Build Coastguard Worker     switch(resetType) {
2322*062a843bSAndroid Build Coastguard Worker       case ResetNvType::RELOAD:
2323*062a843bSAndroid Build Coastguard Worker         rilResetType = 1;
2324*062a843bSAndroid Build Coastguard Worker         break;
2325*062a843bSAndroid Build Coastguard Worker       case ResetNvType::ERASE:
2326*062a843bSAndroid Build Coastguard Worker         rilResetType = 2;
2327*062a843bSAndroid Build Coastguard Worker         break;
2328*062a843bSAndroid Build Coastguard Worker       case ResetNvType::FACTORY_RESET:
2329*062a843bSAndroid Build Coastguard Worker         rilResetType = 3;
2330*062a843bSAndroid Build Coastguard Worker         break;
2331*062a843bSAndroid Build Coastguard Worker     }
2332*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2333*062a843bSAndroid Build Coastguard Worker     return Void();
2334*062a843bSAndroid Build Coastguard Worker }
2335*062a843bSAndroid Build Coastguard Worker 
setUiccSubscription(int32_t serial,const SelectUiccSub & uiccSub)2336*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2337*062a843bSAndroid Build Coastguard Worker #if VDBG
2338*062a843bSAndroid Build Coastguard Worker     RLOGD("setUiccSubscription: serial %d", serial);
2339*062a843bSAndroid Build Coastguard Worker #endif
2340*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2341*062a843bSAndroid Build Coastguard Worker             RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2342*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2343*062a843bSAndroid Build Coastguard Worker         return Void();
2344*062a843bSAndroid Build Coastguard Worker     }
2345*062a843bSAndroid Build Coastguard Worker 
2346*062a843bSAndroid Build Coastguard Worker     RIL_SelectUiccSub rilUiccSub = {};
2347*062a843bSAndroid Build Coastguard Worker 
2348*062a843bSAndroid Build Coastguard Worker     rilUiccSub.slot = uiccSub.slot;
2349*062a843bSAndroid Build Coastguard Worker     rilUiccSub.app_index = uiccSub.appIndex;
2350*062a843bSAndroid Build Coastguard Worker     rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2351*062a843bSAndroid Build Coastguard Worker     rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2352*062a843bSAndroid Build Coastguard Worker 
2353*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2354*062a843bSAndroid Build Coastguard Worker     return Void();
2355*062a843bSAndroid Build Coastguard Worker }
2356*062a843bSAndroid Build Coastguard Worker 
setDataAllowed(int32_t serial,bool allow)2357*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2358*062a843bSAndroid Build Coastguard Worker #if VDBG
2359*062a843bSAndroid Build Coastguard Worker     RLOGD("setDataAllowed: serial %d", serial);
2360*062a843bSAndroid Build Coastguard Worker #endif
2361*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2362*062a843bSAndroid Build Coastguard Worker     return Void();
2363*062a843bSAndroid Build Coastguard Worker }
2364*062a843bSAndroid Build Coastguard Worker 
getHardwareConfig(int32_t serial)2365*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2366*062a843bSAndroid Build Coastguard Worker #if VDBG
2367*062a843bSAndroid Build Coastguard Worker     RLOGD("getHardwareConfig: serial %d", serial);
2368*062a843bSAndroid Build Coastguard Worker #endif
2369*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2370*062a843bSAndroid Build Coastguard Worker     return Void();
2371*062a843bSAndroid Build Coastguard Worker }
2372*062a843bSAndroid Build Coastguard Worker 
requestIccSimAuthentication(int32_t serial,int32_t authContext,const hidl_string & authData,const hidl_string & aid)2373*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2374*062a843bSAndroid Build Coastguard Worker         const hidl_string& authData, const hidl_string& aid) {
2375*062a843bSAndroid Build Coastguard Worker #if VDBG
2376*062a843bSAndroid Build Coastguard Worker     RLOGD("requestIccSimAuthentication: serial %d", serial);
2377*062a843bSAndroid Build Coastguard Worker #endif
2378*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2379*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2380*062a843bSAndroid Build Coastguard Worker         return Void();
2381*062a843bSAndroid Build Coastguard Worker     }
2382*062a843bSAndroid Build Coastguard Worker 
2383*062a843bSAndroid Build Coastguard Worker     RIL_SimAuthentication pf = {};
2384*062a843bSAndroid Build Coastguard Worker 
2385*062a843bSAndroid Build Coastguard Worker     pf.authContext = authContext;
2386*062a843bSAndroid Build Coastguard Worker 
2387*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2388*062a843bSAndroid Build Coastguard Worker         return Void();
2389*062a843bSAndroid Build Coastguard Worker     }
2390*062a843bSAndroid Build Coastguard Worker 
2391*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2392*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(1, pf.authData);
2393*062a843bSAndroid Build Coastguard Worker         return Void();
2394*062a843bSAndroid Build Coastguard Worker     }
2395*062a843bSAndroid Build Coastguard Worker 
2396*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2397*062a843bSAndroid Build Coastguard Worker 
2398*062a843bSAndroid Build Coastguard Worker     memsetAndFreeStrings(2, pf.authData, pf.aid);
2399*062a843bSAndroid Build Coastguard Worker     return Void();
2400*062a843bSAndroid Build Coastguard Worker }
2401*062a843bSAndroid Build Coastguard Worker 
2402*062a843bSAndroid Build Coastguard Worker /**
2403*062a843bSAndroid Build Coastguard Worker  * @param numProfiles number of data profile
2404*062a843bSAndroid Build Coastguard Worker  * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2405*062a843bSAndroid Build Coastguard Worker           RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2406*062a843bSAndroid Build Coastguard Worker  * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2407*062a843bSAndroid Build Coastguard Worker  * @param numfields number of string-type member in the data profile structure
2408*062a843bSAndroid Build Coastguard Worker  * @param ... the variadic parameters are pointers to each string-type member
2409*062a843bSAndroid Build Coastguard Worker  **/
2410*062a843bSAndroid Build Coastguard Worker template <typename T>
freeSetDataProfileData(int numProfiles,T * dataProfiles,T ** dataProfilePtrs,int numfields,...)2411*062a843bSAndroid Build Coastguard Worker void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2412*062a843bSAndroid Build Coastguard Worker                             int numfields, ...) {
2413*062a843bSAndroid Build Coastguard Worker     va_list args;
2414*062a843bSAndroid Build Coastguard Worker     va_start(args, numfields);
2415*062a843bSAndroid Build Coastguard Worker 
2416*062a843bSAndroid Build Coastguard Worker     // Iterate through each string-type field that need to be free.
2417*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < numfields; i++) {
2418*062a843bSAndroid Build Coastguard Worker         // Iterate through each data profile and free that specific string-type field.
2419*062a843bSAndroid Build Coastguard Worker         // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2420*062a843bSAndroid Build Coastguard Worker         char *T::*ptr = va_arg(args, char *T::*);
2421*062a843bSAndroid Build Coastguard Worker         for (int j = 0; j < numProfiles; j++) {
2422*062a843bSAndroid Build Coastguard Worker             memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2423*062a843bSAndroid Build Coastguard Worker         }
2424*062a843bSAndroid Build Coastguard Worker     }
2425*062a843bSAndroid Build Coastguard Worker 
2426*062a843bSAndroid Build Coastguard Worker     va_end(args);
2427*062a843bSAndroid Build Coastguard Worker 
2428*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
2429*062a843bSAndroid Build Coastguard Worker     memset(dataProfiles, 0, numProfiles * sizeof(T));
2430*062a843bSAndroid Build Coastguard Worker     memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2431*062a843bSAndroid Build Coastguard Worker #endif
2432*062a843bSAndroid Build Coastguard Worker     free(dataProfiles);
2433*062a843bSAndroid Build Coastguard Worker     free(dataProfilePtrs);
2434*062a843bSAndroid Build Coastguard Worker }
2435*062a843bSAndroid Build Coastguard Worker 
setDataProfile(int32_t serial,const hidl_vec<DataProfileInfo> & profiles,bool isRoaming)2436*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2437*062a843bSAndroid Build Coastguard Worker                                        bool isRoaming) {
2438*062a843bSAndroid Build Coastguard Worker #if VDBG
2439*062a843bSAndroid Build Coastguard Worker     RLOGD("setDataProfile: serial %d", serial);
2440*062a843bSAndroid Build Coastguard Worker #endif
2441*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2442*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2443*062a843bSAndroid Build Coastguard Worker         return Void();
2444*062a843bSAndroid Build Coastguard Worker     }
2445*062a843bSAndroid Build Coastguard Worker 
2446*062a843bSAndroid Build Coastguard Worker     size_t num = profiles.size();
2447*062a843bSAndroid Build Coastguard Worker     bool success = false;
2448*062a843bSAndroid Build Coastguard Worker 
2449*062a843bSAndroid Build Coastguard Worker     if (s_vendorFunctions->version <= 14) {
2450*062a843bSAndroid Build Coastguard Worker 
2451*062a843bSAndroid Build Coastguard Worker         RIL_DataProfileInfo *dataProfiles =
2452*062a843bSAndroid Build Coastguard Worker             (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2453*062a843bSAndroid Build Coastguard Worker 
2454*062a843bSAndroid Build Coastguard Worker         if (dataProfiles == NULL) {
2455*062a843bSAndroid Build Coastguard Worker             RLOGE("Memory allocation failed for request %s",
2456*062a843bSAndroid Build Coastguard Worker                     requestToString(pRI->pCI->requestNumber));
2457*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2458*062a843bSAndroid Build Coastguard Worker             return Void();
2459*062a843bSAndroid Build Coastguard Worker         }
2460*062a843bSAndroid Build Coastguard Worker 
2461*062a843bSAndroid Build Coastguard Worker         RIL_DataProfileInfo **dataProfilePtrs =
2462*062a843bSAndroid Build Coastguard Worker             (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2463*062a843bSAndroid Build Coastguard Worker         if (dataProfilePtrs == NULL) {
2464*062a843bSAndroid Build Coastguard Worker             RLOGE("Memory allocation failed for request %s",
2465*062a843bSAndroid Build Coastguard Worker                     requestToString(pRI->pCI->requestNumber));
2466*062a843bSAndroid Build Coastguard Worker             free(dataProfiles);
2467*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2468*062a843bSAndroid Build Coastguard Worker             return Void();
2469*062a843bSAndroid Build Coastguard Worker         }
2470*062a843bSAndroid Build Coastguard Worker 
2471*062a843bSAndroid Build Coastguard Worker         for (size_t i = 0; i < num; i++) {
2472*062a843bSAndroid Build Coastguard Worker             dataProfilePtrs[i] = &dataProfiles[i];
2473*062a843bSAndroid Build Coastguard Worker 
2474*062a843bSAndroid Build Coastguard Worker             success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2475*062a843bSAndroid Build Coastguard Worker 
2476*062a843bSAndroid Build Coastguard Worker             const hidl_string &protocol =
2477*062a843bSAndroid Build Coastguard Worker                     (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2478*062a843bSAndroid Build Coastguard Worker 
2479*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
2480*062a843bSAndroid Build Coastguard Worker                 success = false;
2481*062a843bSAndroid Build Coastguard Worker             }
2482*062a843bSAndroid Build Coastguard Worker 
2483*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2484*062a843bSAndroid Build Coastguard Worker                     true)) {
2485*062a843bSAndroid Build Coastguard Worker                 success = false;
2486*062a843bSAndroid Build Coastguard Worker             }
2487*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2488*062a843bSAndroid Build Coastguard Worker                     pRI, true)) {
2489*062a843bSAndroid Build Coastguard Worker                 success = false;
2490*062a843bSAndroid Build Coastguard Worker             }
2491*062a843bSAndroid Build Coastguard Worker 
2492*062a843bSAndroid Build Coastguard Worker             if (!success) {
2493*062a843bSAndroid Build Coastguard Worker                 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2494*062a843bSAndroid Build Coastguard Worker                     &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2495*062a843bSAndroid Build Coastguard Worker                     &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2496*062a843bSAndroid Build Coastguard Worker                 return Void();
2497*062a843bSAndroid Build Coastguard Worker             }
2498*062a843bSAndroid Build Coastguard Worker 
2499*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2500*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].authType = (int) profiles[i].authType;
2501*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].type = (int) profiles[i].type;
2502*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2503*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].maxConns = profiles[i].maxConns;
2504*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].waitTime = profiles[i].waitTime;
2505*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2506*062a843bSAndroid Build Coastguard Worker         }
2507*062a843bSAndroid Build Coastguard Worker 
2508*062a843bSAndroid Build Coastguard Worker         CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2509*062a843bSAndroid Build Coastguard Worker                 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2510*062a843bSAndroid Build Coastguard Worker 
2511*062a843bSAndroid Build Coastguard Worker         freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2512*062a843bSAndroid Build Coastguard Worker                 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2513*062a843bSAndroid Build Coastguard Worker                 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2514*062a843bSAndroid Build Coastguard Worker     } else {
2515*062a843bSAndroid Build Coastguard Worker         RIL_DataProfileInfo_v15 *dataProfiles =
2516*062a843bSAndroid Build Coastguard Worker             (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2517*062a843bSAndroid Build Coastguard Worker 
2518*062a843bSAndroid Build Coastguard Worker         if (dataProfiles == NULL) {
2519*062a843bSAndroid Build Coastguard Worker             RLOGE("Memory allocation failed for request %s",
2520*062a843bSAndroid Build Coastguard Worker                     requestToString(pRI->pCI->requestNumber));
2521*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2522*062a843bSAndroid Build Coastguard Worker             return Void();
2523*062a843bSAndroid Build Coastguard Worker         }
2524*062a843bSAndroid Build Coastguard Worker 
2525*062a843bSAndroid Build Coastguard Worker         RIL_DataProfileInfo_v15 **dataProfilePtrs =
2526*062a843bSAndroid Build Coastguard Worker             (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2527*062a843bSAndroid Build Coastguard Worker         if (dataProfilePtrs == NULL) {
2528*062a843bSAndroid Build Coastguard Worker             RLOGE("Memory allocation failed for request %s",
2529*062a843bSAndroid Build Coastguard Worker                     requestToString(pRI->pCI->requestNumber));
2530*062a843bSAndroid Build Coastguard Worker             free(dataProfiles);
2531*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2532*062a843bSAndroid Build Coastguard Worker             return Void();
2533*062a843bSAndroid Build Coastguard Worker         }
2534*062a843bSAndroid Build Coastguard Worker 
2535*062a843bSAndroid Build Coastguard Worker         for (size_t i = 0; i < num; i++) {
2536*062a843bSAndroid Build Coastguard Worker             dataProfilePtrs[i] = &dataProfiles[i];
2537*062a843bSAndroid Build Coastguard Worker 
2538*062a843bSAndroid Build Coastguard Worker             success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2539*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2540*062a843bSAndroid Build Coastguard Worker                     pRI)) {
2541*062a843bSAndroid Build Coastguard Worker                 success = false;
2542*062a843bSAndroid Build Coastguard Worker             }
2543*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2544*062a843bSAndroid Build Coastguard Worker                     profiles[i].roamingProtocol, pRI, true)) {
2545*062a843bSAndroid Build Coastguard Worker                 success = false;
2546*062a843bSAndroid Build Coastguard Worker             }
2547*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2548*062a843bSAndroid Build Coastguard Worker                     true)) {
2549*062a843bSAndroid Build Coastguard Worker                 success = false;
2550*062a843bSAndroid Build Coastguard Worker             }
2551*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2552*062a843bSAndroid Build Coastguard Worker                     pRI, true)) {
2553*062a843bSAndroid Build Coastguard Worker                 success = false;
2554*062a843bSAndroid Build Coastguard Worker             }
2555*062a843bSAndroid Build Coastguard Worker             if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2556*062a843bSAndroid Build Coastguard Worker                     profiles[i].mvnoMatchData, pRI, true)) {
2557*062a843bSAndroid Build Coastguard Worker                 success = false;
2558*062a843bSAndroid Build Coastguard Worker             }
2559*062a843bSAndroid Build Coastguard Worker 
2560*062a843bSAndroid Build Coastguard Worker             if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2561*062a843bSAndroid Build Coastguard Worker                     dataProfiles[i].mvnoType)) {
2562*062a843bSAndroid Build Coastguard Worker                 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2563*062a843bSAndroid Build Coastguard Worker                 success = false;
2564*062a843bSAndroid Build Coastguard Worker             }
2565*062a843bSAndroid Build Coastguard Worker 
2566*062a843bSAndroid Build Coastguard Worker             if (!success) {
2567*062a843bSAndroid Build Coastguard Worker                 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2568*062a843bSAndroid Build Coastguard Worker                     &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2569*062a843bSAndroid Build Coastguard Worker                     &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2570*062a843bSAndroid Build Coastguard Worker                     &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2571*062a843bSAndroid Build Coastguard Worker                 return Void();
2572*062a843bSAndroid Build Coastguard Worker             }
2573*062a843bSAndroid Build Coastguard Worker 
2574*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2575*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].authType = (int) profiles[i].authType;
2576*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].type = (int) profiles[i].type;
2577*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2578*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].maxConns = profiles[i].maxConns;
2579*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].waitTime = profiles[i].waitTime;
2580*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2581*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2582*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2583*062a843bSAndroid Build Coastguard Worker             dataProfiles[i].mtu = profiles[i].mtu;
2584*062a843bSAndroid Build Coastguard Worker         }
2585*062a843bSAndroid Build Coastguard Worker 
2586*062a843bSAndroid Build Coastguard Worker         CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2587*062a843bSAndroid Build Coastguard Worker                 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2588*062a843bSAndroid Build Coastguard Worker 
2589*062a843bSAndroid Build Coastguard Worker         freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2590*062a843bSAndroid Build Coastguard Worker                 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2591*062a843bSAndroid Build Coastguard Worker                 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2592*062a843bSAndroid Build Coastguard Worker                 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2593*062a843bSAndroid Build Coastguard Worker     }
2594*062a843bSAndroid Build Coastguard Worker 
2595*062a843bSAndroid Build Coastguard Worker     return Void();
2596*062a843bSAndroid Build Coastguard Worker }
2597*062a843bSAndroid Build Coastguard Worker 
requestShutdown(int32_t serial)2598*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::requestShutdown(int32_t serial) {
2599*062a843bSAndroid Build Coastguard Worker #if VDBG
2600*062a843bSAndroid Build Coastguard Worker     RLOGD("requestShutdown: serial %d", serial);
2601*062a843bSAndroid Build Coastguard Worker #endif
2602*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2603*062a843bSAndroid Build Coastguard Worker     return Void();
2604*062a843bSAndroid Build Coastguard Worker }
2605*062a843bSAndroid Build Coastguard Worker 
getRadioCapability(int32_t serial)2606*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2607*062a843bSAndroid Build Coastguard Worker #if VDBG
2608*062a843bSAndroid Build Coastguard Worker     RLOGD("getRadioCapability: serial %d", serial);
2609*062a843bSAndroid Build Coastguard Worker #endif
2610*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2611*062a843bSAndroid Build Coastguard Worker     return Void();
2612*062a843bSAndroid Build Coastguard Worker }
2613*062a843bSAndroid Build Coastguard Worker 
setRadioCapability(int32_t serial,const RadioCapability & rc)2614*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2615*062a843bSAndroid Build Coastguard Worker #if VDBG
2616*062a843bSAndroid Build Coastguard Worker     RLOGD("setRadioCapability: serial %d", serial);
2617*062a843bSAndroid Build Coastguard Worker #endif
2618*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2619*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2620*062a843bSAndroid Build Coastguard Worker         return Void();
2621*062a843bSAndroid Build Coastguard Worker     }
2622*062a843bSAndroid Build Coastguard Worker 
2623*062a843bSAndroid Build Coastguard Worker     RIL_RadioCapability rilRc = {};
2624*062a843bSAndroid Build Coastguard Worker 
2625*062a843bSAndroid Build Coastguard Worker     // TODO : set rilRc.version using HIDL version ?
2626*062a843bSAndroid Build Coastguard Worker     rilRc.session = rc.session;
2627*062a843bSAndroid Build Coastguard Worker     rilRc.phase = (int) rc.phase;
2628*062a843bSAndroid Build Coastguard Worker     rilRc.rat = (int) rc.raf;
2629*062a843bSAndroid Build Coastguard Worker     rilRc.status = (int) rc.status;
2630*062a843bSAndroid Build Coastguard Worker     strlcpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), sizeof(rilRc.logicalModemUuid));
2631*062a843bSAndroid Build Coastguard Worker 
2632*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2633*062a843bSAndroid Build Coastguard Worker 
2634*062a843bSAndroid Build Coastguard Worker     return Void();
2635*062a843bSAndroid Build Coastguard Worker }
2636*062a843bSAndroid Build Coastguard Worker 
startLceService(int32_t serial,int32_t reportInterval,bool pullMode)2637*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2638*062a843bSAndroid Build Coastguard Worker #if VDBG
2639*062a843bSAndroid Build Coastguard Worker     RLOGD("startLceService: serial %d", serial);
2640*062a843bSAndroid Build Coastguard Worker #endif
2641*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2642*062a843bSAndroid Build Coastguard Worker             BOOL_TO_INT(pullMode));
2643*062a843bSAndroid Build Coastguard Worker     return Void();
2644*062a843bSAndroid Build Coastguard Worker }
2645*062a843bSAndroid Build Coastguard Worker 
stopLceService(int32_t serial)2646*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::stopLceService(int32_t serial) {
2647*062a843bSAndroid Build Coastguard Worker #if VDBG
2648*062a843bSAndroid Build Coastguard Worker     RLOGD("stopLceService: serial %d", serial);
2649*062a843bSAndroid Build Coastguard Worker #endif
2650*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2651*062a843bSAndroid Build Coastguard Worker     return Void();
2652*062a843bSAndroid Build Coastguard Worker }
2653*062a843bSAndroid Build Coastguard Worker 
pullLceData(int32_t serial)2654*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::pullLceData(int32_t serial) {
2655*062a843bSAndroid Build Coastguard Worker #if VDBG
2656*062a843bSAndroid Build Coastguard Worker     RLOGD("pullLceData: serial %d", serial);
2657*062a843bSAndroid Build Coastguard Worker #endif
2658*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2659*062a843bSAndroid Build Coastguard Worker     return Void();
2660*062a843bSAndroid Build Coastguard Worker }
2661*062a843bSAndroid Build Coastguard Worker 
getModemActivityInfo(int32_t serial)2662*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2663*062a843bSAndroid Build Coastguard Worker #if VDBG
2664*062a843bSAndroid Build Coastguard Worker     RLOGD("getModemActivityInfo: serial %d", serial);
2665*062a843bSAndroid Build Coastguard Worker #endif
2666*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2667*062a843bSAndroid Build Coastguard Worker     return Void();
2668*062a843bSAndroid Build Coastguard Worker }
2669*062a843bSAndroid Build Coastguard Worker 
setAllowedCarriers(int32_t serial,bool allAllowed,const CarrierRestrictions & carriers)2670*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2671*062a843bSAndroid Build Coastguard Worker                                            const CarrierRestrictions& carriers) {
2672*062a843bSAndroid Build Coastguard Worker #if VDBG
2673*062a843bSAndroid Build Coastguard Worker     RLOGD("setAllowedCarriers: serial %d", serial);
2674*062a843bSAndroid Build Coastguard Worker #endif
2675*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2676*062a843bSAndroid Build Coastguard Worker             RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2677*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2678*062a843bSAndroid Build Coastguard Worker         return Void();
2679*062a843bSAndroid Build Coastguard Worker     }
2680*062a843bSAndroid Build Coastguard Worker 
2681*062a843bSAndroid Build Coastguard Worker     RIL_CarrierRestrictions cr = {};
2682*062a843bSAndroid Build Coastguard Worker     RIL_Carrier *allowedCarriers = NULL;
2683*062a843bSAndroid Build Coastguard Worker     RIL_Carrier *excludedCarriers = NULL;
2684*062a843bSAndroid Build Coastguard Worker 
2685*062a843bSAndroid Build Coastguard Worker     cr.len_allowed_carriers = carriers.allowedCarriers.size();
2686*062a843bSAndroid Build Coastguard Worker     allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2687*062a843bSAndroid Build Coastguard Worker     if (allowedCarriers == NULL) {
2688*062a843bSAndroid Build Coastguard Worker         RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2689*062a843bSAndroid Build Coastguard Worker                 requestToString(pRI->pCI->requestNumber));
2690*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2691*062a843bSAndroid Build Coastguard Worker         return Void();
2692*062a843bSAndroid Build Coastguard Worker     }
2693*062a843bSAndroid Build Coastguard Worker     cr.allowed_carriers = allowedCarriers;
2694*062a843bSAndroid Build Coastguard Worker 
2695*062a843bSAndroid Build Coastguard Worker     cr.len_excluded_carriers = carriers.excludedCarriers.size();
2696*062a843bSAndroid Build Coastguard Worker     excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2697*062a843bSAndroid Build Coastguard Worker     if (excludedCarriers == NULL) {
2698*062a843bSAndroid Build Coastguard Worker         RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2699*062a843bSAndroid Build Coastguard Worker                 requestToString(pRI->pCI->requestNumber));
2700*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2701*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
2702*062a843bSAndroid Build Coastguard Worker         memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2703*062a843bSAndroid Build Coastguard Worker #endif
2704*062a843bSAndroid Build Coastguard Worker         free(allowedCarriers);
2705*062a843bSAndroid Build Coastguard Worker         return Void();
2706*062a843bSAndroid Build Coastguard Worker     }
2707*062a843bSAndroid Build Coastguard Worker     cr.excluded_carriers = excludedCarriers;
2708*062a843bSAndroid Build Coastguard Worker 
2709*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < cr.len_allowed_carriers; i++) {
2710*062a843bSAndroid Build Coastguard Worker         allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2711*062a843bSAndroid Build Coastguard Worker         allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2712*062a843bSAndroid Build Coastguard Worker         allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2713*062a843bSAndroid Build Coastguard Worker         allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2714*062a843bSAndroid Build Coastguard Worker     }
2715*062a843bSAndroid Build Coastguard Worker 
2716*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < cr.len_excluded_carriers; i++) {
2717*062a843bSAndroid Build Coastguard Worker         excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2718*062a843bSAndroid Build Coastguard Worker         excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2719*062a843bSAndroid Build Coastguard Worker         excludedCarriers[i].match_type =
2720*062a843bSAndroid Build Coastguard Worker                 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2721*062a843bSAndroid Build Coastguard Worker         excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2722*062a843bSAndroid Build Coastguard Worker     }
2723*062a843bSAndroid Build Coastguard Worker 
2724*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2725*062a843bSAndroid Build Coastguard Worker 
2726*062a843bSAndroid Build Coastguard Worker #ifdef MEMSET_FREED
2727*062a843bSAndroid Build Coastguard Worker     memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2728*062a843bSAndroid Build Coastguard Worker     memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2729*062a843bSAndroid Build Coastguard Worker #endif
2730*062a843bSAndroid Build Coastguard Worker     free(allowedCarriers);
2731*062a843bSAndroid Build Coastguard Worker     free(excludedCarriers);
2732*062a843bSAndroid Build Coastguard Worker     return Void();
2733*062a843bSAndroid Build Coastguard Worker }
2734*062a843bSAndroid Build Coastguard Worker 
getAllowedCarriers(int32_t serial)2735*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2736*062a843bSAndroid Build Coastguard Worker #if VDBG
2737*062a843bSAndroid Build Coastguard Worker     RLOGD("getAllowedCarriers: serial %d", serial);
2738*062a843bSAndroid Build Coastguard Worker #endif
2739*062a843bSAndroid Build Coastguard Worker     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2740*062a843bSAndroid Build Coastguard Worker     return Void();
2741*062a843bSAndroid Build Coastguard Worker }
2742*062a843bSAndroid Build Coastguard Worker 
sendDeviceState(int32_t serial,DeviceStateType deviceStateType,bool state)2743*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2744*062a843bSAndroid Build Coastguard Worker                                         bool state) {
2745*062a843bSAndroid Build Coastguard Worker #if VDBG
2746*062a843bSAndroid Build Coastguard Worker     RLOGD("sendDeviceState: serial %d", serial);
2747*062a843bSAndroid Build Coastguard Worker #endif
2748*062a843bSAndroid Build Coastguard Worker     if (s_vendorFunctions->version < 15) {
2749*062a843bSAndroid Build Coastguard Worker         if (deviceStateType ==  DeviceStateType::LOW_DATA_EXPECTED) {
2750*062a843bSAndroid Build Coastguard Worker             RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2751*062a843bSAndroid Build Coastguard Worker             dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2752*062a843bSAndroid Build Coastguard Worker         } else {
2753*062a843bSAndroid Build Coastguard Worker             RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2754*062a843bSAndroid Build Coastguard Worker                     RIL_REQUEST_SEND_DEVICE_STATE);
2755*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2756*062a843bSAndroid Build Coastguard Worker         }
2757*062a843bSAndroid Build Coastguard Worker         return Void();
2758*062a843bSAndroid Build Coastguard Worker     }
2759*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2760*062a843bSAndroid Build Coastguard Worker             BOOL_TO_INT(state));
2761*062a843bSAndroid Build Coastguard Worker     return Void();
2762*062a843bSAndroid Build Coastguard Worker }
2763*062a843bSAndroid Build Coastguard Worker 
setIndicationFilter(int32_t serial,int32_t indicationFilter)2764*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2765*062a843bSAndroid Build Coastguard Worker #if VDBG
2766*062a843bSAndroid Build Coastguard Worker     RLOGD("setIndicationFilter: serial %d", serial);
2767*062a843bSAndroid Build Coastguard Worker #endif
2768*062a843bSAndroid Build Coastguard Worker     if (s_vendorFunctions->version < 15) {
2769*062a843bSAndroid Build Coastguard Worker         RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2770*062a843bSAndroid Build Coastguard Worker                 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2771*062a843bSAndroid Build Coastguard Worker         sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2772*062a843bSAndroid Build Coastguard Worker         return Void();
2773*062a843bSAndroid Build Coastguard Worker     }
2774*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2775*062a843bSAndroid Build Coastguard Worker     return Void();
2776*062a843bSAndroid Build Coastguard Worker }
2777*062a843bSAndroid Build Coastguard Worker 
setSimCardPower(int32_t serial,bool powerUp)2778*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2779*062a843bSAndroid Build Coastguard Worker #if VDBG
2780*062a843bSAndroid Build Coastguard Worker     RLOGD("setSimCardPower: serial %d", serial);
2781*062a843bSAndroid Build Coastguard Worker #endif
2782*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2783*062a843bSAndroid Build Coastguard Worker     return Void();
2784*062a843bSAndroid Build Coastguard Worker }
2785*062a843bSAndroid Build Coastguard Worker 
setSimCardPower_1_1(int32_t serial,const V1_1::CardPowerState state)2786*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
2787*062a843bSAndroid Build Coastguard Worker #if VDBG
2788*062a843bSAndroid Build Coastguard Worker     RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2789*062a843bSAndroid Build Coastguard Worker #endif
2790*062a843bSAndroid Build Coastguard Worker     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2791*062a843bSAndroid Build Coastguard Worker     return Void();
2792*062a843bSAndroid Build Coastguard Worker }
2793*062a843bSAndroid Build Coastguard Worker 
setCarrierInfoForImsiEncryption(int32_t serial,const V1_1::ImsiEncryptionInfo & data)2794*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2795*062a843bSAndroid Build Coastguard Worker         const V1_1::ImsiEncryptionInfo& data) {
2796*062a843bSAndroid Build Coastguard Worker #if VDBG
2797*062a843bSAndroid Build Coastguard Worker     RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2798*062a843bSAndroid Build Coastguard Worker #endif
2799*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(
2800*062a843bSAndroid Build Coastguard Worker             serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2801*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2802*062a843bSAndroid Build Coastguard Worker         return Void();
2803*062a843bSAndroid Build Coastguard Worker     }
2804*062a843bSAndroid Build Coastguard Worker 
2805*062a843bSAndroid Build Coastguard Worker     RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2806*062a843bSAndroid Build Coastguard Worker 
2807*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2808*062a843bSAndroid Build Coastguard Worker         return Void();
2809*062a843bSAndroid Build Coastguard Worker     }
2810*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2811*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(1, imsiEncryption.mnc);
2812*062a843bSAndroid Build Coastguard Worker         return Void();
2813*062a843bSAndroid Build Coastguard Worker     }
2814*062a843bSAndroid Build Coastguard Worker     if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2815*062a843bSAndroid Build Coastguard Worker         memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2816*062a843bSAndroid Build Coastguard Worker         return Void();
2817*062a843bSAndroid Build Coastguard Worker     }
2818*062a843bSAndroid Build Coastguard Worker     imsiEncryption.carrierKeyLength = data.carrierKey.size();
2819*062a843bSAndroid Build Coastguard Worker     imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
2820*062a843bSAndroid Build Coastguard Worker     memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), imsiEncryption.carrierKeyLength);
2821*062a843bSAndroid Build Coastguard Worker     imsiEncryption.expirationTime = data.expirationTime;
2822*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
2823*062a843bSAndroid Build Coastguard Worker             sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
2824*062a843bSAndroid Build Coastguard Worker     delete[](imsiEncryption.carrierKey);
2825*062a843bSAndroid Build Coastguard Worker     return Void();
2826*062a843bSAndroid Build Coastguard Worker }
2827*062a843bSAndroid Build Coastguard Worker 
startKeepalive(int32_t serial,const V1_1::KeepaliveRequest & keepalive)2828*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
2829*062a843bSAndroid Build Coastguard Worker #if VDBG
2830*062a843bSAndroid Build Coastguard Worker     RLOGD("%s(): %d", __FUNCTION__, serial);
2831*062a843bSAndroid Build Coastguard Worker #endif
2832*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
2833*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2834*062a843bSAndroid Build Coastguard Worker         return Void();
2835*062a843bSAndroid Build Coastguard Worker     }
2836*062a843bSAndroid Build Coastguard Worker 
2837*062a843bSAndroid Build Coastguard Worker     RIL_KeepaliveRequest kaReq = {};
2838*062a843bSAndroid Build Coastguard Worker 
2839*062a843bSAndroid Build Coastguard Worker     kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
2840*062a843bSAndroid Build Coastguard Worker     switch(kaReq.type) {
2841*062a843bSAndroid Build Coastguard Worker         case NATT_IPV4:
2842*062a843bSAndroid Build Coastguard Worker             if (keepalive.sourceAddress.size() != 4 ||
2843*062a843bSAndroid Build Coastguard Worker                     keepalive.destinationAddress.size() != 4) {
2844*062a843bSAndroid Build Coastguard Worker                 RLOGE("Invalid address for keepalive!");
2845*062a843bSAndroid Build Coastguard Worker                 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2846*062a843bSAndroid Build Coastguard Worker                 return Void();
2847*062a843bSAndroid Build Coastguard Worker             }
2848*062a843bSAndroid Build Coastguard Worker             break;
2849*062a843bSAndroid Build Coastguard Worker         case NATT_IPV6:
2850*062a843bSAndroid Build Coastguard Worker             if (keepalive.sourceAddress.size() != 16 ||
2851*062a843bSAndroid Build Coastguard Worker                     keepalive.destinationAddress.size() != 16) {
2852*062a843bSAndroid Build Coastguard Worker                 RLOGE("Invalid address for keepalive!");
2853*062a843bSAndroid Build Coastguard Worker                 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2854*062a843bSAndroid Build Coastguard Worker                 return Void();
2855*062a843bSAndroid Build Coastguard Worker             }
2856*062a843bSAndroid Build Coastguard Worker             break;
2857*062a843bSAndroid Build Coastguard Worker         default:
2858*062a843bSAndroid Build Coastguard Worker             RLOGE("Unknown packet keepalive type!");
2859*062a843bSAndroid Build Coastguard Worker             sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2860*062a843bSAndroid Build Coastguard Worker             return Void();
2861*062a843bSAndroid Build Coastguard Worker     }
2862*062a843bSAndroid Build Coastguard Worker 
2863*062a843bSAndroid Build Coastguard Worker     ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
2864*062a843bSAndroid Build Coastguard Worker     kaReq.sourcePort = keepalive.sourcePort;
2865*062a843bSAndroid Build Coastguard Worker 
2866*062a843bSAndroid Build Coastguard Worker     ::memcpy(kaReq.destinationAddress,
2867*062a843bSAndroid Build Coastguard Worker             keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
2868*062a843bSAndroid Build Coastguard Worker     kaReq.destinationPort = keepalive.destinationPort;
2869*062a843bSAndroid Build Coastguard Worker 
2870*062a843bSAndroid Build Coastguard Worker     kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
2871*062a843bSAndroid Build Coastguard Worker     kaReq.cid = keepalive.cid; // This is the context ID of the data call
2872*062a843bSAndroid Build Coastguard Worker 
2873*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
2874*062a843bSAndroid Build Coastguard Worker     return Void();
2875*062a843bSAndroid Build Coastguard Worker }
2876*062a843bSAndroid Build Coastguard Worker 
stopKeepalive(int32_t serial,int32_t sessionHandle)2877*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2878*062a843bSAndroid Build Coastguard Worker #if VDBG
2879*062a843bSAndroid Build Coastguard Worker     RLOGD("%s(): %d", __FUNCTION__, serial);
2880*062a843bSAndroid Build Coastguard Worker #endif
2881*062a843bSAndroid Build Coastguard Worker     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE);
2882*062a843bSAndroid Build Coastguard Worker     if (pRI == NULL) {
2883*062a843bSAndroid Build Coastguard Worker         return Void();
2884*062a843bSAndroid Build Coastguard Worker     }
2885*062a843bSAndroid Build Coastguard Worker 
2886*062a843bSAndroid Build Coastguard Worker     CALL_ONREQUEST(pRI->pCI->requestNumber, &sessionHandle, sizeof(uint32_t), pRI, mSlotId);
2887*062a843bSAndroid Build Coastguard Worker     return Void();
2888*062a843bSAndroid Build Coastguard Worker }
2889*062a843bSAndroid Build Coastguard Worker 
responseAcknowledgement()2890*062a843bSAndroid Build Coastguard Worker Return<void> RadioImpl::responseAcknowledgement() {
2891*062a843bSAndroid Build Coastguard Worker     android::releaseWakeLock();
2892*062a843bSAndroid Build Coastguard Worker     return Void();
2893*062a843bSAndroid Build Coastguard Worker }
2894*062a843bSAndroid Build Coastguard Worker 
2895*062a843bSAndroid Build Coastguard Worker /***************************************************************************************************
2896*062a843bSAndroid Build Coastguard Worker  * RESPONSE FUNCTIONS
2897*062a843bSAndroid Build Coastguard Worker  * Functions above are used for requests going from framework to vendor code. The ones below are
2898*062a843bSAndroid Build Coastguard Worker  * responses for those requests coming back from the vendor code.
2899*062a843bSAndroid Build Coastguard Worker  **************************************************************************************************/
2900*062a843bSAndroid Build Coastguard Worker 
acknowledgeRequest(int slotId,int serial)2901*062a843bSAndroid Build Coastguard Worker void radio::acknowledgeRequest(int slotId, int serial) {
2902*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
2903*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2904*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
2905*062a843bSAndroid Build Coastguard Worker     } else {
2906*062a843bSAndroid Build Coastguard Worker         RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2907*062a843bSAndroid Build Coastguard Worker     }
2908*062a843bSAndroid Build Coastguard Worker }
2909*062a843bSAndroid Build Coastguard Worker 
populateResponseInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)2910*062a843bSAndroid Build Coastguard Worker void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2911*062a843bSAndroid Build Coastguard Worker                          RIL_Errno e) {
2912*062a843bSAndroid Build Coastguard Worker     responseInfo.serial = serial;
2913*062a843bSAndroid Build Coastguard Worker     switch (responseType) {
2914*062a843bSAndroid Build Coastguard Worker         case RESPONSE_SOLICITED:
2915*062a843bSAndroid Build Coastguard Worker             responseInfo.type = RadioResponseType::SOLICITED;
2916*062a843bSAndroid Build Coastguard Worker             break;
2917*062a843bSAndroid Build Coastguard Worker         case RESPONSE_SOLICITED_ACK_EXP:
2918*062a843bSAndroid Build Coastguard Worker             responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2919*062a843bSAndroid Build Coastguard Worker             break;
2920*062a843bSAndroid Build Coastguard Worker     }
2921*062a843bSAndroid Build Coastguard Worker     responseInfo.error = (RadioError) e;
2922*062a843bSAndroid Build Coastguard Worker }
2923*062a843bSAndroid Build Coastguard Worker 
responseIntOrEmpty(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)2924*062a843bSAndroid Build Coastguard Worker int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2925*062a843bSAndroid Build Coastguard Worker                void *response, size_t responseLen) {
2926*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
2927*062a843bSAndroid Build Coastguard Worker     int ret = -1;
2928*062a843bSAndroid Build Coastguard Worker 
2929*062a843bSAndroid Build Coastguard Worker     if (response == NULL && responseLen == 0) {
2930*062a843bSAndroid Build Coastguard Worker         // Earlier RILs did not send a response for some cases although the interface
2931*062a843bSAndroid Build Coastguard Worker         // expected an integer as response. Do not return error if response is empty. Instead
2932*062a843bSAndroid Build Coastguard Worker         // Return -1 in those cases to maintain backward compatibility.
2933*062a843bSAndroid Build Coastguard Worker     } else if (response == NULL || responseLen != sizeof(int)) {
2934*062a843bSAndroid Build Coastguard Worker         RLOGE("responseIntOrEmpty: Invalid response");
2935*062a843bSAndroid Build Coastguard Worker         if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2936*062a843bSAndroid Build Coastguard Worker     } else {
2937*062a843bSAndroid Build Coastguard Worker         int *p_int = (int *) response;
2938*062a843bSAndroid Build Coastguard Worker         ret = p_int[0];
2939*062a843bSAndroid Build Coastguard Worker     }
2940*062a843bSAndroid Build Coastguard Worker     return ret;
2941*062a843bSAndroid Build Coastguard Worker }
2942*062a843bSAndroid Build Coastguard Worker 
responseInt(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)2943*062a843bSAndroid Build Coastguard Worker int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2944*062a843bSAndroid Build Coastguard Worker                void *response, size_t responseLen) {
2945*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
2946*062a843bSAndroid Build Coastguard Worker     int ret = -1;
2947*062a843bSAndroid Build Coastguard Worker 
2948*062a843bSAndroid Build Coastguard Worker     if (response == NULL || responseLen != sizeof(int)) {
2949*062a843bSAndroid Build Coastguard Worker         RLOGE("responseInt: Invalid response");
2950*062a843bSAndroid Build Coastguard Worker         if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2951*062a843bSAndroid Build Coastguard Worker     } else {
2952*062a843bSAndroid Build Coastguard Worker         int *p_int = (int *) response;
2953*062a843bSAndroid Build Coastguard Worker         ret = p_int[0];
2954*062a843bSAndroid Build Coastguard Worker     }
2955*062a843bSAndroid Build Coastguard Worker     return ret;
2956*062a843bSAndroid Build Coastguard Worker }
2957*062a843bSAndroid Build Coastguard Worker 
getIccCardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)2958*062a843bSAndroid Build Coastguard Worker int radio::getIccCardStatusResponse(int slotId,
2959*062a843bSAndroid Build Coastguard Worker                                    int responseType, int serial, RIL_Errno e,
2960*062a843bSAndroid Build Coastguard Worker                                    void *response, size_t responseLen) {
2961*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
2962*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
2963*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
2964*062a843bSAndroid Build Coastguard Worker         CardStatus cardStatus = {CardState::ABSENT, PinState::UNKNOWN, -1, -1, -1, {}};
2965*062a843bSAndroid Build Coastguard Worker         RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2966*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
2967*062a843bSAndroid Build Coastguard Worker                 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
2968*062a843bSAndroid Build Coastguard Worker                 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
2969*062a843bSAndroid Build Coastguard Worker                 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
2970*062a843bSAndroid Build Coastguard Worker             RLOGE("getIccCardStatusResponse: Invalid response");
2971*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2972*062a843bSAndroid Build Coastguard Worker         } else {
2973*062a843bSAndroid Build Coastguard Worker             cardStatus.cardState = (CardState) p_cur->card_state;
2974*062a843bSAndroid Build Coastguard Worker             cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2975*062a843bSAndroid Build Coastguard Worker             cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2976*062a843bSAndroid Build Coastguard Worker             cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2977*062a843bSAndroid Build Coastguard Worker             cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2978*062a843bSAndroid Build Coastguard Worker 
2979*062a843bSAndroid Build Coastguard Worker             RIL_AppStatus *rilAppStatus = p_cur->applications;
2980*062a843bSAndroid Build Coastguard Worker             cardStatus.applications.resize(p_cur->num_applications);
2981*062a843bSAndroid Build Coastguard Worker             AppStatus *appStatus = cardStatus.applications.data();
2982*062a843bSAndroid Build Coastguard Worker #if VDBG
2983*062a843bSAndroid Build Coastguard Worker             RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2984*062a843bSAndroid Build Coastguard Worker #endif
2985*062a843bSAndroid Build Coastguard Worker             for (int i = 0; i < p_cur->num_applications; i++) {
2986*062a843bSAndroid Build Coastguard Worker                 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2987*062a843bSAndroid Build Coastguard Worker                 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2988*062a843bSAndroid Build Coastguard Worker                 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2989*062a843bSAndroid Build Coastguard Worker                 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2990*062a843bSAndroid Build Coastguard Worker                 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2991*062a843bSAndroid Build Coastguard Worker                         rilAppStatus[i].app_label_ptr);
2992*062a843bSAndroid Build Coastguard Worker                 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2993*062a843bSAndroid Build Coastguard Worker                 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2994*062a843bSAndroid Build Coastguard Worker                 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2995*062a843bSAndroid Build Coastguard Worker             }
2996*062a843bSAndroid Build Coastguard Worker         }
2997*062a843bSAndroid Build Coastguard Worker 
2998*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
2999*062a843bSAndroid Build Coastguard Worker                 getIccCardStatusResponse(responseInfo, cardStatus);
3000*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3001*062a843bSAndroid Build Coastguard Worker     } else {
3002*062a843bSAndroid Build Coastguard Worker         RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3003*062a843bSAndroid Build Coastguard Worker     }
3004*062a843bSAndroid Build Coastguard Worker 
3005*062a843bSAndroid Build Coastguard Worker     return 0;
3006*062a843bSAndroid Build Coastguard Worker }
3007*062a843bSAndroid Build Coastguard Worker 
supplyIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3008*062a843bSAndroid Build Coastguard Worker int radio::supplyIccPinForAppResponse(int slotId,
3009*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
3010*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
3011*062a843bSAndroid Build Coastguard Worker #if VDBG
3012*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPinForAppResponse: serial %d", serial);
3013*062a843bSAndroid Build Coastguard Worker #endif
3014*062a843bSAndroid Build Coastguard Worker 
3015*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3016*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3017*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3018*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
3019*062a843bSAndroid Build Coastguard Worker                 supplyIccPinForAppResponse(responseInfo, ret);
3020*062a843bSAndroid Build Coastguard Worker         RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
3021*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3022*062a843bSAndroid Build Coastguard Worker     } else {
3023*062a843bSAndroid Build Coastguard Worker         RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3024*062a843bSAndroid Build Coastguard Worker                 slotId);
3025*062a843bSAndroid Build Coastguard Worker     }
3026*062a843bSAndroid Build Coastguard Worker 
3027*062a843bSAndroid Build Coastguard Worker     return 0;
3028*062a843bSAndroid Build Coastguard Worker }
3029*062a843bSAndroid Build Coastguard Worker 
supplyIccPukForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3030*062a843bSAndroid Build Coastguard Worker int radio::supplyIccPukForAppResponse(int slotId,
3031*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
3032*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
3033*062a843bSAndroid Build Coastguard Worker #if VDBG
3034*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPukForAppResponse: serial %d", serial);
3035*062a843bSAndroid Build Coastguard Worker #endif
3036*062a843bSAndroid Build Coastguard Worker 
3037*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3038*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3039*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3040*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
3041*062a843bSAndroid Build Coastguard Worker                 responseInfo, ret);
3042*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3043*062a843bSAndroid Build Coastguard Worker     } else {
3044*062a843bSAndroid Build Coastguard Worker         RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
3045*062a843bSAndroid Build Coastguard Worker                 slotId);
3046*062a843bSAndroid Build Coastguard Worker     }
3047*062a843bSAndroid Build Coastguard Worker 
3048*062a843bSAndroid Build Coastguard Worker     return 0;
3049*062a843bSAndroid Build Coastguard Worker }
3050*062a843bSAndroid Build Coastguard Worker 
supplyIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3051*062a843bSAndroid Build Coastguard Worker int radio::supplyIccPin2ForAppResponse(int slotId,
3052*062a843bSAndroid Build Coastguard Worker                                       int responseType, int serial, RIL_Errno e,
3053*062a843bSAndroid Build Coastguard Worker                                       void *response, size_t responseLen) {
3054*062a843bSAndroid Build Coastguard Worker #if VDBG
3055*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
3056*062a843bSAndroid Build Coastguard Worker #endif
3057*062a843bSAndroid Build Coastguard Worker 
3058*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3059*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3060*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3061*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
3062*062a843bSAndroid Build Coastguard Worker                 supplyIccPin2ForAppResponse(responseInfo, ret);
3063*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3064*062a843bSAndroid Build Coastguard Worker     } else {
3065*062a843bSAndroid Build Coastguard Worker         RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3066*062a843bSAndroid Build Coastguard Worker                 slotId);
3067*062a843bSAndroid Build Coastguard Worker     }
3068*062a843bSAndroid Build Coastguard Worker 
3069*062a843bSAndroid Build Coastguard Worker     return 0;
3070*062a843bSAndroid Build Coastguard Worker }
3071*062a843bSAndroid Build Coastguard Worker 
supplyIccPuk2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3072*062a843bSAndroid Build Coastguard Worker int radio::supplyIccPuk2ForAppResponse(int slotId,
3073*062a843bSAndroid Build Coastguard Worker                                       int responseType, int serial, RIL_Errno e,
3074*062a843bSAndroid Build Coastguard Worker                                       void *response, size_t responseLen) {
3075*062a843bSAndroid Build Coastguard Worker #if VDBG
3076*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3077*062a843bSAndroid Build Coastguard Worker #endif
3078*062a843bSAndroid Build Coastguard Worker 
3079*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3080*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3081*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3082*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
3083*062a843bSAndroid Build Coastguard Worker                 supplyIccPuk2ForAppResponse(responseInfo, ret);
3084*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3085*062a843bSAndroid Build Coastguard Worker     } else {
3086*062a843bSAndroid Build Coastguard Worker         RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3087*062a843bSAndroid Build Coastguard Worker                 slotId);
3088*062a843bSAndroid Build Coastguard Worker     }
3089*062a843bSAndroid Build Coastguard Worker 
3090*062a843bSAndroid Build Coastguard Worker     return 0;
3091*062a843bSAndroid Build Coastguard Worker }
3092*062a843bSAndroid Build Coastguard Worker 
changeIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3093*062a843bSAndroid Build Coastguard Worker int radio::changeIccPinForAppResponse(int slotId,
3094*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
3095*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
3096*062a843bSAndroid Build Coastguard Worker #if VDBG
3097*062a843bSAndroid Build Coastguard Worker     RLOGD("changeIccPinForAppResponse: serial %d", serial);
3098*062a843bSAndroid Build Coastguard Worker #endif
3099*062a843bSAndroid Build Coastguard Worker 
3100*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3101*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3102*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3103*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
3104*062a843bSAndroid Build Coastguard Worker                 changeIccPinForAppResponse(responseInfo, ret);
3105*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3106*062a843bSAndroid Build Coastguard Worker     } else {
3107*062a843bSAndroid Build Coastguard Worker         RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3108*062a843bSAndroid Build Coastguard Worker                 slotId);
3109*062a843bSAndroid Build Coastguard Worker     }
3110*062a843bSAndroid Build Coastguard Worker 
3111*062a843bSAndroid Build Coastguard Worker     return 0;
3112*062a843bSAndroid Build Coastguard Worker }
3113*062a843bSAndroid Build Coastguard Worker 
changeIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3114*062a843bSAndroid Build Coastguard Worker int radio::changeIccPin2ForAppResponse(int slotId,
3115*062a843bSAndroid Build Coastguard Worker                                       int responseType, int serial, RIL_Errno e,
3116*062a843bSAndroid Build Coastguard Worker                                       void *response, size_t responseLen) {
3117*062a843bSAndroid Build Coastguard Worker #if VDBG
3118*062a843bSAndroid Build Coastguard Worker     RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3119*062a843bSAndroid Build Coastguard Worker #endif
3120*062a843bSAndroid Build Coastguard Worker 
3121*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3122*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3123*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3124*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
3125*062a843bSAndroid Build Coastguard Worker                 changeIccPin2ForAppResponse(responseInfo, ret);
3126*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3127*062a843bSAndroid Build Coastguard Worker     } else {
3128*062a843bSAndroid Build Coastguard Worker         RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3129*062a843bSAndroid Build Coastguard Worker                 slotId);
3130*062a843bSAndroid Build Coastguard Worker     }
3131*062a843bSAndroid Build Coastguard Worker 
3132*062a843bSAndroid Build Coastguard Worker     return 0;
3133*062a843bSAndroid Build Coastguard Worker }
3134*062a843bSAndroid Build Coastguard Worker 
supplyNetworkDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3135*062a843bSAndroid Build Coastguard Worker int radio::supplyNetworkDepersonalizationResponse(int slotId,
3136*062a843bSAndroid Build Coastguard Worker                                                  int responseType, int serial, RIL_Errno e,
3137*062a843bSAndroid Build Coastguard Worker                                                  void *response, size_t responseLen) {
3138*062a843bSAndroid Build Coastguard Worker #if VDBG
3139*062a843bSAndroid Build Coastguard Worker     RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3140*062a843bSAndroid Build Coastguard Worker #endif
3141*062a843bSAndroid Build Coastguard Worker 
3142*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3143*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3144*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3145*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
3146*062a843bSAndroid Build Coastguard Worker                 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3147*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3148*062a843bSAndroid Build Coastguard Worker     } else {
3149*062a843bSAndroid Build Coastguard Worker         RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3150*062a843bSAndroid Build Coastguard Worker                 "NULL", slotId);
3151*062a843bSAndroid Build Coastguard Worker     }
3152*062a843bSAndroid Build Coastguard Worker 
3153*062a843bSAndroid Build Coastguard Worker     return 0;
3154*062a843bSAndroid Build Coastguard Worker }
3155*062a843bSAndroid Build Coastguard Worker 
getCurrentCallsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3156*062a843bSAndroid Build Coastguard Worker int radio::getCurrentCallsResponse(int slotId,
3157*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
3158*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
3159*062a843bSAndroid Build Coastguard Worker #if VDBG
3160*062a843bSAndroid Build Coastguard Worker     RLOGD("getCurrentCallsResponse: serial %d", serial);
3161*062a843bSAndroid Build Coastguard Worker #endif
3162*062a843bSAndroid Build Coastguard Worker 
3163*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3164*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3165*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3166*062a843bSAndroid Build Coastguard Worker 
3167*062a843bSAndroid Build Coastguard Worker         hidl_vec<Call> calls;
3168*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
3169*062a843bSAndroid Build Coastguard Worker                 || (responseLen % sizeof(RIL_Call *)) != 0) {
3170*062a843bSAndroid Build Coastguard Worker             RLOGE("getCurrentCallsResponse: Invalid response");
3171*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3172*062a843bSAndroid Build Coastguard Worker         } else {
3173*062a843bSAndroid Build Coastguard Worker             int num = responseLen / sizeof(RIL_Call *);
3174*062a843bSAndroid Build Coastguard Worker             calls.resize(num);
3175*062a843bSAndroid Build Coastguard Worker 
3176*062a843bSAndroid Build Coastguard Worker             for (int i = 0 ; i < num ; i++) {
3177*062a843bSAndroid Build Coastguard Worker                 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3178*062a843bSAndroid Build Coastguard Worker                 /* each call info */
3179*062a843bSAndroid Build Coastguard Worker                 calls[i].state = (CallState) p_cur->state;
3180*062a843bSAndroid Build Coastguard Worker                 calls[i].index = p_cur->index;
3181*062a843bSAndroid Build Coastguard Worker                 calls[i].toa = p_cur->toa;
3182*062a843bSAndroid Build Coastguard Worker                 calls[i].isMpty = p_cur->isMpty;
3183*062a843bSAndroid Build Coastguard Worker                 calls[i].isMT = p_cur->isMT;
3184*062a843bSAndroid Build Coastguard Worker                 calls[i].als = p_cur->als;
3185*062a843bSAndroid Build Coastguard Worker                 calls[i].isVoice = p_cur->isVoice;
3186*062a843bSAndroid Build Coastguard Worker                 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3187*062a843bSAndroid Build Coastguard Worker                 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3188*062a843bSAndroid Build Coastguard Worker                 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3189*062a843bSAndroid Build Coastguard Worker                 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3190*062a843bSAndroid Build Coastguard Worker                 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3191*062a843bSAndroid Build Coastguard Worker                 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3192*062a843bSAndroid Build Coastguard Worker                     RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3193*062a843bSAndroid Build Coastguard Worker                     calls[i].uusInfo.resize(1);
3194*062a843bSAndroid Build Coastguard Worker                     calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3195*062a843bSAndroid Build Coastguard Worker                     calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3196*062a843bSAndroid Build Coastguard Worker                     // convert uusInfo->uusData to a null-terminated string
3197*062a843bSAndroid Build Coastguard Worker                     char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3198*062a843bSAndroid Build Coastguard Worker                     calls[i].uusInfo[0].uusData = nullTermStr;
3199*062a843bSAndroid Build Coastguard Worker                     free(nullTermStr);
3200*062a843bSAndroid Build Coastguard Worker                 }
3201*062a843bSAndroid Build Coastguard Worker             }
3202*062a843bSAndroid Build Coastguard Worker         }
3203*062a843bSAndroid Build Coastguard Worker 
3204*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
3205*062a843bSAndroid Build Coastguard Worker                 getCurrentCallsResponse(responseInfo, calls);
3206*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3207*062a843bSAndroid Build Coastguard Worker     } else {
3208*062a843bSAndroid Build Coastguard Worker         RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3209*062a843bSAndroid Build Coastguard Worker     }
3210*062a843bSAndroid Build Coastguard Worker 
3211*062a843bSAndroid Build Coastguard Worker     return 0;
3212*062a843bSAndroid Build Coastguard Worker }
3213*062a843bSAndroid Build Coastguard Worker 
dialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3214*062a843bSAndroid Build Coastguard Worker int radio::dialResponse(int slotId,
3215*062a843bSAndroid Build Coastguard Worker                        int responseType, int serial, RIL_Errno e, void *response,
3216*062a843bSAndroid Build Coastguard Worker                        size_t responseLen) {
3217*062a843bSAndroid Build Coastguard Worker #if VDBG
3218*062a843bSAndroid Build Coastguard Worker     RLOGD("dialResponse: serial %d", serial);
3219*062a843bSAndroid Build Coastguard Worker #endif
3220*062a843bSAndroid Build Coastguard Worker 
3221*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3222*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3223*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3224*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3225*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3226*062a843bSAndroid Build Coastguard Worker     } else {
3227*062a843bSAndroid Build Coastguard Worker         RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3228*062a843bSAndroid Build Coastguard Worker     }
3229*062a843bSAndroid Build Coastguard Worker 
3230*062a843bSAndroid Build Coastguard Worker     return 0;
3231*062a843bSAndroid Build Coastguard Worker }
3232*062a843bSAndroid Build Coastguard Worker 
getIMSIForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3233*062a843bSAndroid Build Coastguard Worker int radio::getIMSIForAppResponse(int slotId,
3234*062a843bSAndroid Build Coastguard Worker                                 int responseType, int serial, RIL_Errno e, void *response,
3235*062a843bSAndroid Build Coastguard Worker                                 size_t responseLen) {
3236*062a843bSAndroid Build Coastguard Worker #if VDBG
3237*062a843bSAndroid Build Coastguard Worker     RLOGD("getIMSIForAppResponse: serial %d", serial);
3238*062a843bSAndroid Build Coastguard Worker #endif
3239*062a843bSAndroid Build Coastguard Worker 
3240*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3241*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3242*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3243*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3244*062a843bSAndroid Build Coastguard Worker                 responseInfo, convertCharPtrToHidlString((char *) response));
3245*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3246*062a843bSAndroid Build Coastguard Worker     } else {
3247*062a843bSAndroid Build Coastguard Worker         RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3248*062a843bSAndroid Build Coastguard Worker                 slotId);
3249*062a843bSAndroid Build Coastguard Worker     }
3250*062a843bSAndroid Build Coastguard Worker 
3251*062a843bSAndroid Build Coastguard Worker     return 0;
3252*062a843bSAndroid Build Coastguard Worker }
3253*062a843bSAndroid Build Coastguard Worker 
hangupConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3254*062a843bSAndroid Build Coastguard Worker int radio::hangupConnectionResponse(int slotId,
3255*062a843bSAndroid Build Coastguard Worker                                    int responseType, int serial, RIL_Errno e,
3256*062a843bSAndroid Build Coastguard Worker                                    void *response, size_t responseLen) {
3257*062a843bSAndroid Build Coastguard Worker #if VDBG
3258*062a843bSAndroid Build Coastguard Worker     RLOGD("hangupConnectionResponse: serial %d", serial);
3259*062a843bSAndroid Build Coastguard Worker #endif
3260*062a843bSAndroid Build Coastguard Worker 
3261*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3262*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3263*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3264*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3265*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3266*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3267*062a843bSAndroid Build Coastguard Worker     } else {
3268*062a843bSAndroid Build Coastguard Worker         RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3269*062a843bSAndroid Build Coastguard Worker                 slotId);
3270*062a843bSAndroid Build Coastguard Worker     }
3271*062a843bSAndroid Build Coastguard Worker 
3272*062a843bSAndroid Build Coastguard Worker     return 0;
3273*062a843bSAndroid Build Coastguard Worker }
3274*062a843bSAndroid Build Coastguard Worker 
hangupWaitingOrBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3275*062a843bSAndroid Build Coastguard Worker int radio::hangupWaitingOrBackgroundResponse(int slotId,
3276*062a843bSAndroid Build Coastguard Worker                                             int responseType, int serial, RIL_Errno e,
3277*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
3278*062a843bSAndroid Build Coastguard Worker #if VDBG
3279*062a843bSAndroid Build Coastguard Worker     RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3280*062a843bSAndroid Build Coastguard Worker #endif
3281*062a843bSAndroid Build Coastguard Worker 
3282*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3283*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3284*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3285*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus =
3286*062a843bSAndroid Build Coastguard Worker                 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3287*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3288*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3289*062a843bSAndroid Build Coastguard Worker     } else {
3290*062a843bSAndroid Build Coastguard Worker         RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3291*062a843bSAndroid Build Coastguard Worker                 slotId);
3292*062a843bSAndroid Build Coastguard Worker     }
3293*062a843bSAndroid Build Coastguard Worker 
3294*062a843bSAndroid Build Coastguard Worker     return 0;
3295*062a843bSAndroid Build Coastguard Worker }
3296*062a843bSAndroid Build Coastguard Worker 
hangupForegroundResumeBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3297*062a843bSAndroid Build Coastguard Worker int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3298*062a843bSAndroid Build Coastguard Worker                                                     RIL_Errno e, void *response,
3299*062a843bSAndroid Build Coastguard Worker                                                     size_t responseLen) {
3300*062a843bSAndroid Build Coastguard Worker #if VDBG
3301*062a843bSAndroid Build Coastguard Worker     RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3302*062a843bSAndroid Build Coastguard Worker #endif
3303*062a843bSAndroid Build Coastguard Worker 
3304*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3305*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3306*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3307*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus =
3308*062a843bSAndroid Build Coastguard Worker                 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3309*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3310*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3311*062a843bSAndroid Build Coastguard Worker     } else {
3312*062a843bSAndroid Build Coastguard Worker         RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3313*062a843bSAndroid Build Coastguard Worker                 slotId);
3314*062a843bSAndroid Build Coastguard Worker     }
3315*062a843bSAndroid Build Coastguard Worker 
3316*062a843bSAndroid Build Coastguard Worker     return 0;
3317*062a843bSAndroid Build Coastguard Worker }
3318*062a843bSAndroid Build Coastguard Worker 
switchWaitingOrHoldingAndActiveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3319*062a843bSAndroid Build Coastguard Worker int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3320*062a843bSAndroid Build Coastguard Worker                                                    RIL_Errno e, void *response,
3321*062a843bSAndroid Build Coastguard Worker                                                    size_t responseLen) {
3322*062a843bSAndroid Build Coastguard Worker #if VDBG
3323*062a843bSAndroid Build Coastguard Worker     RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3324*062a843bSAndroid Build Coastguard Worker #endif
3325*062a843bSAndroid Build Coastguard Worker 
3326*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3327*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3328*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3329*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus =
3330*062a843bSAndroid Build Coastguard Worker                 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3331*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3332*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3333*062a843bSAndroid Build Coastguard Worker     } else {
3334*062a843bSAndroid Build Coastguard Worker         RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3335*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
3336*062a843bSAndroid Build Coastguard Worker     }
3337*062a843bSAndroid Build Coastguard Worker 
3338*062a843bSAndroid Build Coastguard Worker     return 0;
3339*062a843bSAndroid Build Coastguard Worker }
3340*062a843bSAndroid Build Coastguard Worker 
conferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3341*062a843bSAndroid Build Coastguard Worker int radio::conferenceResponse(int slotId, int responseType,
3342*062a843bSAndroid Build Coastguard Worker                              int serial, RIL_Errno e, void *response, size_t responseLen) {
3343*062a843bSAndroid Build Coastguard Worker #if VDBG
3344*062a843bSAndroid Build Coastguard Worker     RLOGD("conferenceResponse: serial %d", serial);
3345*062a843bSAndroid Build Coastguard Worker #endif
3346*062a843bSAndroid Build Coastguard Worker 
3347*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3348*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3349*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3350*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3351*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3352*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3353*062a843bSAndroid Build Coastguard Worker     } else {
3354*062a843bSAndroid Build Coastguard Worker         RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3355*062a843bSAndroid Build Coastguard Worker                 slotId);
3356*062a843bSAndroid Build Coastguard Worker     }
3357*062a843bSAndroid Build Coastguard Worker 
3358*062a843bSAndroid Build Coastguard Worker     return 0;
3359*062a843bSAndroid Build Coastguard Worker }
3360*062a843bSAndroid Build Coastguard Worker 
rejectCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3361*062a843bSAndroid Build Coastguard Worker int radio::rejectCallResponse(int slotId, int responseType,
3362*062a843bSAndroid Build Coastguard Worker                              int serial, RIL_Errno e, void *response, size_t responseLen) {
3363*062a843bSAndroid Build Coastguard Worker #if VDBG
3364*062a843bSAndroid Build Coastguard Worker     RLOGD("rejectCallResponse: serial %d", serial);
3365*062a843bSAndroid Build Coastguard Worker #endif
3366*062a843bSAndroid Build Coastguard Worker 
3367*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3368*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3369*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3370*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3371*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3372*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3373*062a843bSAndroid Build Coastguard Worker     } else {
3374*062a843bSAndroid Build Coastguard Worker         RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3375*062a843bSAndroid Build Coastguard Worker                 slotId);
3376*062a843bSAndroid Build Coastguard Worker     }
3377*062a843bSAndroid Build Coastguard Worker 
3378*062a843bSAndroid Build Coastguard Worker     return 0;
3379*062a843bSAndroid Build Coastguard Worker }
3380*062a843bSAndroid Build Coastguard Worker 
getLastCallFailCauseResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3381*062a843bSAndroid Build Coastguard Worker int radio::getLastCallFailCauseResponse(int slotId,
3382*062a843bSAndroid Build Coastguard Worker                                        int responseType, int serial, RIL_Errno e, void *response,
3383*062a843bSAndroid Build Coastguard Worker                                        size_t responseLen) {
3384*062a843bSAndroid Build Coastguard Worker #if VDBG
3385*062a843bSAndroid Build Coastguard Worker     RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3386*062a843bSAndroid Build Coastguard Worker #endif
3387*062a843bSAndroid Build Coastguard Worker 
3388*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3389*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3390*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3391*062a843bSAndroid Build Coastguard Worker 
3392*062a843bSAndroid Build Coastguard Worker         LastCallFailCauseInfo info = {};
3393*062a843bSAndroid Build Coastguard Worker         info.vendorCause = hidl_string();
3394*062a843bSAndroid Build Coastguard Worker         if (response == NULL) {
3395*062a843bSAndroid Build Coastguard Worker             RLOGE("getCurrentCallsResponse Invalid response: NULL");
3396*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3397*062a843bSAndroid Build Coastguard Worker         } else if (responseLen == sizeof(int)) {
3398*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
3399*062a843bSAndroid Build Coastguard Worker             info.causeCode = (LastCallFailCause) pInt[0];
3400*062a843bSAndroid Build Coastguard Worker         } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo))  {
3401*062a843bSAndroid Build Coastguard Worker             RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3402*062a843bSAndroid Build Coastguard Worker             info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3403*062a843bSAndroid Build Coastguard Worker             info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3404*062a843bSAndroid Build Coastguard Worker         } else {
3405*062a843bSAndroid Build Coastguard Worker             RLOGE("getCurrentCallsResponse Invalid response: NULL");
3406*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3407*062a843bSAndroid Build Coastguard Worker         }
3408*062a843bSAndroid Build Coastguard Worker 
3409*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3410*062a843bSAndroid Build Coastguard Worker                 responseInfo, info);
3411*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3412*062a843bSAndroid Build Coastguard Worker     } else {
3413*062a843bSAndroid Build Coastguard Worker         RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3414*062a843bSAndroid Build Coastguard Worker                 slotId);
3415*062a843bSAndroid Build Coastguard Worker     }
3416*062a843bSAndroid Build Coastguard Worker 
3417*062a843bSAndroid Build Coastguard Worker     return 0;
3418*062a843bSAndroid Build Coastguard Worker }
3419*062a843bSAndroid Build Coastguard Worker 
getSignalStrengthResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3420*062a843bSAndroid Build Coastguard Worker int radio::getSignalStrengthResponse(int slotId,
3421*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
3422*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
3423*062a843bSAndroid Build Coastguard Worker #if VDBG
3424*062a843bSAndroid Build Coastguard Worker     RLOGD("getSignalStrengthResponse: serial %d", serial);
3425*062a843bSAndroid Build Coastguard Worker #endif
3426*062a843bSAndroid Build Coastguard Worker 
3427*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3428*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3429*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3430*062a843bSAndroid Build Coastguard Worker         SignalStrength signalStrength = {};
3431*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3432*062a843bSAndroid Build Coastguard Worker             RLOGE("getSignalStrengthResponse: Invalid response");
3433*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3434*062a843bSAndroid Build Coastguard Worker         } else {
3435*062a843bSAndroid Build Coastguard Worker             convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3436*062a843bSAndroid Build Coastguard Worker         }
3437*062a843bSAndroid Build Coastguard Worker 
3438*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3439*062a843bSAndroid Build Coastguard Worker                 responseInfo, signalStrength);
3440*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3441*062a843bSAndroid Build Coastguard Worker     } else {
3442*062a843bSAndroid Build Coastguard Worker         RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3443*062a843bSAndroid Build Coastguard Worker                 slotId);
3444*062a843bSAndroid Build Coastguard Worker     }
3445*062a843bSAndroid Build Coastguard Worker 
3446*062a843bSAndroid Build Coastguard Worker     return 0;
3447*062a843bSAndroid Build Coastguard Worker }
3448*062a843bSAndroid Build Coastguard Worker 
getCellInfoTypeRadioTechnology(char * rat)3449*062a843bSAndroid Build Coastguard Worker RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3450*062a843bSAndroid Build Coastguard Worker     if (rat == NULL) {
3451*062a843bSAndroid Build Coastguard Worker         return RIL_CELL_INFO_TYPE_NONE;
3452*062a843bSAndroid Build Coastguard Worker     }
3453*062a843bSAndroid Build Coastguard Worker 
3454*062a843bSAndroid Build Coastguard Worker     int radioTech = atoi(rat);
3455*062a843bSAndroid Build Coastguard Worker 
3456*062a843bSAndroid Build Coastguard Worker     switch(radioTech) {
3457*062a843bSAndroid Build Coastguard Worker 
3458*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_GPRS:
3459*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_EDGE:
3460*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_GSM: {
3461*062a843bSAndroid Build Coastguard Worker             return RIL_CELL_INFO_TYPE_GSM;
3462*062a843bSAndroid Build Coastguard Worker         }
3463*062a843bSAndroid Build Coastguard Worker 
3464*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_UMTS:
3465*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_HSDPA:
3466*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_HSUPA:
3467*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_HSPA:
3468*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_HSPAP: {
3469*062a843bSAndroid Build Coastguard Worker             return RIL_CELL_INFO_TYPE_WCDMA;
3470*062a843bSAndroid Build Coastguard Worker         }
3471*062a843bSAndroid Build Coastguard Worker 
3472*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_IS95A:
3473*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_IS95B:
3474*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_1xRTT:
3475*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_EVDO_0:
3476*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_EVDO_A:
3477*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_EVDO_B:
3478*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_EHRPD: {
3479*062a843bSAndroid Build Coastguard Worker             return RIL_CELL_INFO_TYPE_CDMA;
3480*062a843bSAndroid Build Coastguard Worker         }
3481*062a843bSAndroid Build Coastguard Worker 
3482*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_LTE:
3483*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_LTE_CA: {
3484*062a843bSAndroid Build Coastguard Worker             return RIL_CELL_INFO_TYPE_LTE;
3485*062a843bSAndroid Build Coastguard Worker         }
3486*062a843bSAndroid Build Coastguard Worker 
3487*062a843bSAndroid Build Coastguard Worker         case RADIO_TECH_TD_SCDMA: {
3488*062a843bSAndroid Build Coastguard Worker             return RIL_CELL_INFO_TYPE_TD_SCDMA;
3489*062a843bSAndroid Build Coastguard Worker         }
3490*062a843bSAndroid Build Coastguard Worker 
3491*062a843bSAndroid Build Coastguard Worker         default: {
3492*062a843bSAndroid Build Coastguard Worker             break;
3493*062a843bSAndroid Build Coastguard Worker         }
3494*062a843bSAndroid Build Coastguard Worker     }
3495*062a843bSAndroid Build Coastguard Worker 
3496*062a843bSAndroid Build Coastguard Worker     return RIL_CELL_INFO_TYPE_NONE;
3497*062a843bSAndroid Build Coastguard Worker 
3498*062a843bSAndroid Build Coastguard Worker }
3499*062a843bSAndroid Build Coastguard Worker 
fillCellIdentityResponse(CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)3500*062a843bSAndroid Build Coastguard Worker void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3501*062a843bSAndroid Build Coastguard Worker 
3502*062a843bSAndroid Build Coastguard Worker     cellIdentity.cellIdentityGsm.resize(0);
3503*062a843bSAndroid Build Coastguard Worker     cellIdentity.cellIdentityWcdma.resize(0);
3504*062a843bSAndroid Build Coastguard Worker     cellIdentity.cellIdentityCdma.resize(0);
3505*062a843bSAndroid Build Coastguard Worker     cellIdentity.cellIdentityTdscdma.resize(0);
3506*062a843bSAndroid Build Coastguard Worker     cellIdentity.cellIdentityLte.resize(0);
3507*062a843bSAndroid Build Coastguard Worker     cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3508*062a843bSAndroid Build Coastguard Worker     switch(rilCellIdentity.cellInfoType) {
3509*062a843bSAndroid Build Coastguard Worker 
3510*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_GSM: {
3511*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityGsm.resize(1);
3512*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityGsm[0].mcc =
3513*062a843bSAndroid Build Coastguard Worker                     ril::util::mcc::decode(rilCellIdentity.cellIdentityGsm.mcc);
3514*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityGsm[0].mnc =
3515*062a843bSAndroid Build Coastguard Worker                     ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
3516*062a843bSAndroid Build Coastguard Worker 
3517*062a843bSAndroid Build Coastguard Worker             if (cellIdentity.cellIdentityGsm[0].mcc == "-1") {
3518*062a843bSAndroid Build Coastguard Worker                 cellIdentity.cellIdentityGsm[0].mcc = "";
3519*062a843bSAndroid Build Coastguard Worker             }
3520*062a843bSAndroid Build Coastguard Worker 
3521*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3522*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3523*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3524*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3525*062a843bSAndroid Build Coastguard Worker             break;
3526*062a843bSAndroid Build Coastguard Worker         }
3527*062a843bSAndroid Build Coastguard Worker 
3528*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_WCDMA: {
3529*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityWcdma.resize(1);
3530*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityWcdma[0].mcc =
3531*062a843bSAndroid Build Coastguard Worker                     ril::util::mcc::decode(rilCellIdentity.cellIdentityWcdma.mcc);
3532*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityWcdma[0].mnc =
3533*062a843bSAndroid Build Coastguard Worker                     ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
3534*062a843bSAndroid Build Coastguard Worker 
3535*062a843bSAndroid Build Coastguard Worker             if (cellIdentity.cellIdentityWcdma[0].mcc == "-1") {
3536*062a843bSAndroid Build Coastguard Worker                 cellIdentity.cellIdentityWcdma[0].mcc = "";
3537*062a843bSAndroid Build Coastguard Worker             }
3538*062a843bSAndroid Build Coastguard Worker 
3539*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3540*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3541*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3542*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3543*062a843bSAndroid Build Coastguard Worker             break;
3544*062a843bSAndroid Build Coastguard Worker         }
3545*062a843bSAndroid Build Coastguard Worker 
3546*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_CDMA: {
3547*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityCdma.resize(1);
3548*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3549*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3550*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityCdma[0].baseStationId =
3551*062a843bSAndroid Build Coastguard Worker                     rilCellIdentity.cellIdentityCdma.basestationId;
3552*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3553*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3554*062a843bSAndroid Build Coastguard Worker             break;
3555*062a843bSAndroid Build Coastguard Worker         }
3556*062a843bSAndroid Build Coastguard Worker 
3557*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_LTE: {
3558*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityLte.resize(1);
3559*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityLte[0].mcc =
3560*062a843bSAndroid Build Coastguard Worker                     ril::util::mcc::decode(rilCellIdentity.cellIdentityLte.mcc);
3561*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityLte[0].mnc =
3562*062a843bSAndroid Build Coastguard Worker                     ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
3563*062a843bSAndroid Build Coastguard Worker 
3564*062a843bSAndroid Build Coastguard Worker             if (cellIdentity.cellIdentityLte[0].mcc == "-1") {
3565*062a843bSAndroid Build Coastguard Worker                 cellIdentity.cellIdentityLte[0].mcc = "";
3566*062a843bSAndroid Build Coastguard Worker             }
3567*062a843bSAndroid Build Coastguard Worker 
3568*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3569*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3570*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3571*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3572*062a843bSAndroid Build Coastguard Worker             break;
3573*062a843bSAndroid Build Coastguard Worker         }
3574*062a843bSAndroid Build Coastguard Worker 
3575*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3576*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityTdscdma.resize(1);
3577*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityTdscdma[0].mcc =
3578*062a843bSAndroid Build Coastguard Worker                     ril::util::mcc::decode(rilCellIdentity.cellIdentityTdscdma.mcc);
3579*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityTdscdma[0].mnc =
3580*062a843bSAndroid Build Coastguard Worker                     ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
3581*062a843bSAndroid Build Coastguard Worker 
3582*062a843bSAndroid Build Coastguard Worker             if (cellIdentity.cellIdentityTdscdma[0].mcc == "-1") {
3583*062a843bSAndroid Build Coastguard Worker                 cellIdentity.cellIdentityTdscdma[0].mcc = "";
3584*062a843bSAndroid Build Coastguard Worker             }
3585*062a843bSAndroid Build Coastguard Worker 
3586*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3587*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3588*062a843bSAndroid Build Coastguard Worker             cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3589*062a843bSAndroid Build Coastguard Worker             break;
3590*062a843bSAndroid Build Coastguard Worker         }
3591*062a843bSAndroid Build Coastguard Worker 
3592*062a843bSAndroid Build Coastguard Worker         default: {
3593*062a843bSAndroid Build Coastguard Worker             break;
3594*062a843bSAndroid Build Coastguard Worker         }
3595*062a843bSAndroid Build Coastguard Worker     }
3596*062a843bSAndroid Build Coastguard Worker }
3597*062a843bSAndroid Build Coastguard Worker 
convertResponseStringEntryToInt(char ** response,int index,int numStrings)3598*062a843bSAndroid Build Coastguard Worker int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3599*062a843bSAndroid Build Coastguard Worker     if ((response != NULL) &&  (numStrings > index) && (response[index] != NULL)) {
3600*062a843bSAndroid Build Coastguard Worker         return atoi(response[index]);
3601*062a843bSAndroid Build Coastguard Worker     }
3602*062a843bSAndroid Build Coastguard Worker 
3603*062a843bSAndroid Build Coastguard Worker     return -1;
3604*062a843bSAndroid Build Coastguard Worker }
3605*062a843bSAndroid Build Coastguard Worker 
convertResponseHexStringEntryToInt(char ** response,int index,int numStrings)3606*062a843bSAndroid Build Coastguard Worker int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3607*062a843bSAndroid Build Coastguard Worker     const int hexBase = 16;
3608*062a843bSAndroid Build Coastguard Worker     if ((response != NULL) &&  (numStrings > index) && (response[index] != NULL)) {
3609*062a843bSAndroid Build Coastguard Worker         return strtol(response[index], NULL, hexBase);
3610*062a843bSAndroid Build Coastguard Worker     }
3611*062a843bSAndroid Build Coastguard Worker 
3612*062a843bSAndroid Build Coastguard Worker     return -1;
3613*062a843bSAndroid Build Coastguard Worker }
3614*062a843bSAndroid Build Coastguard Worker 
3615*062a843bSAndroid Build Coastguard Worker /* Fill Cell Identity info from Voice Registration State Response.
3616*062a843bSAndroid Build Coastguard Worker  * This fucntion is applicable only for RIL Version < 15.
3617*062a843bSAndroid Build Coastguard Worker  * Response is a  "char **".
3618*062a843bSAndroid Build Coastguard Worker  * First and Second entries are in hex string format
3619*062a843bSAndroid Build Coastguard Worker  * and rest are integers represented in ascii format. */
fillCellIdentityFromVoiceRegStateResponseString(CellIdentity & cellIdentity,int numStrings,char ** response)3620*062a843bSAndroid Build Coastguard Worker void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3621*062a843bSAndroid Build Coastguard Worker         int numStrings, char** response) {
3622*062a843bSAndroid Build Coastguard Worker 
3623*062a843bSAndroid Build Coastguard Worker     RIL_CellIdentity_v16 rilCellIdentity;
3624*062a843bSAndroid Build Coastguard Worker     memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3625*062a843bSAndroid Build Coastguard Worker 
3626*062a843bSAndroid Build Coastguard Worker     rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3627*062a843bSAndroid Build Coastguard Worker     switch(rilCellIdentity.cellInfoType) {
3628*062a843bSAndroid Build Coastguard Worker 
3629*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_GSM: {
3630*062a843bSAndroid Build Coastguard Worker             /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3631*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityGsm.lac =
3632*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 1, numStrings);
3633*062a843bSAndroid Build Coastguard Worker 
3634*062a843bSAndroid Build Coastguard Worker             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3635*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityGsm.cid =
3636*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 2, numStrings);
3637*062a843bSAndroid Build Coastguard Worker             break;
3638*062a843bSAndroid Build Coastguard Worker         }
3639*062a843bSAndroid Build Coastguard Worker 
3640*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_WCDMA: {
3641*062a843bSAndroid Build Coastguard Worker             /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3642*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityWcdma.lac =
3643*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 1, numStrings);
3644*062a843bSAndroid Build Coastguard Worker 
3645*062a843bSAndroid Build Coastguard Worker             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3646*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityWcdma.cid =
3647*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 2, numStrings);
3648*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityWcdma.psc =
3649*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 14, numStrings);
3650*062a843bSAndroid Build Coastguard Worker             break;
3651*062a843bSAndroid Build Coastguard Worker         }
3652*062a843bSAndroid Build Coastguard Worker 
3653*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3654*062a843bSAndroid Build Coastguard Worker             /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3655*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityTdscdma.lac =
3656*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 1, numStrings);
3657*062a843bSAndroid Build Coastguard Worker 
3658*062a843bSAndroid Build Coastguard Worker             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3659*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityTdscdma.cid =
3660*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 2, numStrings);
3661*062a843bSAndroid Build Coastguard Worker             break;
3662*062a843bSAndroid Build Coastguard Worker         }
3663*062a843bSAndroid Build Coastguard Worker 
3664*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_CDMA:{
3665*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityCdma.basestationId =
3666*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 4, numStrings);
3667*062a843bSAndroid Build Coastguard Worker             /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
3668*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityCdma.latitude =
3669*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 5, numStrings);
3670*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityCdma.longitude =
3671*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 6, numStrings);
3672*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityCdma.systemId =
3673*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 8, numStrings);
3674*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityCdma.networkId =
3675*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 9, numStrings);
3676*062a843bSAndroid Build Coastguard Worker             break;
3677*062a843bSAndroid Build Coastguard Worker         }
3678*062a843bSAndroid Build Coastguard Worker 
3679*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_LTE:{
3680*062a843bSAndroid Build Coastguard Worker             /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3681*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityLte.tac =
3682*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 1, numStrings);
3683*062a843bSAndroid Build Coastguard Worker 
3684*062a843bSAndroid Build Coastguard Worker             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3685*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityLte.ci =
3686*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 2, numStrings);
3687*062a843bSAndroid Build Coastguard Worker             break;
3688*062a843bSAndroid Build Coastguard Worker         }
3689*062a843bSAndroid Build Coastguard Worker 
3690*062a843bSAndroid Build Coastguard Worker         default: {
3691*062a843bSAndroid Build Coastguard Worker             break;
3692*062a843bSAndroid Build Coastguard Worker         }
3693*062a843bSAndroid Build Coastguard Worker     }
3694*062a843bSAndroid Build Coastguard Worker 
3695*062a843bSAndroid Build Coastguard Worker     fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3696*062a843bSAndroid Build Coastguard Worker }
3697*062a843bSAndroid Build Coastguard Worker 
3698*062a843bSAndroid Build Coastguard Worker /* Fill Cell Identity info from Data Registration State Response.
3699*062a843bSAndroid Build Coastguard Worker  * This fucntion is applicable only for RIL Version < 15.
3700*062a843bSAndroid Build Coastguard Worker  * Response is a  "char **".
3701*062a843bSAndroid Build Coastguard Worker  * First and Second entries are in hex string format
3702*062a843bSAndroid Build Coastguard Worker  * and rest are integers represented in ascii format. */
fillCellIdentityFromDataRegStateResponseString(CellIdentity & cellIdentity,int numStrings,char ** response)3703*062a843bSAndroid Build Coastguard Worker void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3704*062a843bSAndroid Build Coastguard Worker         int numStrings, char** response) {
3705*062a843bSAndroid Build Coastguard Worker 
3706*062a843bSAndroid Build Coastguard Worker     RIL_CellIdentity_v16 rilCellIdentity;
3707*062a843bSAndroid Build Coastguard Worker     memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3708*062a843bSAndroid Build Coastguard Worker 
3709*062a843bSAndroid Build Coastguard Worker     rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3710*062a843bSAndroid Build Coastguard Worker     switch(rilCellIdentity.cellInfoType) {
3711*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_GSM: {
3712*062a843bSAndroid Build Coastguard Worker             /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3713*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityGsm.lac =
3714*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 1, numStrings);
3715*062a843bSAndroid Build Coastguard Worker 
3716*062a843bSAndroid Build Coastguard Worker             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3717*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityGsm.cid =
3718*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 2, numStrings);
3719*062a843bSAndroid Build Coastguard Worker 
3720*062a843bSAndroid Build Coastguard Worker             if (numStrings >= 13) {
3721*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityGsm.mcc =
3722*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 11, numStrings);
3723*062a843bSAndroid Build Coastguard Worker 
3724*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityGsm.mnc =
3725*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 12, numStrings);
3726*062a843bSAndroid Build Coastguard Worker             }
3727*062a843bSAndroid Build Coastguard Worker             break;
3728*062a843bSAndroid Build Coastguard Worker         }
3729*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_WCDMA: {
3730*062a843bSAndroid Build Coastguard Worker             /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3731*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityWcdma.lac =
3732*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 1, numStrings);
3733*062a843bSAndroid Build Coastguard Worker 
3734*062a843bSAndroid Build Coastguard Worker             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3735*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityWcdma.cid =
3736*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 2, numStrings);
3737*062a843bSAndroid Build Coastguard Worker 
3738*062a843bSAndroid Build Coastguard Worker             if (numStrings >= 13) {
3739*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityWcdma.mcc =
3740*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 11, numStrings);
3741*062a843bSAndroid Build Coastguard Worker 
3742*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityWcdma.mnc =
3743*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 12, numStrings);
3744*062a843bSAndroid Build Coastguard Worker             }
3745*062a843bSAndroid Build Coastguard Worker             break;
3746*062a843bSAndroid Build Coastguard Worker         }
3747*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3748*062a843bSAndroid Build Coastguard Worker             /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3749*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityTdscdma.lac =
3750*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 1, numStrings);
3751*062a843bSAndroid Build Coastguard Worker 
3752*062a843bSAndroid Build Coastguard Worker             /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3753*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityTdscdma.cid =
3754*062a843bSAndroid Build Coastguard Worker                     convertResponseHexStringEntryToInt(response, 2, numStrings);
3755*062a843bSAndroid Build Coastguard Worker 
3756*062a843bSAndroid Build Coastguard Worker             if (numStrings >= 13) {
3757*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityTdscdma.mcc =
3758*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 11, numStrings);
3759*062a843bSAndroid Build Coastguard Worker 
3760*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityTdscdma.mnc =
3761*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 12, numStrings);
3762*062a843bSAndroid Build Coastguard Worker             }
3763*062a843bSAndroid Build Coastguard Worker             break;
3764*062a843bSAndroid Build Coastguard Worker         }
3765*062a843bSAndroid Build Coastguard Worker         case RIL_CELL_INFO_TYPE_LTE: {
3766*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityLte.tac =
3767*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 6, numStrings);
3768*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityLte.pci =
3769*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 7, numStrings);
3770*062a843bSAndroid Build Coastguard Worker             rilCellIdentity.cellIdentityLte.ci =
3771*062a843bSAndroid Build Coastguard Worker                     convertResponseStringEntryToInt(response, 8, numStrings);
3772*062a843bSAndroid Build Coastguard Worker 
3773*062a843bSAndroid Build Coastguard Worker             if (numStrings >= 13) {
3774*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityLte.mcc =
3775*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 11, numStrings);
3776*062a843bSAndroid Build Coastguard Worker 
3777*062a843bSAndroid Build Coastguard Worker                 rilCellIdentity.cellIdentityLte.mnc =
3778*062a843bSAndroid Build Coastguard Worker                         convertResponseStringEntryToInt(response, 12, numStrings);
3779*062a843bSAndroid Build Coastguard Worker             }
3780*062a843bSAndroid Build Coastguard Worker             break;
3781*062a843bSAndroid Build Coastguard Worker         }
3782*062a843bSAndroid Build Coastguard Worker         default: {
3783*062a843bSAndroid Build Coastguard Worker             break;
3784*062a843bSAndroid Build Coastguard Worker         }
3785*062a843bSAndroid Build Coastguard Worker     }
3786*062a843bSAndroid Build Coastguard Worker 
3787*062a843bSAndroid Build Coastguard Worker     fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3788*062a843bSAndroid Build Coastguard Worker }
3789*062a843bSAndroid Build Coastguard Worker 
getVoiceRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3790*062a843bSAndroid Build Coastguard Worker int radio::getVoiceRegistrationStateResponse(int slotId,
3791*062a843bSAndroid Build Coastguard Worker                                             int responseType, int serial, RIL_Errno e,
3792*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
3793*062a843bSAndroid Build Coastguard Worker #if VDBG
3794*062a843bSAndroid Build Coastguard Worker     RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3795*062a843bSAndroid Build Coastguard Worker #endif
3796*062a843bSAndroid Build Coastguard Worker 
3797*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3798*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3799*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3800*062a843bSAndroid Build Coastguard Worker 
3801*062a843bSAndroid Build Coastguard Worker         VoiceRegStateResult voiceRegResponse = {};
3802*062a843bSAndroid Build Coastguard Worker         int numStrings = responseLen / sizeof(char *);
3803*062a843bSAndroid Build Coastguard Worker         if (response == NULL) {
3804*062a843bSAndroid Build Coastguard Worker                RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3805*062a843bSAndroid Build Coastguard Worker                if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3806*062a843bSAndroid Build Coastguard Worker         } else if (s_vendorFunctions->version <= 14) {
3807*062a843bSAndroid Build Coastguard Worker             if (numStrings != 15) {
3808*062a843bSAndroid Build Coastguard Worker                 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3809*062a843bSAndroid Build Coastguard Worker                 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3810*062a843bSAndroid Build Coastguard Worker             } else {
3811*062a843bSAndroid Build Coastguard Worker                 char **resp = (char **) response;
3812*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3813*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3814*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3815*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3816*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3817*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3818*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3819*062a843bSAndroid Build Coastguard Worker                 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3820*062a843bSAndroid Build Coastguard Worker                         numStrings, resp);
3821*062a843bSAndroid Build Coastguard Worker             }
3822*062a843bSAndroid Build Coastguard Worker         } else {
3823*062a843bSAndroid Build Coastguard Worker             RIL_VoiceRegistrationStateResponse *voiceRegState =
3824*062a843bSAndroid Build Coastguard Worker                     (RIL_VoiceRegistrationStateResponse *)response;
3825*062a843bSAndroid Build Coastguard Worker 
3826*062a843bSAndroid Build Coastguard Worker             if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3827*062a843bSAndroid Build Coastguard Worker                 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3828*062a843bSAndroid Build Coastguard Worker                 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3829*062a843bSAndroid Build Coastguard Worker             } else {
3830*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3831*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.rat = voiceRegState->rat;;
3832*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3833*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3834*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3835*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3836*062a843bSAndroid Build Coastguard Worker                 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3837*062a843bSAndroid Build Coastguard Worker                 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3838*062a843bSAndroid Build Coastguard Worker                         voiceRegState->cellIdentity);
3839*062a843bSAndroid Build Coastguard Worker             }
3840*062a843bSAndroid Build Coastguard Worker         }
3841*062a843bSAndroid Build Coastguard Worker 
3842*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus =
3843*062a843bSAndroid Build Coastguard Worker                 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3844*062a843bSAndroid Build Coastguard Worker                 responseInfo, voiceRegResponse);
3845*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3846*062a843bSAndroid Build Coastguard Worker     } else {
3847*062a843bSAndroid Build Coastguard Worker         RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3848*062a843bSAndroid Build Coastguard Worker                 slotId);
3849*062a843bSAndroid Build Coastguard Worker     }
3850*062a843bSAndroid Build Coastguard Worker 
3851*062a843bSAndroid Build Coastguard Worker     return 0;
3852*062a843bSAndroid Build Coastguard Worker }
3853*062a843bSAndroid Build Coastguard Worker 
getDataRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3854*062a843bSAndroid Build Coastguard Worker int radio::getDataRegistrationStateResponse(int slotId,
3855*062a843bSAndroid Build Coastguard Worker                                            int responseType, int serial, RIL_Errno e,
3856*062a843bSAndroid Build Coastguard Worker                                            void *response, size_t responseLen) {
3857*062a843bSAndroid Build Coastguard Worker #if VDBG
3858*062a843bSAndroid Build Coastguard Worker     RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3859*062a843bSAndroid Build Coastguard Worker #endif
3860*062a843bSAndroid Build Coastguard Worker 
3861*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3862*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3863*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3864*062a843bSAndroid Build Coastguard Worker         DataRegStateResult dataRegResponse = {};
3865*062a843bSAndroid Build Coastguard Worker         if (response == NULL) {
3866*062a843bSAndroid Build Coastguard Worker             RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3867*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3868*062a843bSAndroid Build Coastguard Worker         } else if (s_vendorFunctions->version <= 14) {
3869*062a843bSAndroid Build Coastguard Worker             int numStrings = responseLen / sizeof(char *);
3870*062a843bSAndroid Build Coastguard Worker             if ((numStrings != 6) && (numStrings != 11) && (numStrings != 13)) {
3871*062a843bSAndroid Build Coastguard Worker                 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3872*062a843bSAndroid Build Coastguard Worker                 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3873*062a843bSAndroid Build Coastguard Worker             } else {
3874*062a843bSAndroid Build Coastguard Worker                 char **resp = (char **) response;
3875*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3876*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.rat =  ATOI_NULL_HANDLED_DEF(resp[3], 0);
3877*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.reasonDataDenied =  ATOI_NULL_HANDLED(resp[4]);
3878*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.maxDataCalls =  ATOI_NULL_HANDLED_DEF(resp[5], 1);
3879*062a843bSAndroid Build Coastguard Worker                 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3880*062a843bSAndroid Build Coastguard Worker                         numStrings, resp);
3881*062a843bSAndroid Build Coastguard Worker             }
3882*062a843bSAndroid Build Coastguard Worker         } else {
3883*062a843bSAndroid Build Coastguard Worker             RIL_DataRegistrationStateResponse *dataRegState =
3884*062a843bSAndroid Build Coastguard Worker                     (RIL_DataRegistrationStateResponse *)response;
3885*062a843bSAndroid Build Coastguard Worker 
3886*062a843bSAndroid Build Coastguard Worker             if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3887*062a843bSAndroid Build Coastguard Worker                 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3888*062a843bSAndroid Build Coastguard Worker                 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3889*062a843bSAndroid Build Coastguard Worker             } else {
3890*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.regState = (RegState) dataRegState->regState;
3891*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.rat = dataRegState->rat;;
3892*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3893*062a843bSAndroid Build Coastguard Worker                 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3894*062a843bSAndroid Build Coastguard Worker                 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3895*062a843bSAndroid Build Coastguard Worker             }
3896*062a843bSAndroid Build Coastguard Worker         }
3897*062a843bSAndroid Build Coastguard Worker 
3898*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus =
3899*062a843bSAndroid Build Coastguard Worker                 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3900*062a843bSAndroid Build Coastguard Worker                 dataRegResponse);
3901*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3902*062a843bSAndroid Build Coastguard Worker     } else {
3903*062a843bSAndroid Build Coastguard Worker         RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3904*062a843bSAndroid Build Coastguard Worker                 slotId);
3905*062a843bSAndroid Build Coastguard Worker     }
3906*062a843bSAndroid Build Coastguard Worker 
3907*062a843bSAndroid Build Coastguard Worker     return 0;
3908*062a843bSAndroid Build Coastguard Worker }
3909*062a843bSAndroid Build Coastguard Worker 
getOperatorResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3910*062a843bSAndroid Build Coastguard Worker int radio::getOperatorResponse(int slotId,
3911*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e, void *response,
3912*062a843bSAndroid Build Coastguard Worker                               size_t responseLen) {
3913*062a843bSAndroid Build Coastguard Worker #if VDBG
3914*062a843bSAndroid Build Coastguard Worker     RLOGD("getOperatorResponse: serial %d", serial);
3915*062a843bSAndroid Build Coastguard Worker #endif
3916*062a843bSAndroid Build Coastguard Worker 
3917*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3918*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3919*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3920*062a843bSAndroid Build Coastguard Worker         hidl_string longName;
3921*062a843bSAndroid Build Coastguard Worker         hidl_string shortName;
3922*062a843bSAndroid Build Coastguard Worker         hidl_string numeric;
3923*062a843bSAndroid Build Coastguard Worker         int numStrings = responseLen / sizeof(char *);
3924*062a843bSAndroid Build Coastguard Worker         if (response == NULL || numStrings != 3) {
3925*062a843bSAndroid Build Coastguard Worker             RLOGE("getOperatorResponse Invalid response: NULL");
3926*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3927*062a843bSAndroid Build Coastguard Worker 
3928*062a843bSAndroid Build Coastguard Worker         } else {
3929*062a843bSAndroid Build Coastguard Worker             char **resp = (char **) response;
3930*062a843bSAndroid Build Coastguard Worker             longName = convertCharPtrToHidlString(resp[0]);
3931*062a843bSAndroid Build Coastguard Worker             shortName = convertCharPtrToHidlString(resp[1]);
3932*062a843bSAndroid Build Coastguard Worker             numeric = convertCharPtrToHidlString(resp[2]);
3933*062a843bSAndroid Build Coastguard Worker         }
3934*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3935*062a843bSAndroid Build Coastguard Worker                 responseInfo, longName, shortName, numeric);
3936*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3937*062a843bSAndroid Build Coastguard Worker     } else {
3938*062a843bSAndroid Build Coastguard Worker         RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3939*062a843bSAndroid Build Coastguard Worker                 slotId);
3940*062a843bSAndroid Build Coastguard Worker     }
3941*062a843bSAndroid Build Coastguard Worker 
3942*062a843bSAndroid Build Coastguard Worker     return 0;
3943*062a843bSAndroid Build Coastguard Worker }
3944*062a843bSAndroid Build Coastguard Worker 
setRadioPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3945*062a843bSAndroid Build Coastguard Worker int radio::setRadioPowerResponse(int slotId,
3946*062a843bSAndroid Build Coastguard Worker                                 int responseType, int serial, RIL_Errno e, void *response,
3947*062a843bSAndroid Build Coastguard Worker                                 size_t responseLen) {
3948*062a843bSAndroid Build Coastguard Worker     RLOGD("setRadioPowerResponse: serial %d", serial);
3949*062a843bSAndroid Build Coastguard Worker 
3950*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3951*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3952*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3953*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3954*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3955*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3956*062a843bSAndroid Build Coastguard Worker     } else {
3957*062a843bSAndroid Build Coastguard Worker         RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3958*062a843bSAndroid Build Coastguard Worker                 slotId);
3959*062a843bSAndroid Build Coastguard Worker     }
3960*062a843bSAndroid Build Coastguard Worker 
3961*062a843bSAndroid Build Coastguard Worker     return 0;
3962*062a843bSAndroid Build Coastguard Worker }
3963*062a843bSAndroid Build Coastguard Worker 
sendDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)3964*062a843bSAndroid Build Coastguard Worker int radio::sendDtmfResponse(int slotId,
3965*062a843bSAndroid Build Coastguard Worker                            int responseType, int serial, RIL_Errno e, void *response,
3966*062a843bSAndroid Build Coastguard Worker                            size_t responseLen) {
3967*062a843bSAndroid Build Coastguard Worker #if VDBG
3968*062a843bSAndroid Build Coastguard Worker     RLOGD("sendDtmfResponse: serial %d", serial);
3969*062a843bSAndroid Build Coastguard Worker #endif
3970*062a843bSAndroid Build Coastguard Worker 
3971*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
3972*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
3973*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
3974*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3975*062a843bSAndroid Build Coastguard Worker                 responseInfo);
3976*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
3977*062a843bSAndroid Build Coastguard Worker     } else {
3978*062a843bSAndroid Build Coastguard Worker         RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3979*062a843bSAndroid Build Coastguard Worker                 slotId);
3980*062a843bSAndroid Build Coastguard Worker     }
3981*062a843bSAndroid Build Coastguard Worker 
3982*062a843bSAndroid Build Coastguard Worker     return 0;
3983*062a843bSAndroid Build Coastguard Worker }
3984*062a843bSAndroid Build Coastguard Worker 
makeSendSmsResult(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)3985*062a843bSAndroid Build Coastguard Worker SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3986*062a843bSAndroid Build Coastguard Worker                                 RIL_Errno e, void *response, size_t responseLen) {
3987*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
3988*062a843bSAndroid Build Coastguard Worker     SendSmsResult result = {};
3989*062a843bSAndroid Build Coastguard Worker 
3990*062a843bSAndroid Build Coastguard Worker     if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3991*062a843bSAndroid Build Coastguard Worker         RLOGE("Invalid response: NULL");
3992*062a843bSAndroid Build Coastguard Worker         if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3993*062a843bSAndroid Build Coastguard Worker         result.ackPDU = hidl_string();
3994*062a843bSAndroid Build Coastguard Worker     } else {
3995*062a843bSAndroid Build Coastguard Worker         RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3996*062a843bSAndroid Build Coastguard Worker         result.messageRef = resp->messageRef;
3997*062a843bSAndroid Build Coastguard Worker         result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3998*062a843bSAndroid Build Coastguard Worker         result.errorCode = resp->errorCode;
3999*062a843bSAndroid Build Coastguard Worker     }
4000*062a843bSAndroid Build Coastguard Worker     return result;
4001*062a843bSAndroid Build Coastguard Worker }
4002*062a843bSAndroid Build Coastguard Worker 
sendSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4003*062a843bSAndroid Build Coastguard Worker int radio::sendSmsResponse(int slotId,
4004*062a843bSAndroid Build Coastguard Worker                           int responseType, int serial, RIL_Errno e, void *response,
4005*062a843bSAndroid Build Coastguard Worker                           size_t responseLen) {
4006*062a843bSAndroid Build Coastguard Worker #if VDBG
4007*062a843bSAndroid Build Coastguard Worker     RLOGD("sendSmsResponse: serial %d", serial);
4008*062a843bSAndroid Build Coastguard Worker #endif
4009*062a843bSAndroid Build Coastguard Worker 
4010*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4011*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4012*062a843bSAndroid Build Coastguard Worker         SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4013*062a843bSAndroid Build Coastguard Worker                 responseLen);
4014*062a843bSAndroid Build Coastguard Worker 
4015*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
4016*062a843bSAndroid Build Coastguard Worker                 result);
4017*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4018*062a843bSAndroid Build Coastguard Worker     } else {
4019*062a843bSAndroid Build Coastguard Worker         RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4020*062a843bSAndroid Build Coastguard Worker     }
4021*062a843bSAndroid Build Coastguard Worker 
4022*062a843bSAndroid Build Coastguard Worker     return 0;
4023*062a843bSAndroid Build Coastguard Worker }
4024*062a843bSAndroid Build Coastguard Worker 
sendSMSExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4025*062a843bSAndroid Build Coastguard Worker int radio::sendSMSExpectMoreResponse(int slotId,
4026*062a843bSAndroid Build Coastguard Worker                                     int responseType, int serial, RIL_Errno e, void *response,
4027*062a843bSAndroid Build Coastguard Worker                                     size_t responseLen) {
4028*062a843bSAndroid Build Coastguard Worker #if VDBG
4029*062a843bSAndroid Build Coastguard Worker     RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
4030*062a843bSAndroid Build Coastguard Worker #endif
4031*062a843bSAndroid Build Coastguard Worker 
4032*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4033*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4034*062a843bSAndroid Build Coastguard Worker         SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4035*062a843bSAndroid Build Coastguard Worker                 responseLen);
4036*062a843bSAndroid Build Coastguard Worker 
4037*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
4038*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
4039*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4040*062a843bSAndroid Build Coastguard Worker     } else {
4041*062a843bSAndroid Build Coastguard Worker         RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4042*062a843bSAndroid Build Coastguard Worker     }
4043*062a843bSAndroid Build Coastguard Worker 
4044*062a843bSAndroid Build Coastguard Worker     return 0;
4045*062a843bSAndroid Build Coastguard Worker }
4046*062a843bSAndroid Build Coastguard Worker 
setupDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4047*062a843bSAndroid Build Coastguard Worker int radio::setupDataCallResponse(int slotId,
4048*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e, void *response,
4049*062a843bSAndroid Build Coastguard Worker                                  size_t responseLen) {
4050*062a843bSAndroid Build Coastguard Worker #if VDBG
4051*062a843bSAndroid Build Coastguard Worker     RLOGD("setupDataCallResponse: serial %d", serial);
4052*062a843bSAndroid Build Coastguard Worker #endif
4053*062a843bSAndroid Build Coastguard Worker 
4054*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4055*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4056*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4057*062a843bSAndroid Build Coastguard Worker 
4058*062a843bSAndroid Build Coastguard Worker         SetupDataCallResult result = {};
4059*062a843bSAndroid Build Coastguard Worker         if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
4060*062a843bSAndroid Build Coastguard Worker             if (response != NULL) {
4061*062a843bSAndroid Build Coastguard Worker                 RLOGE("setupDataCallResponse: Invalid response");
4062*062a843bSAndroid Build Coastguard Worker                 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4063*062a843bSAndroid Build Coastguard Worker             }
4064*062a843bSAndroid Build Coastguard Worker             result.status = DataCallFailCause::ERROR_UNSPECIFIED;
4065*062a843bSAndroid Build Coastguard Worker             result.type = hidl_string();
4066*062a843bSAndroid Build Coastguard Worker             result.ifname = hidl_string();
4067*062a843bSAndroid Build Coastguard Worker             result.addresses = hidl_string();
4068*062a843bSAndroid Build Coastguard Worker             result.dnses = hidl_string();
4069*062a843bSAndroid Build Coastguard Worker             result.gateways = hidl_string();
4070*062a843bSAndroid Build Coastguard Worker             result.pcscf = hidl_string();
4071*062a843bSAndroid Build Coastguard Worker         } else {
4072*062a843bSAndroid Build Coastguard Worker             convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
4073*062a843bSAndroid Build Coastguard Worker         }
4074*062a843bSAndroid Build Coastguard Worker 
4075*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
4076*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
4077*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4078*062a843bSAndroid Build Coastguard Worker     } else {
4079*062a843bSAndroid Build Coastguard Worker         RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4080*062a843bSAndroid Build Coastguard Worker     }
4081*062a843bSAndroid Build Coastguard Worker 
4082*062a843bSAndroid Build Coastguard Worker     return 0;
4083*062a843bSAndroid Build Coastguard Worker }
4084*062a843bSAndroid Build Coastguard Worker 
responseIccIo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4085*062a843bSAndroid Build Coastguard Worker IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
4086*062a843bSAndroid Build Coastguard Worker                            RIL_Errno e, void *response, size_t responseLen) {
4087*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
4088*062a843bSAndroid Build Coastguard Worker     IccIoResult result = {};
4089*062a843bSAndroid Build Coastguard Worker 
4090*062a843bSAndroid Build Coastguard Worker     if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
4091*062a843bSAndroid Build Coastguard Worker         RLOGE("Invalid response: NULL");
4092*062a843bSAndroid Build Coastguard Worker         if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4093*062a843bSAndroid Build Coastguard Worker         result.simResponse = hidl_string();
4094*062a843bSAndroid Build Coastguard Worker     } else {
4095*062a843bSAndroid Build Coastguard Worker         RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
4096*062a843bSAndroid Build Coastguard Worker         result.sw1 = resp->sw1;
4097*062a843bSAndroid Build Coastguard Worker         result.sw2 = resp->sw2;
4098*062a843bSAndroid Build Coastguard Worker         result.simResponse = convertCharPtrToHidlString(resp->simResponse);
4099*062a843bSAndroid Build Coastguard Worker     }
4100*062a843bSAndroid Build Coastguard Worker     return result;
4101*062a843bSAndroid Build Coastguard Worker }
4102*062a843bSAndroid Build Coastguard Worker 
iccIOForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4103*062a843bSAndroid Build Coastguard Worker int radio::iccIOForAppResponse(int slotId,
4104*062a843bSAndroid Build Coastguard Worker                       int responseType, int serial, RIL_Errno e, void *response,
4105*062a843bSAndroid Build Coastguard Worker                       size_t responseLen) {
4106*062a843bSAndroid Build Coastguard Worker #if VDBG
4107*062a843bSAndroid Build Coastguard Worker     RLOGD("iccIOForAppResponse: serial %d", serial);
4108*062a843bSAndroid Build Coastguard Worker #endif
4109*062a843bSAndroid Build Coastguard Worker 
4110*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4111*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4112*062a843bSAndroid Build Coastguard Worker         IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4113*062a843bSAndroid Build Coastguard Worker                 responseLen);
4114*062a843bSAndroid Build Coastguard Worker 
4115*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
4116*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
4117*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4118*062a843bSAndroid Build Coastguard Worker     } else {
4119*062a843bSAndroid Build Coastguard Worker         RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4120*062a843bSAndroid Build Coastguard Worker     }
4121*062a843bSAndroid Build Coastguard Worker 
4122*062a843bSAndroid Build Coastguard Worker     return 0;
4123*062a843bSAndroid Build Coastguard Worker }
4124*062a843bSAndroid Build Coastguard Worker 
sendUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4125*062a843bSAndroid Build Coastguard Worker int radio::sendUssdResponse(int slotId,
4126*062a843bSAndroid Build Coastguard Worker                            int responseType, int serial, RIL_Errno e, void *response,
4127*062a843bSAndroid Build Coastguard Worker                            size_t responseLen) {
4128*062a843bSAndroid Build Coastguard Worker #if VDBG
4129*062a843bSAndroid Build Coastguard Worker     RLOGD("sendUssdResponse: serial %d", serial);
4130*062a843bSAndroid Build Coastguard Worker #endif
4131*062a843bSAndroid Build Coastguard Worker 
4132*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4133*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4134*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4135*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
4136*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4137*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4138*062a843bSAndroid Build Coastguard Worker     } else {
4139*062a843bSAndroid Build Coastguard Worker         RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
4140*062a843bSAndroid Build Coastguard Worker                 slotId);
4141*062a843bSAndroid Build Coastguard Worker     }
4142*062a843bSAndroid Build Coastguard Worker 
4143*062a843bSAndroid Build Coastguard Worker     return 0;
4144*062a843bSAndroid Build Coastguard Worker }
4145*062a843bSAndroid Build Coastguard Worker 
cancelPendingUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4146*062a843bSAndroid Build Coastguard Worker int radio::cancelPendingUssdResponse(int slotId,
4147*062a843bSAndroid Build Coastguard Worker                                     int responseType, int serial, RIL_Errno e, void *response,
4148*062a843bSAndroid Build Coastguard Worker                                     size_t responseLen) {
4149*062a843bSAndroid Build Coastguard Worker #if VDBG
4150*062a843bSAndroid Build Coastguard Worker     RLOGD("cancelPendingUssdResponse: serial %d", serial);
4151*062a843bSAndroid Build Coastguard Worker #endif
4152*062a843bSAndroid Build Coastguard Worker 
4153*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4154*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4155*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4156*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
4157*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4158*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4159*062a843bSAndroid Build Coastguard Worker     } else {
4160*062a843bSAndroid Build Coastguard Worker         RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4161*062a843bSAndroid Build Coastguard Worker                 slotId);
4162*062a843bSAndroid Build Coastguard Worker     }
4163*062a843bSAndroid Build Coastguard Worker 
4164*062a843bSAndroid Build Coastguard Worker     return 0;
4165*062a843bSAndroid Build Coastguard Worker }
4166*062a843bSAndroid Build Coastguard Worker 
getClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4167*062a843bSAndroid Build Coastguard Worker int radio::getClirResponse(int slotId,
4168*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e, void *response,
4169*062a843bSAndroid Build Coastguard Worker                               size_t responseLen) {
4170*062a843bSAndroid Build Coastguard Worker #if VDBG
4171*062a843bSAndroid Build Coastguard Worker     RLOGD("getClirResponse: serial %d", serial);
4172*062a843bSAndroid Build Coastguard Worker #endif
4173*062a843bSAndroid Build Coastguard Worker 
4174*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4175*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4176*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4177*062a843bSAndroid Build Coastguard Worker         int n = -1, m = -1;
4178*062a843bSAndroid Build Coastguard Worker         int numInts = responseLen / sizeof(int);
4179*062a843bSAndroid Build Coastguard Worker         if (response == NULL || numInts != 2) {
4180*062a843bSAndroid Build Coastguard Worker             RLOGE("getClirResponse Invalid response: NULL");
4181*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4182*062a843bSAndroid Build Coastguard Worker         } else {
4183*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
4184*062a843bSAndroid Build Coastguard Worker             n = pInt[0];
4185*062a843bSAndroid Build Coastguard Worker             m = pInt[1];
4186*062a843bSAndroid Build Coastguard Worker         }
4187*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4188*062a843bSAndroid Build Coastguard Worker                 n, m);
4189*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4190*062a843bSAndroid Build Coastguard Worker     } else {
4191*062a843bSAndroid Build Coastguard Worker         RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4192*062a843bSAndroid Build Coastguard Worker     }
4193*062a843bSAndroid Build Coastguard Worker 
4194*062a843bSAndroid Build Coastguard Worker     return 0;
4195*062a843bSAndroid Build Coastguard Worker }
4196*062a843bSAndroid Build Coastguard Worker 
setClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4197*062a843bSAndroid Build Coastguard Worker int radio::setClirResponse(int slotId,
4198*062a843bSAndroid Build Coastguard Worker                           int responseType, int serial, RIL_Errno e, void *response,
4199*062a843bSAndroid Build Coastguard Worker                           size_t responseLen) {
4200*062a843bSAndroid Build Coastguard Worker #if VDBG
4201*062a843bSAndroid Build Coastguard Worker     RLOGD("setClirResponse: serial %d", serial);
4202*062a843bSAndroid Build Coastguard Worker #endif
4203*062a843bSAndroid Build Coastguard Worker 
4204*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4205*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4206*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4207*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4208*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4209*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4210*062a843bSAndroid Build Coastguard Worker     } else {
4211*062a843bSAndroid Build Coastguard Worker         RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4212*062a843bSAndroid Build Coastguard Worker     }
4213*062a843bSAndroid Build Coastguard Worker 
4214*062a843bSAndroid Build Coastguard Worker     return 0;
4215*062a843bSAndroid Build Coastguard Worker }
4216*062a843bSAndroid Build Coastguard Worker 
getCallForwardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4217*062a843bSAndroid Build Coastguard Worker int radio::getCallForwardStatusResponse(int slotId,
4218*062a843bSAndroid Build Coastguard Worker                                        int responseType, int serial, RIL_Errno e,
4219*062a843bSAndroid Build Coastguard Worker                                        void *response, size_t responseLen) {
4220*062a843bSAndroid Build Coastguard Worker #if VDBG
4221*062a843bSAndroid Build Coastguard Worker     RLOGD("getCallForwardStatusResponse: serial %d", serial);
4222*062a843bSAndroid Build Coastguard Worker #endif
4223*062a843bSAndroid Build Coastguard Worker 
4224*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4225*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4226*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4227*062a843bSAndroid Build Coastguard Worker         hidl_vec<CallForwardInfo> callForwardInfos;
4228*062a843bSAndroid Build Coastguard Worker 
4229*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
4230*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4231*062a843bSAndroid Build Coastguard Worker             RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4232*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4233*062a843bSAndroid Build Coastguard Worker         } else {
4234*062a843bSAndroid Build Coastguard Worker             int num = responseLen / sizeof(RIL_CallForwardInfo *);
4235*062a843bSAndroid Build Coastguard Worker             callForwardInfos.resize(num);
4236*062a843bSAndroid Build Coastguard Worker             for (int i = 0 ; i < num; i++) {
4237*062a843bSAndroid Build Coastguard Worker                 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4238*062a843bSAndroid Build Coastguard Worker                 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4239*062a843bSAndroid Build Coastguard Worker                 callForwardInfos[i].reason = resp->reason;
4240*062a843bSAndroid Build Coastguard Worker                 callForwardInfos[i].serviceClass = resp->serviceClass;
4241*062a843bSAndroid Build Coastguard Worker                 callForwardInfos[i].toa = resp->toa;
4242*062a843bSAndroid Build Coastguard Worker                 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4243*062a843bSAndroid Build Coastguard Worker                 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4244*062a843bSAndroid Build Coastguard Worker             }
4245*062a843bSAndroid Build Coastguard Worker         }
4246*062a843bSAndroid Build Coastguard Worker 
4247*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4248*062a843bSAndroid Build Coastguard Worker                 responseInfo, callForwardInfos);
4249*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4250*062a843bSAndroid Build Coastguard Worker     } else {
4251*062a843bSAndroid Build Coastguard Worker         RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4252*062a843bSAndroid Build Coastguard Worker                 slotId);
4253*062a843bSAndroid Build Coastguard Worker     }
4254*062a843bSAndroid Build Coastguard Worker 
4255*062a843bSAndroid Build Coastguard Worker     return 0;
4256*062a843bSAndroid Build Coastguard Worker }
4257*062a843bSAndroid Build Coastguard Worker 
setCallForwardResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4258*062a843bSAndroid Build Coastguard Worker int radio::setCallForwardResponse(int slotId,
4259*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e, void *response,
4260*062a843bSAndroid Build Coastguard Worker                                  size_t responseLen) {
4261*062a843bSAndroid Build Coastguard Worker #if VDBG
4262*062a843bSAndroid Build Coastguard Worker     RLOGD("setCallForwardResponse: serial %d", serial);
4263*062a843bSAndroid Build Coastguard Worker #endif
4264*062a843bSAndroid Build Coastguard Worker 
4265*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4266*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4267*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4268*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4269*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4270*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4271*062a843bSAndroid Build Coastguard Worker     } else {
4272*062a843bSAndroid Build Coastguard Worker         RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4273*062a843bSAndroid Build Coastguard Worker     }
4274*062a843bSAndroid Build Coastguard Worker 
4275*062a843bSAndroid Build Coastguard Worker     return 0;
4276*062a843bSAndroid Build Coastguard Worker }
4277*062a843bSAndroid Build Coastguard Worker 
getCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4278*062a843bSAndroid Build Coastguard Worker int radio::getCallWaitingResponse(int slotId,
4279*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e, void *response,
4280*062a843bSAndroid Build Coastguard Worker                                  size_t responseLen) {
4281*062a843bSAndroid Build Coastguard Worker #if VDBG
4282*062a843bSAndroid Build Coastguard Worker     RLOGD("getCallWaitingResponse: serial %d", serial);
4283*062a843bSAndroid Build Coastguard Worker #endif
4284*062a843bSAndroid Build Coastguard Worker 
4285*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4286*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4287*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4288*062a843bSAndroid Build Coastguard Worker         bool enable = false;
4289*062a843bSAndroid Build Coastguard Worker         int serviceClass = -1;
4290*062a843bSAndroid Build Coastguard Worker         int numInts = responseLen / sizeof(int);
4291*062a843bSAndroid Build Coastguard Worker         if (response == NULL || numInts != 2) {
4292*062a843bSAndroid Build Coastguard Worker             RLOGE("getCallWaitingResponse Invalid response: NULL");
4293*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4294*062a843bSAndroid Build Coastguard Worker         } else {
4295*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
4296*062a843bSAndroid Build Coastguard Worker             enable = pInt[0] == 1 ? true : false;
4297*062a843bSAndroid Build Coastguard Worker             serviceClass = pInt[1];
4298*062a843bSAndroid Build Coastguard Worker         }
4299*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4300*062a843bSAndroid Build Coastguard Worker                 responseInfo, enable, serviceClass);
4301*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4302*062a843bSAndroid Build Coastguard Worker     } else {
4303*062a843bSAndroid Build Coastguard Worker         RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4304*062a843bSAndroid Build Coastguard Worker     }
4305*062a843bSAndroid Build Coastguard Worker 
4306*062a843bSAndroid Build Coastguard Worker     return 0;
4307*062a843bSAndroid Build Coastguard Worker }
4308*062a843bSAndroid Build Coastguard Worker 
setCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4309*062a843bSAndroid Build Coastguard Worker int radio::setCallWaitingResponse(int slotId,
4310*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e, void *response,
4311*062a843bSAndroid Build Coastguard Worker                                  size_t responseLen) {
4312*062a843bSAndroid Build Coastguard Worker #if VDBG
4313*062a843bSAndroid Build Coastguard Worker     RLOGD("setCallWaitingResponse: serial %d", serial);
4314*062a843bSAndroid Build Coastguard Worker #endif
4315*062a843bSAndroid Build Coastguard Worker 
4316*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4317*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4318*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4319*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4320*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4321*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4322*062a843bSAndroid Build Coastguard Worker     } else {
4323*062a843bSAndroid Build Coastguard Worker         RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4324*062a843bSAndroid Build Coastguard Worker     }
4325*062a843bSAndroid Build Coastguard Worker 
4326*062a843bSAndroid Build Coastguard Worker     return 0;
4327*062a843bSAndroid Build Coastguard Worker }
4328*062a843bSAndroid Build Coastguard Worker 
acknowledgeLastIncomingGsmSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4329*062a843bSAndroid Build Coastguard Worker int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4330*062a843bSAndroid Build Coastguard Worker                                                 int responseType, int serial, RIL_Errno e,
4331*062a843bSAndroid Build Coastguard Worker                                                 void *response, size_t responseLen) {
4332*062a843bSAndroid Build Coastguard Worker #if VDBG
4333*062a843bSAndroid Build Coastguard Worker     RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4334*062a843bSAndroid Build Coastguard Worker #endif
4335*062a843bSAndroid Build Coastguard Worker 
4336*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4337*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4338*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4339*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus =
4340*062a843bSAndroid Build Coastguard Worker                 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4341*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4342*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4343*062a843bSAndroid Build Coastguard Worker     } else {
4344*062a843bSAndroid Build Coastguard Worker         RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4345*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
4346*062a843bSAndroid Build Coastguard Worker     }
4347*062a843bSAndroid Build Coastguard Worker 
4348*062a843bSAndroid Build Coastguard Worker     return 0;
4349*062a843bSAndroid Build Coastguard Worker }
4350*062a843bSAndroid Build Coastguard Worker 
acceptCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4351*062a843bSAndroid Build Coastguard Worker int radio::acceptCallResponse(int slotId,
4352*062a843bSAndroid Build Coastguard Worker                              int responseType, int serial, RIL_Errno e,
4353*062a843bSAndroid Build Coastguard Worker                              void *response, size_t responseLen) {
4354*062a843bSAndroid Build Coastguard Worker #if VDBG
4355*062a843bSAndroid Build Coastguard Worker     RLOGD("acceptCallResponse: serial %d", serial);
4356*062a843bSAndroid Build Coastguard Worker #endif
4357*062a843bSAndroid Build Coastguard Worker 
4358*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4359*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4360*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4361*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4362*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4363*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4364*062a843bSAndroid Build Coastguard Worker     } else {
4365*062a843bSAndroid Build Coastguard Worker         RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4366*062a843bSAndroid Build Coastguard Worker                 slotId);
4367*062a843bSAndroid Build Coastguard Worker     }
4368*062a843bSAndroid Build Coastguard Worker 
4369*062a843bSAndroid Build Coastguard Worker     return 0;
4370*062a843bSAndroid Build Coastguard Worker }
4371*062a843bSAndroid Build Coastguard Worker 
deactivateDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4372*062a843bSAndroid Build Coastguard Worker int radio::deactivateDataCallResponse(int slotId,
4373*062a843bSAndroid Build Coastguard Worker                                                 int responseType, int serial, RIL_Errno e,
4374*062a843bSAndroid Build Coastguard Worker                                                 void *response, size_t responseLen) {
4375*062a843bSAndroid Build Coastguard Worker #if VDBG
4376*062a843bSAndroid Build Coastguard Worker     RLOGD("deactivateDataCallResponse: serial %d", serial);
4377*062a843bSAndroid Build Coastguard Worker #endif
4378*062a843bSAndroid Build Coastguard Worker 
4379*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4380*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4381*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4382*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4383*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4384*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4385*062a843bSAndroid Build Coastguard Worker     } else {
4386*062a843bSAndroid Build Coastguard Worker         RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4387*062a843bSAndroid Build Coastguard Worker                 slotId);
4388*062a843bSAndroid Build Coastguard Worker     }
4389*062a843bSAndroid Build Coastguard Worker 
4390*062a843bSAndroid Build Coastguard Worker     return 0;
4391*062a843bSAndroid Build Coastguard Worker }
4392*062a843bSAndroid Build Coastguard Worker 
getFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4393*062a843bSAndroid Build Coastguard Worker int radio::getFacilityLockForAppResponse(int slotId,
4394*062a843bSAndroid Build Coastguard Worker                                         int responseType, int serial, RIL_Errno e,
4395*062a843bSAndroid Build Coastguard Worker                                         void *response, size_t responseLen) {
4396*062a843bSAndroid Build Coastguard Worker #if VDBG
4397*062a843bSAndroid Build Coastguard Worker     RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4398*062a843bSAndroid Build Coastguard Worker #endif
4399*062a843bSAndroid Build Coastguard Worker 
4400*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4401*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4402*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4403*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
4404*062a843bSAndroid Build Coastguard Worker                 getFacilityLockForAppResponse(responseInfo, ret);
4405*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4406*062a843bSAndroid Build Coastguard Worker     } else {
4407*062a843bSAndroid Build Coastguard Worker         RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4408*062a843bSAndroid Build Coastguard Worker                 slotId);
4409*062a843bSAndroid Build Coastguard Worker     }
4410*062a843bSAndroid Build Coastguard Worker 
4411*062a843bSAndroid Build Coastguard Worker     return 0;
4412*062a843bSAndroid Build Coastguard Worker }
4413*062a843bSAndroid Build Coastguard Worker 
setFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4414*062a843bSAndroid Build Coastguard Worker int radio::setFacilityLockForAppResponse(int slotId,
4415*062a843bSAndroid Build Coastguard Worker                                       int responseType, int serial, RIL_Errno e,
4416*062a843bSAndroid Build Coastguard Worker                                       void *response, size_t responseLen) {
4417*062a843bSAndroid Build Coastguard Worker #if VDBG
4418*062a843bSAndroid Build Coastguard Worker     RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4419*062a843bSAndroid Build Coastguard Worker #endif
4420*062a843bSAndroid Build Coastguard Worker 
4421*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4422*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4423*062a843bSAndroid Build Coastguard Worker         int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4424*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4425*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4426*062a843bSAndroid Build Coastguard Worker                 ret);
4427*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4428*062a843bSAndroid Build Coastguard Worker     } else {
4429*062a843bSAndroid Build Coastguard Worker         RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4430*062a843bSAndroid Build Coastguard Worker                 slotId);
4431*062a843bSAndroid Build Coastguard Worker     }
4432*062a843bSAndroid Build Coastguard Worker 
4433*062a843bSAndroid Build Coastguard Worker     return 0;
4434*062a843bSAndroid Build Coastguard Worker }
4435*062a843bSAndroid Build Coastguard Worker 
setBarringPasswordResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4436*062a843bSAndroid Build Coastguard Worker int radio::setBarringPasswordResponse(int slotId,
4437*062a843bSAndroid Build Coastguard Worker                              int responseType, int serial, RIL_Errno e,
4438*062a843bSAndroid Build Coastguard Worker                              void *response, size_t responseLen) {
4439*062a843bSAndroid Build Coastguard Worker #if VDBG
4440*062a843bSAndroid Build Coastguard Worker     RLOGD("acceptCallResponse: serial %d", serial);
4441*062a843bSAndroid Build Coastguard Worker #endif
4442*062a843bSAndroid Build Coastguard Worker 
4443*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4444*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4445*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4446*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4447*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4448*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4449*062a843bSAndroid Build Coastguard Worker     } else {
4450*062a843bSAndroid Build Coastguard Worker         RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4451*062a843bSAndroid Build Coastguard Worker                 slotId);
4452*062a843bSAndroid Build Coastguard Worker     }
4453*062a843bSAndroid Build Coastguard Worker 
4454*062a843bSAndroid Build Coastguard Worker     return 0;
4455*062a843bSAndroid Build Coastguard Worker }
4456*062a843bSAndroid Build Coastguard Worker 
getNetworkSelectionModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4457*062a843bSAndroid Build Coastguard Worker int radio::getNetworkSelectionModeResponse(int slotId,
4458*062a843bSAndroid Build Coastguard Worker                                           int responseType, int serial, RIL_Errno e, void *response,
4459*062a843bSAndroid Build Coastguard Worker                                           size_t responseLen) {
4460*062a843bSAndroid Build Coastguard Worker #if VDBG
4461*062a843bSAndroid Build Coastguard Worker     RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4462*062a843bSAndroid Build Coastguard Worker #endif
4463*062a843bSAndroid Build Coastguard Worker 
4464*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4465*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4466*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4467*062a843bSAndroid Build Coastguard Worker         bool manual = false;
4468*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
4469*062a843bSAndroid Build Coastguard Worker             RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4470*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4471*062a843bSAndroid Build Coastguard Worker         } else {
4472*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
4473*062a843bSAndroid Build Coastguard Worker             manual = pInt[0] == 1 ? true : false;
4474*062a843bSAndroid Build Coastguard Worker         }
4475*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4476*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4477*062a843bSAndroid Build Coastguard Worker                 responseInfo,
4478*062a843bSAndroid Build Coastguard Worker                 manual);
4479*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4480*062a843bSAndroid Build Coastguard Worker     } else {
4481*062a843bSAndroid Build Coastguard Worker         RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4482*062a843bSAndroid Build Coastguard Worker                 slotId);
4483*062a843bSAndroid Build Coastguard Worker     }
4484*062a843bSAndroid Build Coastguard Worker 
4485*062a843bSAndroid Build Coastguard Worker     return 0;
4486*062a843bSAndroid Build Coastguard Worker }
4487*062a843bSAndroid Build Coastguard Worker 
setNetworkSelectionModeAutomaticResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4488*062a843bSAndroid Build Coastguard Worker int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4489*062a843bSAndroid Build Coastguard Worker                                                     RIL_Errno e, void *response,
4490*062a843bSAndroid Build Coastguard Worker                                                     size_t responseLen) {
4491*062a843bSAndroid Build Coastguard Worker #if VDBG
4492*062a843bSAndroid Build Coastguard Worker     RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4493*062a843bSAndroid Build Coastguard Worker #endif
4494*062a843bSAndroid Build Coastguard Worker 
4495*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4496*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4497*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4498*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4499*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4500*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4501*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4502*062a843bSAndroid Build Coastguard Worker     } else {
4503*062a843bSAndroid Build Coastguard Worker         RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4504*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
4505*062a843bSAndroid Build Coastguard Worker     }
4506*062a843bSAndroid Build Coastguard Worker 
4507*062a843bSAndroid Build Coastguard Worker     return 0;
4508*062a843bSAndroid Build Coastguard Worker }
4509*062a843bSAndroid Build Coastguard Worker 
setNetworkSelectionModeManualResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4510*062a843bSAndroid Build Coastguard Worker int radio::setNetworkSelectionModeManualResponse(int slotId,
4511*062a843bSAndroid Build Coastguard Worker                              int responseType, int serial, RIL_Errno e,
4512*062a843bSAndroid Build Coastguard Worker                              void *response, size_t responseLen) {
4513*062a843bSAndroid Build Coastguard Worker #if VDBG
4514*062a843bSAndroid Build Coastguard Worker     RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4515*062a843bSAndroid Build Coastguard Worker #endif
4516*062a843bSAndroid Build Coastguard Worker 
4517*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4518*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4519*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4520*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4521*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4522*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4523*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4524*062a843bSAndroid Build Coastguard Worker     } else {
4525*062a843bSAndroid Build Coastguard Worker         RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4526*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
4527*062a843bSAndroid Build Coastguard Worker     }
4528*062a843bSAndroid Build Coastguard Worker 
4529*062a843bSAndroid Build Coastguard Worker     return 0;
4530*062a843bSAndroid Build Coastguard Worker }
4531*062a843bSAndroid Build Coastguard Worker 
convertOperatorStatusToInt(const char * str)4532*062a843bSAndroid Build Coastguard Worker int convertOperatorStatusToInt(const char *str) {
4533*062a843bSAndroid Build Coastguard Worker     if (strncmp("unknown", str, 9) == 0) {
4534*062a843bSAndroid Build Coastguard Worker         return (int) OperatorStatus::UNKNOWN;
4535*062a843bSAndroid Build Coastguard Worker     } else if (strncmp("available", str, 9) == 0) {
4536*062a843bSAndroid Build Coastguard Worker         return (int) OperatorStatus::AVAILABLE;
4537*062a843bSAndroid Build Coastguard Worker     } else if (strncmp("current", str, 9) == 0) {
4538*062a843bSAndroid Build Coastguard Worker         return (int) OperatorStatus::CURRENT;
4539*062a843bSAndroid Build Coastguard Worker     } else if (strncmp("forbidden", str, 9) == 0) {
4540*062a843bSAndroid Build Coastguard Worker         return (int) OperatorStatus::FORBIDDEN;
4541*062a843bSAndroid Build Coastguard Worker     } else {
4542*062a843bSAndroid Build Coastguard Worker         return -1;
4543*062a843bSAndroid Build Coastguard Worker     }
4544*062a843bSAndroid Build Coastguard Worker }
4545*062a843bSAndroid Build Coastguard Worker 
getAvailableNetworksResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4546*062a843bSAndroid Build Coastguard Worker int radio::getAvailableNetworksResponse(int slotId,
4547*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e, void *response,
4548*062a843bSAndroid Build Coastguard Worker                               size_t responseLen) {
4549*062a843bSAndroid Build Coastguard Worker #if VDBG
4550*062a843bSAndroid Build Coastguard Worker     RLOGD("getAvailableNetworksResponse: serial %d", serial);
4551*062a843bSAndroid Build Coastguard Worker #endif
4552*062a843bSAndroid Build Coastguard Worker 
4553*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4554*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4555*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4556*062a843bSAndroid Build Coastguard Worker         hidl_vec<OperatorInfo> networks;
4557*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
4558*062a843bSAndroid Build Coastguard Worker                 || responseLen % (4 * sizeof(char *))!= 0) {
4559*062a843bSAndroid Build Coastguard Worker             RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4560*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4561*062a843bSAndroid Build Coastguard Worker         } else {
4562*062a843bSAndroid Build Coastguard Worker             char **resp = (char **) response;
4563*062a843bSAndroid Build Coastguard Worker             int numStrings = responseLen / sizeof(char *);
4564*062a843bSAndroid Build Coastguard Worker             networks.resize(numStrings/4);
4565*062a843bSAndroid Build Coastguard Worker             for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4566*062a843bSAndroid Build Coastguard Worker                 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4567*062a843bSAndroid Build Coastguard Worker                 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4568*062a843bSAndroid Build Coastguard Worker                 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4569*062a843bSAndroid Build Coastguard Worker                 int status = convertOperatorStatusToInt(resp[i + 3]);
4570*062a843bSAndroid Build Coastguard Worker                 if (status == -1) {
4571*062a843bSAndroid Build Coastguard Worker                     if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4572*062a843bSAndroid Build Coastguard Worker                 } else {
4573*062a843bSAndroid Build Coastguard Worker                     networks[j].status = (OperatorStatus) status;
4574*062a843bSAndroid Build Coastguard Worker                 }
4575*062a843bSAndroid Build Coastguard Worker             }
4576*062a843bSAndroid Build Coastguard Worker         }
4577*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4578*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4579*062a843bSAndroid Build Coastguard Worker                 networks);
4580*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4581*062a843bSAndroid Build Coastguard Worker     } else {
4582*062a843bSAndroid Build Coastguard Worker         RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4583*062a843bSAndroid Build Coastguard Worker                 slotId);
4584*062a843bSAndroid Build Coastguard Worker     }
4585*062a843bSAndroid Build Coastguard Worker 
4586*062a843bSAndroid Build Coastguard Worker     return 0;
4587*062a843bSAndroid Build Coastguard Worker }
4588*062a843bSAndroid Build Coastguard Worker 
startDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4589*062a843bSAndroid Build Coastguard Worker int radio::startDtmfResponse(int slotId,
4590*062a843bSAndroid Build Coastguard Worker                             int responseType, int serial, RIL_Errno e,
4591*062a843bSAndroid Build Coastguard Worker                             void *response, size_t responseLen) {
4592*062a843bSAndroid Build Coastguard Worker #if VDBG
4593*062a843bSAndroid Build Coastguard Worker     RLOGD("startDtmfResponse: serial %d", serial);
4594*062a843bSAndroid Build Coastguard Worker #endif
4595*062a843bSAndroid Build Coastguard Worker 
4596*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4597*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4598*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4599*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4600*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4601*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4602*062a843bSAndroid Build Coastguard Worker     } else {
4603*062a843bSAndroid Build Coastguard Worker         RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4604*062a843bSAndroid Build Coastguard Worker     }
4605*062a843bSAndroid Build Coastguard Worker 
4606*062a843bSAndroid Build Coastguard Worker     return 0;
4607*062a843bSAndroid Build Coastguard Worker }
4608*062a843bSAndroid Build Coastguard Worker 
stopDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4609*062a843bSAndroid Build Coastguard Worker int radio::stopDtmfResponse(int slotId,
4610*062a843bSAndroid Build Coastguard Worker                            int responseType, int serial, RIL_Errno e,
4611*062a843bSAndroid Build Coastguard Worker                            void *response, size_t responseLen) {
4612*062a843bSAndroid Build Coastguard Worker #if VDBG
4613*062a843bSAndroid Build Coastguard Worker     RLOGD("stopDtmfResponse: serial %d", serial);
4614*062a843bSAndroid Build Coastguard Worker #endif
4615*062a843bSAndroid Build Coastguard Worker 
4616*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4617*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4618*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4619*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4620*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4621*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4622*062a843bSAndroid Build Coastguard Worker     } else {
4623*062a843bSAndroid Build Coastguard Worker         RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4624*062a843bSAndroid Build Coastguard Worker     }
4625*062a843bSAndroid Build Coastguard Worker 
4626*062a843bSAndroid Build Coastguard Worker     return 0;
4627*062a843bSAndroid Build Coastguard Worker }
4628*062a843bSAndroid Build Coastguard Worker 
getBasebandVersionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4629*062a843bSAndroid Build Coastguard Worker int radio::getBasebandVersionResponse(int slotId,
4630*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
4631*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
4632*062a843bSAndroid Build Coastguard Worker #if VDBG
4633*062a843bSAndroid Build Coastguard Worker     RLOGD("getBasebandVersionResponse: serial %d", serial);
4634*062a843bSAndroid Build Coastguard Worker #endif
4635*062a843bSAndroid Build Coastguard Worker 
4636*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4637*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4638*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4639*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4640*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4641*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
4642*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4643*062a843bSAndroid Build Coastguard Worker     } else {
4644*062a843bSAndroid Build Coastguard Worker         RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4645*062a843bSAndroid Build Coastguard Worker     }
4646*062a843bSAndroid Build Coastguard Worker 
4647*062a843bSAndroid Build Coastguard Worker     return 0;
4648*062a843bSAndroid Build Coastguard Worker }
4649*062a843bSAndroid Build Coastguard Worker 
separateConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4650*062a843bSAndroid Build Coastguard Worker int radio::separateConnectionResponse(int slotId,
4651*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
4652*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
4653*062a843bSAndroid Build Coastguard Worker #if VDBG
4654*062a843bSAndroid Build Coastguard Worker     RLOGD("separateConnectionResponse: serial %d", serial);
4655*062a843bSAndroid Build Coastguard Worker #endif
4656*062a843bSAndroid Build Coastguard Worker 
4657*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4658*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4659*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4660*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4661*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4662*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4663*062a843bSAndroid Build Coastguard Worker     } else {
4664*062a843bSAndroid Build Coastguard Worker         RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4665*062a843bSAndroid Build Coastguard Worker                 slotId);
4666*062a843bSAndroid Build Coastguard Worker     }
4667*062a843bSAndroid Build Coastguard Worker 
4668*062a843bSAndroid Build Coastguard Worker     return 0;
4669*062a843bSAndroid Build Coastguard Worker }
4670*062a843bSAndroid Build Coastguard Worker 
setMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4671*062a843bSAndroid Build Coastguard Worker int radio::setMuteResponse(int slotId,
4672*062a843bSAndroid Build Coastguard Worker                           int responseType, int serial, RIL_Errno e,
4673*062a843bSAndroid Build Coastguard Worker                           void *response, size_t responseLen) {
4674*062a843bSAndroid Build Coastguard Worker #if VDBG
4675*062a843bSAndroid Build Coastguard Worker     RLOGD("setMuteResponse: serial %d", serial);
4676*062a843bSAndroid Build Coastguard Worker #endif
4677*062a843bSAndroid Build Coastguard Worker 
4678*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4679*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4680*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4681*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4682*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4683*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4684*062a843bSAndroid Build Coastguard Worker     } else {
4685*062a843bSAndroid Build Coastguard Worker         RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4686*062a843bSAndroid Build Coastguard Worker     }
4687*062a843bSAndroid Build Coastguard Worker 
4688*062a843bSAndroid Build Coastguard Worker     return 0;
4689*062a843bSAndroid Build Coastguard Worker }
4690*062a843bSAndroid Build Coastguard Worker 
getMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4691*062a843bSAndroid Build Coastguard Worker int radio::getMuteResponse(int slotId,
4692*062a843bSAndroid Build Coastguard Worker                           int responseType, int serial, RIL_Errno e, void *response,
4693*062a843bSAndroid Build Coastguard Worker                           size_t responseLen) {
4694*062a843bSAndroid Build Coastguard Worker #if VDBG
4695*062a843bSAndroid Build Coastguard Worker     RLOGD("getMuteResponse: serial %d", serial);
4696*062a843bSAndroid Build Coastguard Worker #endif
4697*062a843bSAndroid Build Coastguard Worker 
4698*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4699*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4700*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4701*062a843bSAndroid Build Coastguard Worker         bool enable = false;
4702*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
4703*062a843bSAndroid Build Coastguard Worker             RLOGE("getMuteResponse Invalid response: NULL");
4704*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4705*062a843bSAndroid Build Coastguard Worker         } else {
4706*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
4707*062a843bSAndroid Build Coastguard Worker             enable = pInt[0] == 1 ? true : false;
4708*062a843bSAndroid Build Coastguard Worker         }
4709*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4710*062a843bSAndroid Build Coastguard Worker                 enable);
4711*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4712*062a843bSAndroid Build Coastguard Worker     } else {
4713*062a843bSAndroid Build Coastguard Worker         RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4714*062a843bSAndroid Build Coastguard Worker     }
4715*062a843bSAndroid Build Coastguard Worker 
4716*062a843bSAndroid Build Coastguard Worker     return 0;
4717*062a843bSAndroid Build Coastguard Worker }
4718*062a843bSAndroid Build Coastguard Worker 
getClipResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4719*062a843bSAndroid Build Coastguard Worker int radio::getClipResponse(int slotId,
4720*062a843bSAndroid Build Coastguard Worker                           int responseType, int serial, RIL_Errno e,
4721*062a843bSAndroid Build Coastguard Worker                           void *response, size_t responseLen) {
4722*062a843bSAndroid Build Coastguard Worker #if VDBG
4723*062a843bSAndroid Build Coastguard Worker     RLOGD("getClipResponse: serial %d", serial);
4724*062a843bSAndroid Build Coastguard Worker #endif
4725*062a843bSAndroid Build Coastguard Worker 
4726*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4727*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4728*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4729*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4730*062a843bSAndroid Build Coastguard Worker                 (ClipStatus) ret);
4731*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4732*062a843bSAndroid Build Coastguard Worker     } else {
4733*062a843bSAndroid Build Coastguard Worker         RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4734*062a843bSAndroid Build Coastguard Worker     }
4735*062a843bSAndroid Build Coastguard Worker 
4736*062a843bSAndroid Build Coastguard Worker     return 0;
4737*062a843bSAndroid Build Coastguard Worker }
4738*062a843bSAndroid Build Coastguard Worker 
getDataCallListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4739*062a843bSAndroid Build Coastguard Worker int radio::getDataCallListResponse(int slotId,
4740*062a843bSAndroid Build Coastguard Worker                                    int responseType, int serial, RIL_Errno e,
4741*062a843bSAndroid Build Coastguard Worker                                    void *response, size_t responseLen) {
4742*062a843bSAndroid Build Coastguard Worker #if VDBG
4743*062a843bSAndroid Build Coastguard Worker     RLOGD("getDataCallListResponse: serial %d", serial);
4744*062a843bSAndroid Build Coastguard Worker #endif
4745*062a843bSAndroid Build Coastguard Worker 
4746*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4747*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4748*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4749*062a843bSAndroid Build Coastguard Worker 
4750*062a843bSAndroid Build Coastguard Worker         hidl_vec<SetupDataCallResult> ret;
4751*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
4752*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4753*062a843bSAndroid Build Coastguard Worker             RLOGE("getDataCallListResponse: invalid response");
4754*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4755*062a843bSAndroid Build Coastguard Worker         } else {
4756*062a843bSAndroid Build Coastguard Worker             convertRilDataCallListToHal(response, responseLen, ret);
4757*062a843bSAndroid Build Coastguard Worker         }
4758*062a843bSAndroid Build Coastguard Worker 
4759*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4760*062a843bSAndroid Build Coastguard Worker                 responseInfo, ret);
4761*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4762*062a843bSAndroid Build Coastguard Worker     } else {
4763*062a843bSAndroid Build Coastguard Worker         RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4764*062a843bSAndroid Build Coastguard Worker     }
4765*062a843bSAndroid Build Coastguard Worker 
4766*062a843bSAndroid Build Coastguard Worker     return 0;
4767*062a843bSAndroid Build Coastguard Worker }
4768*062a843bSAndroid Build Coastguard Worker 
setSuppServiceNotificationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4769*062a843bSAndroid Build Coastguard Worker int radio::setSuppServiceNotificationsResponse(int slotId,
4770*062a843bSAndroid Build Coastguard Worker                                               int responseType, int serial, RIL_Errno e,
4771*062a843bSAndroid Build Coastguard Worker                                               void *response, size_t responseLen) {
4772*062a843bSAndroid Build Coastguard Worker #if VDBG
4773*062a843bSAndroid Build Coastguard Worker     RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4774*062a843bSAndroid Build Coastguard Worker #endif
4775*062a843bSAndroid Build Coastguard Worker 
4776*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4777*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4778*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4779*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4780*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4781*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4782*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4783*062a843bSAndroid Build Coastguard Worker     } else {
4784*062a843bSAndroid Build Coastguard Worker         RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4785*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
4786*062a843bSAndroid Build Coastguard Worker     }
4787*062a843bSAndroid Build Coastguard Worker 
4788*062a843bSAndroid Build Coastguard Worker     return 0;
4789*062a843bSAndroid Build Coastguard Worker }
4790*062a843bSAndroid Build Coastguard Worker 
deleteSmsOnSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4791*062a843bSAndroid Build Coastguard Worker int radio::deleteSmsOnSimResponse(int slotId,
4792*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
4793*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
4794*062a843bSAndroid Build Coastguard Worker #if VDBG
4795*062a843bSAndroid Build Coastguard Worker     RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4796*062a843bSAndroid Build Coastguard Worker #endif
4797*062a843bSAndroid Build Coastguard Worker 
4798*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4799*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4800*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4801*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4802*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4803*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4804*062a843bSAndroid Build Coastguard Worker     } else {
4805*062a843bSAndroid Build Coastguard Worker         RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4806*062a843bSAndroid Build Coastguard Worker     }
4807*062a843bSAndroid Build Coastguard Worker 
4808*062a843bSAndroid Build Coastguard Worker     return 0;
4809*062a843bSAndroid Build Coastguard Worker }
4810*062a843bSAndroid Build Coastguard Worker 
setBandModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4811*062a843bSAndroid Build Coastguard Worker int radio::setBandModeResponse(int slotId,
4812*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e,
4813*062a843bSAndroid Build Coastguard Worker                               void *response, size_t responseLen) {
4814*062a843bSAndroid Build Coastguard Worker #if VDBG
4815*062a843bSAndroid Build Coastguard Worker     RLOGD("setBandModeResponse: serial %d", serial);
4816*062a843bSAndroid Build Coastguard Worker #endif
4817*062a843bSAndroid Build Coastguard Worker 
4818*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4819*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4820*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4821*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4822*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4823*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4824*062a843bSAndroid Build Coastguard Worker     } else {
4825*062a843bSAndroid Build Coastguard Worker         RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4826*062a843bSAndroid Build Coastguard Worker     }
4827*062a843bSAndroid Build Coastguard Worker 
4828*062a843bSAndroid Build Coastguard Worker     return 0;
4829*062a843bSAndroid Build Coastguard Worker }
4830*062a843bSAndroid Build Coastguard Worker 
writeSmsToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4831*062a843bSAndroid Build Coastguard Worker int radio::writeSmsToSimResponse(int slotId,
4832*062a843bSAndroid Build Coastguard Worker                                 int responseType, int serial, RIL_Errno e,
4833*062a843bSAndroid Build Coastguard Worker                                 void *response, size_t responseLen) {
4834*062a843bSAndroid Build Coastguard Worker #if VDBG
4835*062a843bSAndroid Build Coastguard Worker     RLOGD("writeSmsToSimResponse: serial %d", serial);
4836*062a843bSAndroid Build Coastguard Worker #endif
4837*062a843bSAndroid Build Coastguard Worker 
4838*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4839*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4840*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4841*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4842*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4843*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4844*062a843bSAndroid Build Coastguard Worker     } else {
4845*062a843bSAndroid Build Coastguard Worker         RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4846*062a843bSAndroid Build Coastguard Worker     }
4847*062a843bSAndroid Build Coastguard Worker 
4848*062a843bSAndroid Build Coastguard Worker     return 0;
4849*062a843bSAndroid Build Coastguard Worker }
4850*062a843bSAndroid Build Coastguard Worker 
getAvailableBandModesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4851*062a843bSAndroid Build Coastguard Worker int radio::getAvailableBandModesResponse(int slotId,
4852*062a843bSAndroid Build Coastguard Worker                                         int responseType, int serial, RIL_Errno e, void *response,
4853*062a843bSAndroid Build Coastguard Worker                                         size_t responseLen) {
4854*062a843bSAndroid Build Coastguard Worker #if VDBG
4855*062a843bSAndroid Build Coastguard Worker     RLOGD("getAvailableBandModesResponse: serial %d", serial);
4856*062a843bSAndroid Build Coastguard Worker #endif
4857*062a843bSAndroid Build Coastguard Worker 
4858*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4859*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4860*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4861*062a843bSAndroid Build Coastguard Worker         hidl_vec<RadioBandMode> modes;
4862*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4863*062a843bSAndroid Build Coastguard Worker             RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4864*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4865*062a843bSAndroid Build Coastguard Worker         } else {
4866*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
4867*062a843bSAndroid Build Coastguard Worker             int numInts = responseLen / sizeof(int);
4868*062a843bSAndroid Build Coastguard Worker             modes.resize(numInts);
4869*062a843bSAndroid Build Coastguard Worker             for (int i = 0; i < numInts; i++) {
4870*062a843bSAndroid Build Coastguard Worker                 modes[i] = (RadioBandMode) pInt[i];
4871*062a843bSAndroid Build Coastguard Worker             }
4872*062a843bSAndroid Build Coastguard Worker         }
4873*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4874*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4875*062a843bSAndroid Build Coastguard Worker                 modes);
4876*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4877*062a843bSAndroid Build Coastguard Worker     } else {
4878*062a843bSAndroid Build Coastguard Worker         RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4879*062a843bSAndroid Build Coastguard Worker                 slotId);
4880*062a843bSAndroid Build Coastguard Worker     }
4881*062a843bSAndroid Build Coastguard Worker 
4882*062a843bSAndroid Build Coastguard Worker     return 0;
4883*062a843bSAndroid Build Coastguard Worker }
4884*062a843bSAndroid Build Coastguard Worker 
sendEnvelopeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4885*062a843bSAndroid Build Coastguard Worker int radio::sendEnvelopeResponse(int slotId,
4886*062a843bSAndroid Build Coastguard Worker                                int responseType, int serial, RIL_Errno e,
4887*062a843bSAndroid Build Coastguard Worker                                void *response, size_t responseLen) {
4888*062a843bSAndroid Build Coastguard Worker #if VDBG
4889*062a843bSAndroid Build Coastguard Worker     RLOGD("sendEnvelopeResponse: serial %d", serial);
4890*062a843bSAndroid Build Coastguard Worker #endif
4891*062a843bSAndroid Build Coastguard Worker 
4892*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4893*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4894*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4895*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4896*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4897*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
4898*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4899*062a843bSAndroid Build Coastguard Worker     } else {
4900*062a843bSAndroid Build Coastguard Worker         RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4901*062a843bSAndroid Build Coastguard Worker     }
4902*062a843bSAndroid Build Coastguard Worker 
4903*062a843bSAndroid Build Coastguard Worker     return 0;
4904*062a843bSAndroid Build Coastguard Worker }
4905*062a843bSAndroid Build Coastguard Worker 
sendTerminalResponseToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4906*062a843bSAndroid Build Coastguard Worker int radio::sendTerminalResponseToSimResponse(int slotId,
4907*062a843bSAndroid Build Coastguard Worker                                             int responseType, int serial, RIL_Errno e,
4908*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
4909*062a843bSAndroid Build Coastguard Worker #if VDBG
4910*062a843bSAndroid Build Coastguard Worker     RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4911*062a843bSAndroid Build Coastguard Worker #endif
4912*062a843bSAndroid Build Coastguard Worker 
4913*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4914*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4915*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4916*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4917*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4918*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4919*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4920*062a843bSAndroid Build Coastguard Worker     } else {
4921*062a843bSAndroid Build Coastguard Worker         RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4922*062a843bSAndroid Build Coastguard Worker                 slotId);
4923*062a843bSAndroid Build Coastguard Worker     }
4924*062a843bSAndroid Build Coastguard Worker 
4925*062a843bSAndroid Build Coastguard Worker     return 0;
4926*062a843bSAndroid Build Coastguard Worker }
4927*062a843bSAndroid Build Coastguard Worker 
handleStkCallSetupRequestFromSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4928*062a843bSAndroid Build Coastguard Worker int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4929*062a843bSAndroid Build Coastguard Worker                                                    int responseType, int serial,
4930*062a843bSAndroid Build Coastguard Worker                                                    RIL_Errno e, void *response,
4931*062a843bSAndroid Build Coastguard Worker                                                    size_t responseLen) {
4932*062a843bSAndroid Build Coastguard Worker #if VDBG
4933*062a843bSAndroid Build Coastguard Worker     RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4934*062a843bSAndroid Build Coastguard Worker #endif
4935*062a843bSAndroid Build Coastguard Worker 
4936*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4937*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4938*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4939*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4940*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4941*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4942*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4943*062a843bSAndroid Build Coastguard Worker     } else {
4944*062a843bSAndroid Build Coastguard Worker         RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4945*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
4946*062a843bSAndroid Build Coastguard Worker     }
4947*062a843bSAndroid Build Coastguard Worker 
4948*062a843bSAndroid Build Coastguard Worker     return 0;
4949*062a843bSAndroid Build Coastguard Worker }
4950*062a843bSAndroid Build Coastguard Worker 
explicitCallTransferResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4951*062a843bSAndroid Build Coastguard Worker int radio::explicitCallTransferResponse(int slotId,
4952*062a843bSAndroid Build Coastguard Worker                                        int responseType, int serial, RIL_Errno e,
4953*062a843bSAndroid Build Coastguard Worker                                        void *response, size_t responseLen) {
4954*062a843bSAndroid Build Coastguard Worker #if VDBG
4955*062a843bSAndroid Build Coastguard Worker     RLOGD("explicitCallTransferResponse: serial %d", serial);
4956*062a843bSAndroid Build Coastguard Worker #endif
4957*062a843bSAndroid Build Coastguard Worker 
4958*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4959*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4960*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4961*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4962*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4963*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4964*062a843bSAndroid Build Coastguard Worker     } else {
4965*062a843bSAndroid Build Coastguard Worker         RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4966*062a843bSAndroid Build Coastguard Worker                 slotId);
4967*062a843bSAndroid Build Coastguard Worker     }
4968*062a843bSAndroid Build Coastguard Worker 
4969*062a843bSAndroid Build Coastguard Worker     return 0;
4970*062a843bSAndroid Build Coastguard Worker }
4971*062a843bSAndroid Build Coastguard Worker 
setPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4972*062a843bSAndroid Build Coastguard Worker int radio::setPreferredNetworkTypeResponse(int slotId,
4973*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
4974*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
4975*062a843bSAndroid Build Coastguard Worker #if VDBG
4976*062a843bSAndroid Build Coastguard Worker     RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4977*062a843bSAndroid Build Coastguard Worker #endif
4978*062a843bSAndroid Build Coastguard Worker 
4979*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
4980*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
4981*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
4982*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
4983*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4984*062a843bSAndroid Build Coastguard Worker                 responseInfo);
4985*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
4986*062a843bSAndroid Build Coastguard Worker     } else {
4987*062a843bSAndroid Build Coastguard Worker         RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4988*062a843bSAndroid Build Coastguard Worker                 slotId);
4989*062a843bSAndroid Build Coastguard Worker     }
4990*062a843bSAndroid Build Coastguard Worker 
4991*062a843bSAndroid Build Coastguard Worker     return 0;
4992*062a843bSAndroid Build Coastguard Worker }
4993*062a843bSAndroid Build Coastguard Worker 
4994*062a843bSAndroid Build Coastguard Worker 
getPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4995*062a843bSAndroid Build Coastguard Worker int radio::getPreferredNetworkTypeResponse(int slotId,
4996*062a843bSAndroid Build Coastguard Worker                                           int responseType, int serial, RIL_Errno e,
4997*062a843bSAndroid Build Coastguard Worker                                           void *response, size_t responseLen) {
4998*062a843bSAndroid Build Coastguard Worker #if VDBG
4999*062a843bSAndroid Build Coastguard Worker     RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
5000*062a843bSAndroid Build Coastguard Worker #endif
5001*062a843bSAndroid Build Coastguard Worker 
5002*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5003*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5004*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5005*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5006*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
5007*062a843bSAndroid Build Coastguard Worker                 responseInfo, (PreferredNetworkType) ret);
5008*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5009*062a843bSAndroid Build Coastguard Worker     } else {
5010*062a843bSAndroid Build Coastguard Worker         RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
5011*062a843bSAndroid Build Coastguard Worker                 slotId);
5012*062a843bSAndroid Build Coastguard Worker     }
5013*062a843bSAndroid Build Coastguard Worker 
5014*062a843bSAndroid Build Coastguard Worker     return 0;
5015*062a843bSAndroid Build Coastguard Worker }
5016*062a843bSAndroid Build Coastguard Worker 
getNeighboringCidsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5017*062a843bSAndroid Build Coastguard Worker int radio::getNeighboringCidsResponse(int slotId,
5018*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
5019*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
5020*062a843bSAndroid Build Coastguard Worker #if VDBG
5021*062a843bSAndroid Build Coastguard Worker     RLOGD("getNeighboringCidsResponse: serial %d", serial);
5022*062a843bSAndroid Build Coastguard Worker #endif
5023*062a843bSAndroid Build Coastguard Worker 
5024*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5025*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5026*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5027*062a843bSAndroid Build Coastguard Worker         hidl_vec<NeighboringCell> cells;
5028*062a843bSAndroid Build Coastguard Worker 
5029*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
5030*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
5031*062a843bSAndroid Build Coastguard Worker             RLOGE("getNeighboringCidsResponse Invalid response: NULL");
5032*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5033*062a843bSAndroid Build Coastguard Worker         } else {
5034*062a843bSAndroid Build Coastguard Worker             int num = responseLen / sizeof(RIL_NeighboringCell *);
5035*062a843bSAndroid Build Coastguard Worker             cells.resize(num);
5036*062a843bSAndroid Build Coastguard Worker             for (int i = 0 ; i < num; i++) {
5037*062a843bSAndroid Build Coastguard Worker                 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
5038*062a843bSAndroid Build Coastguard Worker                 cells[i].cid = convertCharPtrToHidlString(resp->cid);
5039*062a843bSAndroid Build Coastguard Worker                 cells[i].rssi = resp->rssi;
5040*062a843bSAndroid Build Coastguard Worker             }
5041*062a843bSAndroid Build Coastguard Worker         }
5042*062a843bSAndroid Build Coastguard Worker 
5043*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5044*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
5045*062a843bSAndroid Build Coastguard Worker                 cells);
5046*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5047*062a843bSAndroid Build Coastguard Worker     } else {
5048*062a843bSAndroid Build Coastguard Worker         RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
5049*062a843bSAndroid Build Coastguard Worker                 slotId);
5050*062a843bSAndroid Build Coastguard Worker     }
5051*062a843bSAndroid Build Coastguard Worker 
5052*062a843bSAndroid Build Coastguard Worker     return 0;
5053*062a843bSAndroid Build Coastguard Worker }
5054*062a843bSAndroid Build Coastguard Worker 
setLocationUpdatesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5055*062a843bSAndroid Build Coastguard Worker int radio::setLocationUpdatesResponse(int slotId,
5056*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
5057*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
5058*062a843bSAndroid Build Coastguard Worker #if VDBG
5059*062a843bSAndroid Build Coastguard Worker     RLOGD("setLocationUpdatesResponse: serial %d", serial);
5060*062a843bSAndroid Build Coastguard Worker #endif
5061*062a843bSAndroid Build Coastguard Worker 
5062*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5063*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5064*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5065*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5066*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
5067*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5068*062a843bSAndroid Build Coastguard Worker     } else {
5069*062a843bSAndroid Build Coastguard Worker         RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
5070*062a843bSAndroid Build Coastguard Worker                 slotId);
5071*062a843bSAndroid Build Coastguard Worker     }
5072*062a843bSAndroid Build Coastguard Worker 
5073*062a843bSAndroid Build Coastguard Worker     return 0;
5074*062a843bSAndroid Build Coastguard Worker }
5075*062a843bSAndroid Build Coastguard Worker 
setCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5076*062a843bSAndroid Build Coastguard Worker int radio::setCdmaSubscriptionSourceResponse(int slotId,
5077*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
5078*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
5079*062a843bSAndroid Build Coastguard Worker #if VDBG
5080*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
5081*062a843bSAndroid Build Coastguard Worker #endif
5082*062a843bSAndroid Build Coastguard Worker 
5083*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5084*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5085*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5086*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5087*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
5088*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5089*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5090*062a843bSAndroid Build Coastguard Worker     } else {
5091*062a843bSAndroid Build Coastguard Worker         RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5092*062a843bSAndroid Build Coastguard Worker                 slotId);
5093*062a843bSAndroid Build Coastguard Worker     }
5094*062a843bSAndroid Build Coastguard Worker 
5095*062a843bSAndroid Build Coastguard Worker     return 0;
5096*062a843bSAndroid Build Coastguard Worker }
5097*062a843bSAndroid Build Coastguard Worker 
setCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5098*062a843bSAndroid Build Coastguard Worker int radio::setCdmaRoamingPreferenceResponse(int slotId,
5099*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
5100*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
5101*062a843bSAndroid Build Coastguard Worker #if VDBG
5102*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
5103*062a843bSAndroid Build Coastguard Worker #endif
5104*062a843bSAndroid Build Coastguard Worker 
5105*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5106*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5107*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5108*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5109*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
5110*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5111*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5112*062a843bSAndroid Build Coastguard Worker     } else {
5113*062a843bSAndroid Build Coastguard Worker         RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5114*062a843bSAndroid Build Coastguard Worker                 slotId);
5115*062a843bSAndroid Build Coastguard Worker     }
5116*062a843bSAndroid Build Coastguard Worker 
5117*062a843bSAndroid Build Coastguard Worker     return 0;
5118*062a843bSAndroid Build Coastguard Worker }
5119*062a843bSAndroid Build Coastguard Worker 
getCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5120*062a843bSAndroid Build Coastguard Worker int radio::getCdmaRoamingPreferenceResponse(int slotId,
5121*062a843bSAndroid Build Coastguard Worker                                            int responseType, int serial, RIL_Errno e,
5122*062a843bSAndroid Build Coastguard Worker                                            void *response, size_t responseLen) {
5123*062a843bSAndroid Build Coastguard Worker #if VDBG
5124*062a843bSAndroid Build Coastguard Worker     RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
5125*062a843bSAndroid Build Coastguard Worker #endif
5126*062a843bSAndroid Build Coastguard Worker 
5127*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5128*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5129*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5130*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5131*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
5132*062a843bSAndroid Build Coastguard Worker                 responseInfo, (CdmaRoamingType) ret);
5133*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5134*062a843bSAndroid Build Coastguard Worker     } else {
5135*062a843bSAndroid Build Coastguard Worker         RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5136*062a843bSAndroid Build Coastguard Worker                 slotId);
5137*062a843bSAndroid Build Coastguard Worker     }
5138*062a843bSAndroid Build Coastguard Worker 
5139*062a843bSAndroid Build Coastguard Worker     return 0;
5140*062a843bSAndroid Build Coastguard Worker }
5141*062a843bSAndroid Build Coastguard Worker 
setTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5142*062a843bSAndroid Build Coastguard Worker int radio::setTTYModeResponse(int slotId,
5143*062a843bSAndroid Build Coastguard Worker                              int responseType, int serial, RIL_Errno e,
5144*062a843bSAndroid Build Coastguard Worker                              void *response, size_t responseLen) {
5145*062a843bSAndroid Build Coastguard Worker #if VDBG
5146*062a843bSAndroid Build Coastguard Worker     RLOGD("setTTYModeResponse: serial %d", serial);
5147*062a843bSAndroid Build Coastguard Worker #endif
5148*062a843bSAndroid Build Coastguard Worker 
5149*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5150*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5151*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5152*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5153*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
5154*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5155*062a843bSAndroid Build Coastguard Worker     } else {
5156*062a843bSAndroid Build Coastguard Worker         RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5157*062a843bSAndroid Build Coastguard Worker     }
5158*062a843bSAndroid Build Coastguard Worker 
5159*062a843bSAndroid Build Coastguard Worker     return 0;
5160*062a843bSAndroid Build Coastguard Worker }
5161*062a843bSAndroid Build Coastguard Worker 
getTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5162*062a843bSAndroid Build Coastguard Worker int radio::getTTYModeResponse(int slotId,
5163*062a843bSAndroid Build Coastguard Worker                              int responseType, int serial, RIL_Errno e,
5164*062a843bSAndroid Build Coastguard Worker                              void *response, size_t responseLen) {
5165*062a843bSAndroid Build Coastguard Worker #if VDBG
5166*062a843bSAndroid Build Coastguard Worker     RLOGD("getTTYModeResponse: serial %d", serial);
5167*062a843bSAndroid Build Coastguard Worker #endif
5168*062a843bSAndroid Build Coastguard Worker 
5169*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5170*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5171*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5172*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5173*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
5174*062a843bSAndroid Build Coastguard Worker                 (TtyMode) ret);
5175*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5176*062a843bSAndroid Build Coastguard Worker     } else {
5177*062a843bSAndroid Build Coastguard Worker         RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5178*062a843bSAndroid Build Coastguard Worker     }
5179*062a843bSAndroid Build Coastguard Worker 
5180*062a843bSAndroid Build Coastguard Worker     return 0;
5181*062a843bSAndroid Build Coastguard Worker }
5182*062a843bSAndroid Build Coastguard Worker 
setPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5183*062a843bSAndroid Build Coastguard Worker int radio::setPreferredVoicePrivacyResponse(int slotId,
5184*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
5185*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
5186*062a843bSAndroid Build Coastguard Worker #if VDBG
5187*062a843bSAndroid Build Coastguard Worker     RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5188*062a843bSAndroid Build Coastguard Worker #endif
5189*062a843bSAndroid Build Coastguard Worker 
5190*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5191*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5192*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5193*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5194*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5195*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5196*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5197*062a843bSAndroid Build Coastguard Worker     } else {
5198*062a843bSAndroid Build Coastguard Worker         RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5199*062a843bSAndroid Build Coastguard Worker                 slotId);
5200*062a843bSAndroid Build Coastguard Worker     }
5201*062a843bSAndroid Build Coastguard Worker 
5202*062a843bSAndroid Build Coastguard Worker     return 0;
5203*062a843bSAndroid Build Coastguard Worker }
5204*062a843bSAndroid Build Coastguard Worker 
getPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5205*062a843bSAndroid Build Coastguard Worker int radio::getPreferredVoicePrivacyResponse(int slotId,
5206*062a843bSAndroid Build Coastguard Worker                                            int responseType, int serial, RIL_Errno e,
5207*062a843bSAndroid Build Coastguard Worker                                            void *response, size_t responseLen) {
5208*062a843bSAndroid Build Coastguard Worker #if VDBG
5209*062a843bSAndroid Build Coastguard Worker     RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5210*062a843bSAndroid Build Coastguard Worker #endif
5211*062a843bSAndroid Build Coastguard Worker 
5212*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5213*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5214*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5215*062a843bSAndroid Build Coastguard Worker         bool enable = false;
5216*062a843bSAndroid Build Coastguard Worker         int numInts = responseLen / sizeof(int);
5217*062a843bSAndroid Build Coastguard Worker         if (response == NULL || numInts != 1) {
5218*062a843bSAndroid Build Coastguard Worker             RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5219*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5220*062a843bSAndroid Build Coastguard Worker         } else {
5221*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
5222*062a843bSAndroid Build Coastguard Worker             enable = pInt[0] == 1 ? true : false;
5223*062a843bSAndroid Build Coastguard Worker         }
5224*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5225*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5226*062a843bSAndroid Build Coastguard Worker                 responseInfo, enable);
5227*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5228*062a843bSAndroid Build Coastguard Worker     } else {
5229*062a843bSAndroid Build Coastguard Worker         RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5230*062a843bSAndroid Build Coastguard Worker                 slotId);
5231*062a843bSAndroid Build Coastguard Worker     }
5232*062a843bSAndroid Build Coastguard Worker 
5233*062a843bSAndroid Build Coastguard Worker     return 0;
5234*062a843bSAndroid Build Coastguard Worker }
5235*062a843bSAndroid Build Coastguard Worker 
sendCDMAFeatureCodeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5236*062a843bSAndroid Build Coastguard Worker int radio::sendCDMAFeatureCodeResponse(int slotId,
5237*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
5238*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
5239*062a843bSAndroid Build Coastguard Worker #if VDBG
5240*062a843bSAndroid Build Coastguard Worker     RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5241*062a843bSAndroid Build Coastguard Worker #endif
5242*062a843bSAndroid Build Coastguard Worker 
5243*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5244*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5245*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5246*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5247*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5248*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5249*062a843bSAndroid Build Coastguard Worker     } else {
5250*062a843bSAndroid Build Coastguard Worker         RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5251*062a843bSAndroid Build Coastguard Worker                 slotId);
5252*062a843bSAndroid Build Coastguard Worker     }
5253*062a843bSAndroid Build Coastguard Worker 
5254*062a843bSAndroid Build Coastguard Worker     return 0;
5255*062a843bSAndroid Build Coastguard Worker }
5256*062a843bSAndroid Build Coastguard Worker 
sendBurstDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5257*062a843bSAndroid Build Coastguard Worker int radio::sendBurstDtmfResponse(int slotId,
5258*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
5259*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
5260*062a843bSAndroid Build Coastguard Worker #if VDBG
5261*062a843bSAndroid Build Coastguard Worker     RLOGD("sendBurstDtmfResponse: serial %d", serial);
5262*062a843bSAndroid Build Coastguard Worker #endif
5263*062a843bSAndroid Build Coastguard Worker 
5264*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5265*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5266*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5267*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5268*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5269*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5270*062a843bSAndroid Build Coastguard Worker     } else {
5271*062a843bSAndroid Build Coastguard Worker         RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5272*062a843bSAndroid Build Coastguard Worker     }
5273*062a843bSAndroid Build Coastguard Worker 
5274*062a843bSAndroid Build Coastguard Worker     return 0;
5275*062a843bSAndroid Build Coastguard Worker }
5276*062a843bSAndroid Build Coastguard Worker 
sendCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5277*062a843bSAndroid Build Coastguard Worker int radio::sendCdmaSmsResponse(int slotId,
5278*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e, void *response,
5279*062a843bSAndroid Build Coastguard Worker                               size_t responseLen) {
5280*062a843bSAndroid Build Coastguard Worker #if VDBG
5281*062a843bSAndroid Build Coastguard Worker     RLOGD("sendCdmaSmsResponse: serial %d", serial);
5282*062a843bSAndroid Build Coastguard Worker #endif
5283*062a843bSAndroid Build Coastguard Worker 
5284*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5285*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5286*062a843bSAndroid Build Coastguard Worker         SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5287*062a843bSAndroid Build Coastguard Worker                 responseLen);
5288*062a843bSAndroid Build Coastguard Worker 
5289*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5290*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5291*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5292*062a843bSAndroid Build Coastguard Worker     } else {
5293*062a843bSAndroid Build Coastguard Worker         RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5294*062a843bSAndroid Build Coastguard Worker     }
5295*062a843bSAndroid Build Coastguard Worker 
5296*062a843bSAndroid Build Coastguard Worker     return 0;
5297*062a843bSAndroid Build Coastguard Worker }
5298*062a843bSAndroid Build Coastguard Worker 
acknowledgeLastIncomingCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5299*062a843bSAndroid Build Coastguard Worker int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5300*062a843bSAndroid Build Coastguard Worker                                                  int responseType, int serial, RIL_Errno e,
5301*062a843bSAndroid Build Coastguard Worker                                                  void *response, size_t responseLen) {
5302*062a843bSAndroid Build Coastguard Worker #if VDBG
5303*062a843bSAndroid Build Coastguard Worker     RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5304*062a843bSAndroid Build Coastguard Worker #endif
5305*062a843bSAndroid Build Coastguard Worker 
5306*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5307*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5308*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5309*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5310*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5311*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5312*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5313*062a843bSAndroid Build Coastguard Worker     } else {
5314*062a843bSAndroid Build Coastguard Worker         RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5315*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
5316*062a843bSAndroid Build Coastguard Worker     }
5317*062a843bSAndroid Build Coastguard Worker 
5318*062a843bSAndroid Build Coastguard Worker     return 0;
5319*062a843bSAndroid Build Coastguard Worker }
5320*062a843bSAndroid Build Coastguard Worker 
getGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5321*062a843bSAndroid Build Coastguard Worker int radio::getGsmBroadcastConfigResponse(int slotId,
5322*062a843bSAndroid Build Coastguard Worker                                         int responseType, int serial, RIL_Errno e,
5323*062a843bSAndroid Build Coastguard Worker                                         void *response, size_t responseLen) {
5324*062a843bSAndroid Build Coastguard Worker #if VDBG
5325*062a843bSAndroid Build Coastguard Worker     RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5326*062a843bSAndroid Build Coastguard Worker #endif
5327*062a843bSAndroid Build Coastguard Worker 
5328*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5329*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5330*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5331*062a843bSAndroid Build Coastguard Worker         hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5332*062a843bSAndroid Build Coastguard Worker 
5333*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
5334*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5335*062a843bSAndroid Build Coastguard Worker             RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5336*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5337*062a843bSAndroid Build Coastguard Worker         } else {
5338*062a843bSAndroid Build Coastguard Worker             int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5339*062a843bSAndroid Build Coastguard Worker             configs.resize(num);
5340*062a843bSAndroid Build Coastguard Worker             for (int i = 0 ; i < num; i++) {
5341*062a843bSAndroid Build Coastguard Worker                 RIL_GSM_BroadcastSmsConfigInfo *resp =
5342*062a843bSAndroid Build Coastguard Worker                         ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5343*062a843bSAndroid Build Coastguard Worker                 configs[i].fromServiceId = resp->fromServiceId;
5344*062a843bSAndroid Build Coastguard Worker                 configs[i].toServiceId = resp->toServiceId;
5345*062a843bSAndroid Build Coastguard Worker                 configs[i].fromCodeScheme = resp->fromCodeScheme;
5346*062a843bSAndroid Build Coastguard Worker                 configs[i].toCodeScheme = resp->toCodeScheme;
5347*062a843bSAndroid Build Coastguard Worker                 configs[i].selected = resp->selected == 1 ? true : false;
5348*062a843bSAndroid Build Coastguard Worker             }
5349*062a843bSAndroid Build Coastguard Worker         }
5350*062a843bSAndroid Build Coastguard Worker 
5351*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5352*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5353*062a843bSAndroid Build Coastguard Worker                 configs);
5354*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5355*062a843bSAndroid Build Coastguard Worker     } else {
5356*062a843bSAndroid Build Coastguard Worker         RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5357*062a843bSAndroid Build Coastguard Worker                 slotId);
5358*062a843bSAndroid Build Coastguard Worker     }
5359*062a843bSAndroid Build Coastguard Worker 
5360*062a843bSAndroid Build Coastguard Worker     return 0;
5361*062a843bSAndroid Build Coastguard Worker }
5362*062a843bSAndroid Build Coastguard Worker 
setGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5363*062a843bSAndroid Build Coastguard Worker int radio::setGsmBroadcastConfigResponse(int slotId,
5364*062a843bSAndroid Build Coastguard Worker                                         int responseType, int serial, RIL_Errno e,
5365*062a843bSAndroid Build Coastguard Worker                                         void *response, size_t responseLen) {
5366*062a843bSAndroid Build Coastguard Worker #if VDBG
5367*062a843bSAndroid Build Coastguard Worker     RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5368*062a843bSAndroid Build Coastguard Worker #endif
5369*062a843bSAndroid Build Coastguard Worker 
5370*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5371*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5372*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5373*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5374*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5375*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5376*062a843bSAndroid Build Coastguard Worker     } else {
5377*062a843bSAndroid Build Coastguard Worker         RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5378*062a843bSAndroid Build Coastguard Worker                 slotId);
5379*062a843bSAndroid Build Coastguard Worker     }
5380*062a843bSAndroid Build Coastguard Worker 
5381*062a843bSAndroid Build Coastguard Worker     return 0;
5382*062a843bSAndroid Build Coastguard Worker }
5383*062a843bSAndroid Build Coastguard Worker 
setGsmBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5384*062a843bSAndroid Build Coastguard Worker int radio::setGsmBroadcastActivationResponse(int slotId,
5385*062a843bSAndroid Build Coastguard Worker                                             int responseType, int serial, RIL_Errno e,
5386*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
5387*062a843bSAndroid Build Coastguard Worker #if VDBG
5388*062a843bSAndroid Build Coastguard Worker     RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5389*062a843bSAndroid Build Coastguard Worker #endif
5390*062a843bSAndroid Build Coastguard Worker 
5391*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5392*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5393*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5394*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5395*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5396*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5397*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5398*062a843bSAndroid Build Coastguard Worker     } else {
5399*062a843bSAndroid Build Coastguard Worker         RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5400*062a843bSAndroid Build Coastguard Worker                 slotId);
5401*062a843bSAndroid Build Coastguard Worker     }
5402*062a843bSAndroid Build Coastguard Worker 
5403*062a843bSAndroid Build Coastguard Worker     return 0;
5404*062a843bSAndroid Build Coastguard Worker }
5405*062a843bSAndroid Build Coastguard Worker 
getCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5406*062a843bSAndroid Build Coastguard Worker int radio::getCdmaBroadcastConfigResponse(int slotId,
5407*062a843bSAndroid Build Coastguard Worker                                          int responseType, int serial, RIL_Errno e,
5408*062a843bSAndroid Build Coastguard Worker                                          void *response, size_t responseLen) {
5409*062a843bSAndroid Build Coastguard Worker #if VDBG
5410*062a843bSAndroid Build Coastguard Worker     RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5411*062a843bSAndroid Build Coastguard Worker #endif
5412*062a843bSAndroid Build Coastguard Worker 
5413*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5414*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5415*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5416*062a843bSAndroid Build Coastguard Worker         hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5417*062a843bSAndroid Build Coastguard Worker 
5418*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
5419*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5420*062a843bSAndroid Build Coastguard Worker             RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5421*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5422*062a843bSAndroid Build Coastguard Worker         } else {
5423*062a843bSAndroid Build Coastguard Worker             int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5424*062a843bSAndroid Build Coastguard Worker             configs.resize(num);
5425*062a843bSAndroid Build Coastguard Worker             for (int i = 0 ; i < num; i++) {
5426*062a843bSAndroid Build Coastguard Worker                 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5427*062a843bSAndroid Build Coastguard Worker                         ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5428*062a843bSAndroid Build Coastguard Worker                 configs[i].serviceCategory = resp->service_category;
5429*062a843bSAndroid Build Coastguard Worker                 configs[i].language = resp->language;
5430*062a843bSAndroid Build Coastguard Worker                 configs[i].selected = resp->selected == 1 ? true : false;
5431*062a843bSAndroid Build Coastguard Worker             }
5432*062a843bSAndroid Build Coastguard Worker         }
5433*062a843bSAndroid Build Coastguard Worker 
5434*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5435*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5436*062a843bSAndroid Build Coastguard Worker                 configs);
5437*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5438*062a843bSAndroid Build Coastguard Worker     } else {
5439*062a843bSAndroid Build Coastguard Worker         RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5440*062a843bSAndroid Build Coastguard Worker                 slotId);
5441*062a843bSAndroid Build Coastguard Worker     }
5442*062a843bSAndroid Build Coastguard Worker 
5443*062a843bSAndroid Build Coastguard Worker     return 0;
5444*062a843bSAndroid Build Coastguard Worker }
5445*062a843bSAndroid Build Coastguard Worker 
setCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5446*062a843bSAndroid Build Coastguard Worker int radio::setCdmaBroadcastConfigResponse(int slotId,
5447*062a843bSAndroid Build Coastguard Worker                                          int responseType, int serial, RIL_Errno e,
5448*062a843bSAndroid Build Coastguard Worker                                          void *response, size_t responseLen) {
5449*062a843bSAndroid Build Coastguard Worker #if VDBG
5450*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5451*062a843bSAndroid Build Coastguard Worker #endif
5452*062a843bSAndroid Build Coastguard Worker 
5453*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5454*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5455*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5456*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5457*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5458*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5459*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5460*062a843bSAndroid Build Coastguard Worker     } else {
5461*062a843bSAndroid Build Coastguard Worker         RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5462*062a843bSAndroid Build Coastguard Worker                 slotId);
5463*062a843bSAndroid Build Coastguard Worker     }
5464*062a843bSAndroid Build Coastguard Worker 
5465*062a843bSAndroid Build Coastguard Worker     return 0;
5466*062a843bSAndroid Build Coastguard Worker }
5467*062a843bSAndroid Build Coastguard Worker 
setCdmaBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5468*062a843bSAndroid Build Coastguard Worker int radio::setCdmaBroadcastActivationResponse(int slotId,
5469*062a843bSAndroid Build Coastguard Worker                                              int responseType, int serial, RIL_Errno e,
5470*062a843bSAndroid Build Coastguard Worker                                              void *response, size_t responseLen) {
5471*062a843bSAndroid Build Coastguard Worker #if VDBG
5472*062a843bSAndroid Build Coastguard Worker     RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5473*062a843bSAndroid Build Coastguard Worker #endif
5474*062a843bSAndroid Build Coastguard Worker 
5475*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5476*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5477*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5478*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5479*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5480*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5481*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5482*062a843bSAndroid Build Coastguard Worker     } else {
5483*062a843bSAndroid Build Coastguard Worker         RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5484*062a843bSAndroid Build Coastguard Worker                 slotId);
5485*062a843bSAndroid Build Coastguard Worker     }
5486*062a843bSAndroid Build Coastguard Worker 
5487*062a843bSAndroid Build Coastguard Worker     return 0;
5488*062a843bSAndroid Build Coastguard Worker }
5489*062a843bSAndroid Build Coastguard Worker 
getCDMASubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5490*062a843bSAndroid Build Coastguard Worker int radio::getCDMASubscriptionResponse(int slotId,
5491*062a843bSAndroid Build Coastguard Worker                                       int responseType, int serial, RIL_Errno e, void *response,
5492*062a843bSAndroid Build Coastguard Worker                                       size_t responseLen) {
5493*062a843bSAndroid Build Coastguard Worker #if VDBG
5494*062a843bSAndroid Build Coastguard Worker     RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5495*062a843bSAndroid Build Coastguard Worker #endif
5496*062a843bSAndroid Build Coastguard Worker 
5497*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5498*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5499*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5500*062a843bSAndroid Build Coastguard Worker 
5501*062a843bSAndroid Build Coastguard Worker         int numStrings = responseLen / sizeof(char *);
5502*062a843bSAndroid Build Coastguard Worker         hidl_string emptyString;
5503*062a843bSAndroid Build Coastguard Worker         if (response == NULL || numStrings != 5) {
5504*062a843bSAndroid Build Coastguard Worker             RLOGE("getOperatorResponse Invalid response: NULL");
5505*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5506*062a843bSAndroid Build Coastguard Worker             Return<void> retStatus
5507*062a843bSAndroid Build Coastguard Worker                     = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5508*062a843bSAndroid Build Coastguard Worker                     responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5509*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->checkReturnStatus(retStatus);
5510*062a843bSAndroid Build Coastguard Worker         } else {
5511*062a843bSAndroid Build Coastguard Worker             char **resp = (char **) response;
5512*062a843bSAndroid Build Coastguard Worker             Return<void> retStatus
5513*062a843bSAndroid Build Coastguard Worker                     = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5514*062a843bSAndroid Build Coastguard Worker                     responseInfo,
5515*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[0]),
5516*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[1]),
5517*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[2]),
5518*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[3]),
5519*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[4]));
5520*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->checkReturnStatus(retStatus);
5521*062a843bSAndroid Build Coastguard Worker         }
5522*062a843bSAndroid Build Coastguard Worker     } else {
5523*062a843bSAndroid Build Coastguard Worker         RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5524*062a843bSAndroid Build Coastguard Worker                 slotId);
5525*062a843bSAndroid Build Coastguard Worker     }
5526*062a843bSAndroid Build Coastguard Worker 
5527*062a843bSAndroid Build Coastguard Worker     return 0;
5528*062a843bSAndroid Build Coastguard Worker }
5529*062a843bSAndroid Build Coastguard Worker 
writeSmsToRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5530*062a843bSAndroid Build Coastguard Worker int radio::writeSmsToRuimResponse(int slotId,
5531*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
5532*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
5533*062a843bSAndroid Build Coastguard Worker #if VDBG
5534*062a843bSAndroid Build Coastguard Worker     RLOGD("writeSmsToRuimResponse: serial %d", serial);
5535*062a843bSAndroid Build Coastguard Worker #endif
5536*062a843bSAndroid Build Coastguard Worker 
5537*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5538*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5539*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5540*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5541*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5542*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5543*062a843bSAndroid Build Coastguard Worker     } else {
5544*062a843bSAndroid Build Coastguard Worker         RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5545*062a843bSAndroid Build Coastguard Worker     }
5546*062a843bSAndroid Build Coastguard Worker 
5547*062a843bSAndroid Build Coastguard Worker     return 0;
5548*062a843bSAndroid Build Coastguard Worker }
5549*062a843bSAndroid Build Coastguard Worker 
deleteSmsOnRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5550*062a843bSAndroid Build Coastguard Worker int radio::deleteSmsOnRuimResponse(int slotId,
5551*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
5552*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
5553*062a843bSAndroid Build Coastguard Worker #if VDBG
5554*062a843bSAndroid Build Coastguard Worker     RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5555*062a843bSAndroid Build Coastguard Worker #endif
5556*062a843bSAndroid Build Coastguard Worker 
5557*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5558*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5559*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5560*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5561*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5562*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5563*062a843bSAndroid Build Coastguard Worker     } else {
5564*062a843bSAndroid Build Coastguard Worker         RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5565*062a843bSAndroid Build Coastguard Worker     }
5566*062a843bSAndroid Build Coastguard Worker 
5567*062a843bSAndroid Build Coastguard Worker     return 0;
5568*062a843bSAndroid Build Coastguard Worker }
5569*062a843bSAndroid Build Coastguard Worker 
getDeviceIdentityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5570*062a843bSAndroid Build Coastguard Worker int radio::getDeviceIdentityResponse(int slotId,
5571*062a843bSAndroid Build Coastguard Worker                                     int responseType, int serial, RIL_Errno e, void *response,
5572*062a843bSAndroid Build Coastguard Worker                                     size_t responseLen) {
5573*062a843bSAndroid Build Coastguard Worker #if VDBG
5574*062a843bSAndroid Build Coastguard Worker     RLOGD("getDeviceIdentityResponse: serial %d", serial);
5575*062a843bSAndroid Build Coastguard Worker #endif
5576*062a843bSAndroid Build Coastguard Worker 
5577*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5578*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5579*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5580*062a843bSAndroid Build Coastguard Worker 
5581*062a843bSAndroid Build Coastguard Worker         int numStrings = responseLen / sizeof(char *);
5582*062a843bSAndroid Build Coastguard Worker         hidl_string emptyString;
5583*062a843bSAndroid Build Coastguard Worker         if (response == NULL || numStrings != 4) {
5584*062a843bSAndroid Build Coastguard Worker             RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5585*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5586*062a843bSAndroid Build Coastguard Worker             Return<void> retStatus
5587*062a843bSAndroid Build Coastguard Worker                     = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5588*062a843bSAndroid Build Coastguard Worker                     emptyString, emptyString, emptyString, emptyString);
5589*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->checkReturnStatus(retStatus);
5590*062a843bSAndroid Build Coastguard Worker         } else {
5591*062a843bSAndroid Build Coastguard Worker             char **resp = (char **) response;
5592*062a843bSAndroid Build Coastguard Worker             Return<void> retStatus
5593*062a843bSAndroid Build Coastguard Worker                     = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5594*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[0]),
5595*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[1]),
5596*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[2]),
5597*062a843bSAndroid Build Coastguard Worker                     convertCharPtrToHidlString(resp[3]));
5598*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->checkReturnStatus(retStatus);
5599*062a843bSAndroid Build Coastguard Worker         }
5600*062a843bSAndroid Build Coastguard Worker     } else {
5601*062a843bSAndroid Build Coastguard Worker         RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5602*062a843bSAndroid Build Coastguard Worker                 slotId);
5603*062a843bSAndroid Build Coastguard Worker     }
5604*062a843bSAndroid Build Coastguard Worker 
5605*062a843bSAndroid Build Coastguard Worker     return 0;
5606*062a843bSAndroid Build Coastguard Worker }
5607*062a843bSAndroid Build Coastguard Worker 
exitEmergencyCallbackModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5608*062a843bSAndroid Build Coastguard Worker int radio::exitEmergencyCallbackModeResponse(int slotId,
5609*062a843bSAndroid Build Coastguard Worker                                             int responseType, int serial, RIL_Errno e,
5610*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
5611*062a843bSAndroid Build Coastguard Worker #if VDBG
5612*062a843bSAndroid Build Coastguard Worker     RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5613*062a843bSAndroid Build Coastguard Worker #endif
5614*062a843bSAndroid Build Coastguard Worker 
5615*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5616*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5617*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5618*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5619*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5620*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5621*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5622*062a843bSAndroid Build Coastguard Worker     } else {
5623*062a843bSAndroid Build Coastguard Worker         RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5624*062a843bSAndroid Build Coastguard Worker                 slotId);
5625*062a843bSAndroid Build Coastguard Worker     }
5626*062a843bSAndroid Build Coastguard Worker 
5627*062a843bSAndroid Build Coastguard Worker     return 0;
5628*062a843bSAndroid Build Coastguard Worker }
5629*062a843bSAndroid Build Coastguard Worker 
getSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5630*062a843bSAndroid Build Coastguard Worker int radio::getSmscAddressResponse(int slotId,
5631*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
5632*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
5633*062a843bSAndroid Build Coastguard Worker #if VDBG
5634*062a843bSAndroid Build Coastguard Worker     RLOGD("getSmscAddressResponse: serial %d", serial);
5635*062a843bSAndroid Build Coastguard Worker #endif
5636*062a843bSAndroid Build Coastguard Worker 
5637*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5638*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5639*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5640*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5641*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5642*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
5643*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5644*062a843bSAndroid Build Coastguard Worker     } else {
5645*062a843bSAndroid Build Coastguard Worker         RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5646*062a843bSAndroid Build Coastguard Worker     }
5647*062a843bSAndroid Build Coastguard Worker 
5648*062a843bSAndroid Build Coastguard Worker     return 0;
5649*062a843bSAndroid Build Coastguard Worker }
5650*062a843bSAndroid Build Coastguard Worker 
setSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5651*062a843bSAndroid Build Coastguard Worker int radio::setSmscAddressResponse(int slotId,
5652*062a843bSAndroid Build Coastguard Worker                                              int responseType, int serial, RIL_Errno e,
5653*062a843bSAndroid Build Coastguard Worker                                              void *response, size_t responseLen) {
5654*062a843bSAndroid Build Coastguard Worker #if VDBG
5655*062a843bSAndroid Build Coastguard Worker     RLOGD("setSmscAddressResponse: serial %d", serial);
5656*062a843bSAndroid Build Coastguard Worker #endif
5657*062a843bSAndroid Build Coastguard Worker 
5658*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5659*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5660*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5661*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5662*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5663*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5664*062a843bSAndroid Build Coastguard Worker     } else {
5665*062a843bSAndroid Build Coastguard Worker         RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5666*062a843bSAndroid Build Coastguard Worker     }
5667*062a843bSAndroid Build Coastguard Worker 
5668*062a843bSAndroid Build Coastguard Worker     return 0;
5669*062a843bSAndroid Build Coastguard Worker }
5670*062a843bSAndroid Build Coastguard Worker 
reportSmsMemoryStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5671*062a843bSAndroid Build Coastguard Worker int radio::reportSmsMemoryStatusResponse(int slotId,
5672*062a843bSAndroid Build Coastguard Worker                                         int responseType, int serial, RIL_Errno e,
5673*062a843bSAndroid Build Coastguard Worker                                         void *response, size_t responseLen) {
5674*062a843bSAndroid Build Coastguard Worker #if VDBG
5675*062a843bSAndroid Build Coastguard Worker     RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5676*062a843bSAndroid Build Coastguard Worker #endif
5677*062a843bSAndroid Build Coastguard Worker 
5678*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5679*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5680*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5681*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5682*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5683*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5684*062a843bSAndroid Build Coastguard Worker     } else {
5685*062a843bSAndroid Build Coastguard Worker         RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5686*062a843bSAndroid Build Coastguard Worker                 slotId);
5687*062a843bSAndroid Build Coastguard Worker     }
5688*062a843bSAndroid Build Coastguard Worker 
5689*062a843bSAndroid Build Coastguard Worker     return 0;
5690*062a843bSAndroid Build Coastguard Worker }
5691*062a843bSAndroid Build Coastguard Worker 
reportStkServiceIsRunningResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5692*062a843bSAndroid Build Coastguard Worker int radio::reportStkServiceIsRunningResponse(int slotId,
5693*062a843bSAndroid Build Coastguard Worker                                              int responseType, int serial, RIL_Errno e,
5694*062a843bSAndroid Build Coastguard Worker                                              void *response, size_t responseLen) {
5695*062a843bSAndroid Build Coastguard Worker #if VDBG
5696*062a843bSAndroid Build Coastguard Worker     RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5697*062a843bSAndroid Build Coastguard Worker #endif
5698*062a843bSAndroid Build Coastguard Worker 
5699*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5700*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5701*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5702*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->
5703*062a843bSAndroid Build Coastguard Worker                 reportStkServiceIsRunningResponse(responseInfo);
5704*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5705*062a843bSAndroid Build Coastguard Worker     } else {
5706*062a843bSAndroid Build Coastguard Worker         RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5707*062a843bSAndroid Build Coastguard Worker                 slotId);
5708*062a843bSAndroid Build Coastguard Worker     }
5709*062a843bSAndroid Build Coastguard Worker 
5710*062a843bSAndroid Build Coastguard Worker     return 0;
5711*062a843bSAndroid Build Coastguard Worker }
5712*062a843bSAndroid Build Coastguard Worker 
getCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5713*062a843bSAndroid Build Coastguard Worker int radio::getCdmaSubscriptionSourceResponse(int slotId,
5714*062a843bSAndroid Build Coastguard Worker                                             int responseType, int serial, RIL_Errno e,
5715*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
5716*062a843bSAndroid Build Coastguard Worker #if VDBG
5717*062a843bSAndroid Build Coastguard Worker     RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5718*062a843bSAndroid Build Coastguard Worker #endif
5719*062a843bSAndroid Build Coastguard Worker 
5720*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5721*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5722*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5723*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5724*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5725*062a843bSAndroid Build Coastguard Worker                 responseInfo, (CdmaSubscriptionSource) ret);
5726*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5727*062a843bSAndroid Build Coastguard Worker     } else {
5728*062a843bSAndroid Build Coastguard Worker         RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5729*062a843bSAndroid Build Coastguard Worker                 slotId);
5730*062a843bSAndroid Build Coastguard Worker     }
5731*062a843bSAndroid Build Coastguard Worker 
5732*062a843bSAndroid Build Coastguard Worker     return 0;
5733*062a843bSAndroid Build Coastguard Worker }
5734*062a843bSAndroid Build Coastguard Worker 
requestIsimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5735*062a843bSAndroid Build Coastguard Worker int radio::requestIsimAuthenticationResponse(int slotId,
5736*062a843bSAndroid Build Coastguard Worker                                             int responseType, int serial, RIL_Errno e,
5737*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
5738*062a843bSAndroid Build Coastguard Worker #if VDBG
5739*062a843bSAndroid Build Coastguard Worker     RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5740*062a843bSAndroid Build Coastguard Worker #endif
5741*062a843bSAndroid Build Coastguard Worker 
5742*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5743*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5744*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5745*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5746*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5747*062a843bSAndroid Build Coastguard Worker                 responseInfo,
5748*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
5749*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5750*062a843bSAndroid Build Coastguard Worker     } else {
5751*062a843bSAndroid Build Coastguard Worker         RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5752*062a843bSAndroid Build Coastguard Worker                 slotId);
5753*062a843bSAndroid Build Coastguard Worker     }
5754*062a843bSAndroid Build Coastguard Worker 
5755*062a843bSAndroid Build Coastguard Worker     return 0;
5756*062a843bSAndroid Build Coastguard Worker }
5757*062a843bSAndroid Build Coastguard Worker 
acknowledgeIncomingGsmSmsWithPduResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5758*062a843bSAndroid Build Coastguard Worker int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5759*062a843bSAndroid Build Coastguard Worker                                                    int responseType,
5760*062a843bSAndroid Build Coastguard Worker                                                    int serial, RIL_Errno e, void *response,
5761*062a843bSAndroid Build Coastguard Worker                                                    size_t responseLen) {
5762*062a843bSAndroid Build Coastguard Worker #if VDBG
5763*062a843bSAndroid Build Coastguard Worker     RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5764*062a843bSAndroid Build Coastguard Worker #endif
5765*062a843bSAndroid Build Coastguard Worker 
5766*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5767*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5768*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5769*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5770*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5771*062a843bSAndroid Build Coastguard Worker                 responseInfo);
5772*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5773*062a843bSAndroid Build Coastguard Worker     } else {
5774*062a843bSAndroid Build Coastguard Worker         RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5775*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
5776*062a843bSAndroid Build Coastguard Worker     }
5777*062a843bSAndroid Build Coastguard Worker 
5778*062a843bSAndroid Build Coastguard Worker     return 0;
5779*062a843bSAndroid Build Coastguard Worker }
5780*062a843bSAndroid Build Coastguard Worker 
sendEnvelopeWithStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5781*062a843bSAndroid Build Coastguard Worker int radio::sendEnvelopeWithStatusResponse(int slotId,
5782*062a843bSAndroid Build Coastguard Worker                                          int responseType, int serial, RIL_Errno e, void *response,
5783*062a843bSAndroid Build Coastguard Worker                                          size_t responseLen) {
5784*062a843bSAndroid Build Coastguard Worker #if VDBG
5785*062a843bSAndroid Build Coastguard Worker     RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5786*062a843bSAndroid Build Coastguard Worker #endif
5787*062a843bSAndroid Build Coastguard Worker 
5788*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5789*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5790*062a843bSAndroid Build Coastguard Worker         IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5791*062a843bSAndroid Build Coastguard Worker                 response, responseLen);
5792*062a843bSAndroid Build Coastguard Worker 
5793*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5794*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5795*062a843bSAndroid Build Coastguard Worker                 result);
5796*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5797*062a843bSAndroid Build Coastguard Worker     } else {
5798*062a843bSAndroid Build Coastguard Worker         RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5799*062a843bSAndroid Build Coastguard Worker                 slotId);
5800*062a843bSAndroid Build Coastguard Worker     }
5801*062a843bSAndroid Build Coastguard Worker 
5802*062a843bSAndroid Build Coastguard Worker     return 0;
5803*062a843bSAndroid Build Coastguard Worker }
5804*062a843bSAndroid Build Coastguard Worker 
getVoiceRadioTechnologyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5805*062a843bSAndroid Build Coastguard Worker int radio::getVoiceRadioTechnologyResponse(int slotId,
5806*062a843bSAndroid Build Coastguard Worker                                           int responseType, int serial, RIL_Errno e,
5807*062a843bSAndroid Build Coastguard Worker                                           void *response, size_t responseLen) {
5808*062a843bSAndroid Build Coastguard Worker #if VDBG
5809*062a843bSAndroid Build Coastguard Worker     RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5810*062a843bSAndroid Build Coastguard Worker #endif
5811*062a843bSAndroid Build Coastguard Worker 
5812*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5813*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5814*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5815*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5816*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5817*062a843bSAndroid Build Coastguard Worker                 responseInfo, (RadioTechnology) ret);
5818*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5819*062a843bSAndroid Build Coastguard Worker     } else {
5820*062a843bSAndroid Build Coastguard Worker         RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5821*062a843bSAndroid Build Coastguard Worker                 slotId);
5822*062a843bSAndroid Build Coastguard Worker     }
5823*062a843bSAndroid Build Coastguard Worker 
5824*062a843bSAndroid Build Coastguard Worker     return 0;
5825*062a843bSAndroid Build Coastguard Worker }
5826*062a843bSAndroid Build Coastguard Worker 
getCellInfoListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5827*062a843bSAndroid Build Coastguard Worker int radio::getCellInfoListResponse(int slotId,
5828*062a843bSAndroid Build Coastguard Worker                                    int responseType,
5829*062a843bSAndroid Build Coastguard Worker                                    int serial, RIL_Errno e, void *response,
5830*062a843bSAndroid Build Coastguard Worker                                    size_t responseLen) {
5831*062a843bSAndroid Build Coastguard Worker #if VDBG
5832*062a843bSAndroid Build Coastguard Worker     RLOGD("getCellInfoListResponse: serial %d", serial);
5833*062a843bSAndroid Build Coastguard Worker #endif
5834*062a843bSAndroid Build Coastguard Worker 
5835*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5836*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5837*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5838*062a843bSAndroid Build Coastguard Worker 
5839*062a843bSAndroid Build Coastguard Worker         hidl_vec<CellInfo> ret;
5840*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
5841*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5842*062a843bSAndroid Build Coastguard Worker             RLOGE("getCellInfoListResponse: Invalid response");
5843*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5844*062a843bSAndroid Build Coastguard Worker         } else {
5845*062a843bSAndroid Build Coastguard Worker             convertRilCellInfoListToHal(response, responseLen, ret);
5846*062a843bSAndroid Build Coastguard Worker         }
5847*062a843bSAndroid Build Coastguard Worker 
5848*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5849*062a843bSAndroid Build Coastguard Worker                 responseInfo, ret);
5850*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5851*062a843bSAndroid Build Coastguard Worker     } else {
5852*062a843bSAndroid Build Coastguard Worker         RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5853*062a843bSAndroid Build Coastguard Worker     }
5854*062a843bSAndroid Build Coastguard Worker 
5855*062a843bSAndroid Build Coastguard Worker     return 0;
5856*062a843bSAndroid Build Coastguard Worker }
5857*062a843bSAndroid Build Coastguard Worker 
setCellInfoListRateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5858*062a843bSAndroid Build Coastguard Worker int radio::setCellInfoListRateResponse(int slotId,
5859*062a843bSAndroid Build Coastguard Worker                                        int responseType,
5860*062a843bSAndroid Build Coastguard Worker                                        int serial, RIL_Errno e, void *response,
5861*062a843bSAndroid Build Coastguard Worker                                        size_t responseLen) {
5862*062a843bSAndroid Build Coastguard Worker #if VDBG
5863*062a843bSAndroid Build Coastguard Worker     RLOGD("setCellInfoListRateResponse: serial %d", serial);
5864*062a843bSAndroid Build Coastguard Worker #endif
5865*062a843bSAndroid Build Coastguard Worker 
5866*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5867*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5868*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5869*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5870*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5871*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5872*062a843bSAndroid Build Coastguard Worker     } else {
5873*062a843bSAndroid Build Coastguard Worker         RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5874*062a843bSAndroid Build Coastguard Worker                 slotId);
5875*062a843bSAndroid Build Coastguard Worker     }
5876*062a843bSAndroid Build Coastguard Worker 
5877*062a843bSAndroid Build Coastguard Worker     return 0;
5878*062a843bSAndroid Build Coastguard Worker }
5879*062a843bSAndroid Build Coastguard Worker 
setInitialAttachApnResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5880*062a843bSAndroid Build Coastguard Worker int radio::setInitialAttachApnResponse(int slotId,
5881*062a843bSAndroid Build Coastguard Worker                                        int responseType, int serial, RIL_Errno e,
5882*062a843bSAndroid Build Coastguard Worker                                        void *response, size_t responseLen) {
5883*062a843bSAndroid Build Coastguard Worker #if VDBG
5884*062a843bSAndroid Build Coastguard Worker     RLOGD("setInitialAttachApnResponse: serial %d", serial);
5885*062a843bSAndroid Build Coastguard Worker #endif
5886*062a843bSAndroid Build Coastguard Worker 
5887*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5888*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5889*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5890*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5891*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5892*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5893*062a843bSAndroid Build Coastguard Worker     } else {
5894*062a843bSAndroid Build Coastguard Worker         RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5895*062a843bSAndroid Build Coastguard Worker                 slotId);
5896*062a843bSAndroid Build Coastguard Worker     }
5897*062a843bSAndroid Build Coastguard Worker 
5898*062a843bSAndroid Build Coastguard Worker     return 0;
5899*062a843bSAndroid Build Coastguard Worker }
5900*062a843bSAndroid Build Coastguard Worker 
getImsRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5901*062a843bSAndroid Build Coastguard Worker int radio::getImsRegistrationStateResponse(int slotId,
5902*062a843bSAndroid Build Coastguard Worker                                            int responseType, int serial, RIL_Errno e,
5903*062a843bSAndroid Build Coastguard Worker                                            void *response, size_t responseLen) {
5904*062a843bSAndroid Build Coastguard Worker #if VDBG
5905*062a843bSAndroid Build Coastguard Worker     RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5906*062a843bSAndroid Build Coastguard Worker #endif
5907*062a843bSAndroid Build Coastguard Worker 
5908*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5909*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5910*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5911*062a843bSAndroid Build Coastguard Worker         bool isRegistered = false;
5912*062a843bSAndroid Build Coastguard Worker         RadioTechnologyFamily ratFamily = RadioTechnologyFamily::THREE_GPP;
5913*062a843bSAndroid Build Coastguard Worker         int numInts = responseLen / sizeof(int);
5914*062a843bSAndroid Build Coastguard Worker         if (response == NULL || numInts != 2) {
5915*062a843bSAndroid Build Coastguard Worker             RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5916*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5917*062a843bSAndroid Build Coastguard Worker         } else {
5918*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
5919*062a843bSAndroid Build Coastguard Worker             isRegistered = pInt[0] == 1 ? true : false;
5920*062a843bSAndroid Build Coastguard Worker             // Map RIL_RadioTechnologyFamily to RadioTechnologyFamily
5921*062a843bSAndroid Build Coastguard Worker             if (pInt[1] == RADIO_TECH_3GPP) {
5922*062a843bSAndroid Build Coastguard Worker                 ratFamily = RadioTechnologyFamily::THREE_GPP;
5923*062a843bSAndroid Build Coastguard Worker             } else {
5924*062a843bSAndroid Build Coastguard Worker                 ratFamily = RadioTechnologyFamily::THREE_GPP2;
5925*062a843bSAndroid Build Coastguard Worker             }
5926*062a843bSAndroid Build Coastguard Worker         }
5927*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5928*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5929*062a843bSAndroid Build Coastguard Worker                 responseInfo, isRegistered, ratFamily);
5930*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5931*062a843bSAndroid Build Coastguard Worker     } else {
5932*062a843bSAndroid Build Coastguard Worker         RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5933*062a843bSAndroid Build Coastguard Worker                 slotId);
5934*062a843bSAndroid Build Coastguard Worker     }
5935*062a843bSAndroid Build Coastguard Worker 
5936*062a843bSAndroid Build Coastguard Worker     return 0;
5937*062a843bSAndroid Build Coastguard Worker }
5938*062a843bSAndroid Build Coastguard Worker 
sendImsSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5939*062a843bSAndroid Build Coastguard Worker int radio::sendImsSmsResponse(int slotId,
5940*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e, void *response,
5941*062a843bSAndroid Build Coastguard Worker                               size_t responseLen) {
5942*062a843bSAndroid Build Coastguard Worker #if VDBG
5943*062a843bSAndroid Build Coastguard Worker     RLOGD("sendImsSmsResponse: serial %d", serial);
5944*062a843bSAndroid Build Coastguard Worker #endif
5945*062a843bSAndroid Build Coastguard Worker 
5946*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5947*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5948*062a843bSAndroid Build Coastguard Worker         SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5949*062a843bSAndroid Build Coastguard Worker                 responseLen);
5950*062a843bSAndroid Build Coastguard Worker 
5951*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5952*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5953*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5954*062a843bSAndroid Build Coastguard Worker     } else {
5955*062a843bSAndroid Build Coastguard Worker         RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5956*062a843bSAndroid Build Coastguard Worker     }
5957*062a843bSAndroid Build Coastguard Worker 
5958*062a843bSAndroid Build Coastguard Worker     return 0;
5959*062a843bSAndroid Build Coastguard Worker }
5960*062a843bSAndroid Build Coastguard Worker 
iccTransmitApduBasicChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5961*062a843bSAndroid Build Coastguard Worker int radio::iccTransmitApduBasicChannelResponse(int slotId,
5962*062a843bSAndroid Build Coastguard Worker                                                int responseType, int serial, RIL_Errno e,
5963*062a843bSAndroid Build Coastguard Worker                                                void *response, size_t responseLen) {
5964*062a843bSAndroid Build Coastguard Worker #if VDBG
5965*062a843bSAndroid Build Coastguard Worker     RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5966*062a843bSAndroid Build Coastguard Worker #endif
5967*062a843bSAndroid Build Coastguard Worker 
5968*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5969*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5970*062a843bSAndroid Build Coastguard Worker         IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5971*062a843bSAndroid Build Coastguard Worker                 responseLen);
5972*062a843bSAndroid Build Coastguard Worker 
5973*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
5974*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5975*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
5976*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
5977*062a843bSAndroid Build Coastguard Worker     } else {
5978*062a843bSAndroid Build Coastguard Worker         RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5979*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
5980*062a843bSAndroid Build Coastguard Worker     }
5981*062a843bSAndroid Build Coastguard Worker 
5982*062a843bSAndroid Build Coastguard Worker     return 0;
5983*062a843bSAndroid Build Coastguard Worker }
5984*062a843bSAndroid Build Coastguard Worker 
iccOpenLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5985*062a843bSAndroid Build Coastguard Worker int radio::iccOpenLogicalChannelResponse(int slotId,
5986*062a843bSAndroid Build Coastguard Worker                                          int responseType, int serial, RIL_Errno e, void *response,
5987*062a843bSAndroid Build Coastguard Worker                                          size_t responseLen) {
5988*062a843bSAndroid Build Coastguard Worker #if VDBG
5989*062a843bSAndroid Build Coastguard Worker     RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5990*062a843bSAndroid Build Coastguard Worker #endif
5991*062a843bSAndroid Build Coastguard Worker 
5992*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
5993*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
5994*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
5995*062a843bSAndroid Build Coastguard Worker         int channelId = -1;
5996*062a843bSAndroid Build Coastguard Worker         hidl_vec<int8_t> selectResponse;
5997*062a843bSAndroid Build Coastguard Worker         int numInts = responseLen / sizeof(int);
5998*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen % sizeof(int) != 0) {
5999*062a843bSAndroid Build Coastguard Worker             RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
6000*062a843bSAndroid Build Coastguard Worker             if (response != NULL) {
6001*062a843bSAndroid Build Coastguard Worker                 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6002*062a843bSAndroid Build Coastguard Worker             }
6003*062a843bSAndroid Build Coastguard Worker         } else {
6004*062a843bSAndroid Build Coastguard Worker             int *pInt = (int *) response;
6005*062a843bSAndroid Build Coastguard Worker             channelId = pInt[0];
6006*062a843bSAndroid Build Coastguard Worker             selectResponse.resize(numInts - 1);
6007*062a843bSAndroid Build Coastguard Worker             for (int i = 1; i < numInts; i++) {
6008*062a843bSAndroid Build Coastguard Worker                 selectResponse[i - 1] = (int8_t) pInt[i];
6009*062a843bSAndroid Build Coastguard Worker             }
6010*062a843bSAndroid Build Coastguard Worker         }
6011*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6012*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
6013*062a843bSAndroid Build Coastguard Worker                 channelId, selectResponse);
6014*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6015*062a843bSAndroid Build Coastguard Worker     } else {
6016*062a843bSAndroid Build Coastguard Worker         RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6017*062a843bSAndroid Build Coastguard Worker                 slotId);
6018*062a843bSAndroid Build Coastguard Worker     }
6019*062a843bSAndroid Build Coastguard Worker 
6020*062a843bSAndroid Build Coastguard Worker     return 0;
6021*062a843bSAndroid Build Coastguard Worker }
6022*062a843bSAndroid Build Coastguard Worker 
iccCloseLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6023*062a843bSAndroid Build Coastguard Worker int radio::iccCloseLogicalChannelResponse(int slotId,
6024*062a843bSAndroid Build Coastguard Worker                                           int responseType, int serial, RIL_Errno e,
6025*062a843bSAndroid Build Coastguard Worker                                           void *response, size_t responseLen) {
6026*062a843bSAndroid Build Coastguard Worker #if VDBG
6027*062a843bSAndroid Build Coastguard Worker     RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
6028*062a843bSAndroid Build Coastguard Worker #endif
6029*062a843bSAndroid Build Coastguard Worker 
6030*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6031*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6032*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6033*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6034*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
6035*062a843bSAndroid Build Coastguard Worker                 responseInfo);
6036*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6037*062a843bSAndroid Build Coastguard Worker     } else {
6038*062a843bSAndroid Build Coastguard Worker         RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6039*062a843bSAndroid Build Coastguard Worker                 slotId);
6040*062a843bSAndroid Build Coastguard Worker     }
6041*062a843bSAndroid Build Coastguard Worker 
6042*062a843bSAndroid Build Coastguard Worker     return 0;
6043*062a843bSAndroid Build Coastguard Worker }
6044*062a843bSAndroid Build Coastguard Worker 
iccTransmitApduLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6045*062a843bSAndroid Build Coastguard Worker int radio::iccTransmitApduLogicalChannelResponse(int slotId,
6046*062a843bSAndroid Build Coastguard Worker                                                  int responseType, int serial, RIL_Errno e,
6047*062a843bSAndroid Build Coastguard Worker                                                  void *response, size_t responseLen) {
6048*062a843bSAndroid Build Coastguard Worker #if VDBG
6049*062a843bSAndroid Build Coastguard Worker     RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
6050*062a843bSAndroid Build Coastguard Worker #endif
6051*062a843bSAndroid Build Coastguard Worker 
6052*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6053*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6054*062a843bSAndroid Build Coastguard Worker         IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6055*062a843bSAndroid Build Coastguard Worker                 responseLen);
6056*062a843bSAndroid Build Coastguard Worker 
6057*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6058*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
6059*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
6060*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6061*062a843bSAndroid Build Coastguard Worker     } else {
6062*062a843bSAndroid Build Coastguard Worker         RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
6063*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
6064*062a843bSAndroid Build Coastguard Worker     }
6065*062a843bSAndroid Build Coastguard Worker 
6066*062a843bSAndroid Build Coastguard Worker     return 0;
6067*062a843bSAndroid Build Coastguard Worker }
6068*062a843bSAndroid Build Coastguard Worker 
nvReadItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6069*062a843bSAndroid Build Coastguard Worker int radio::nvReadItemResponse(int slotId,
6070*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e,
6071*062a843bSAndroid Build Coastguard Worker                               void *response, size_t responseLen) {
6072*062a843bSAndroid Build Coastguard Worker #if VDBG
6073*062a843bSAndroid Build Coastguard Worker     RLOGD("nvReadItemResponse: serial %d", serial);
6074*062a843bSAndroid Build Coastguard Worker #endif
6075*062a843bSAndroid Build Coastguard Worker 
6076*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6077*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6078*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6079*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
6080*062a843bSAndroid Build Coastguard Worker                 responseInfo,
6081*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
6082*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6083*062a843bSAndroid Build Coastguard Worker     } else {
6084*062a843bSAndroid Build Coastguard Worker         RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6085*062a843bSAndroid Build Coastguard Worker     }
6086*062a843bSAndroid Build Coastguard Worker 
6087*062a843bSAndroid Build Coastguard Worker     return 0;
6088*062a843bSAndroid Build Coastguard Worker }
6089*062a843bSAndroid Build Coastguard Worker 
nvWriteItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6090*062a843bSAndroid Build Coastguard Worker int radio::nvWriteItemResponse(int slotId,
6091*062a843bSAndroid Build Coastguard Worker                                int responseType, int serial, RIL_Errno e,
6092*062a843bSAndroid Build Coastguard Worker                                void *response, size_t responseLen) {
6093*062a843bSAndroid Build Coastguard Worker #if VDBG
6094*062a843bSAndroid Build Coastguard Worker     RLOGD("nvWriteItemResponse: serial %d", serial);
6095*062a843bSAndroid Build Coastguard Worker #endif
6096*062a843bSAndroid Build Coastguard Worker 
6097*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6098*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6099*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6100*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6101*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
6102*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6103*062a843bSAndroid Build Coastguard Worker     } else {
6104*062a843bSAndroid Build Coastguard Worker         RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6105*062a843bSAndroid Build Coastguard Worker     }
6106*062a843bSAndroid Build Coastguard Worker 
6107*062a843bSAndroid Build Coastguard Worker     return 0;
6108*062a843bSAndroid Build Coastguard Worker }
6109*062a843bSAndroid Build Coastguard Worker 
nvWriteCdmaPrlResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6110*062a843bSAndroid Build Coastguard Worker int radio::nvWriteCdmaPrlResponse(int slotId,
6111*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
6112*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
6113*062a843bSAndroid Build Coastguard Worker #if VDBG
6114*062a843bSAndroid Build Coastguard Worker     RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
6115*062a843bSAndroid Build Coastguard Worker #endif
6116*062a843bSAndroid Build Coastguard Worker 
6117*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6118*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6119*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6120*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6121*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
6122*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6123*062a843bSAndroid Build Coastguard Worker     } else {
6124*062a843bSAndroid Build Coastguard Worker         RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6125*062a843bSAndroid Build Coastguard Worker     }
6126*062a843bSAndroid Build Coastguard Worker 
6127*062a843bSAndroid Build Coastguard Worker     return 0;
6128*062a843bSAndroid Build Coastguard Worker }
6129*062a843bSAndroid Build Coastguard Worker 
nvResetConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6130*062a843bSAndroid Build Coastguard Worker int radio::nvResetConfigResponse(int slotId,
6131*062a843bSAndroid Build Coastguard Worker                                  int responseType, int serial, RIL_Errno e,
6132*062a843bSAndroid Build Coastguard Worker                                  void *response, size_t responseLen) {
6133*062a843bSAndroid Build Coastguard Worker #if VDBG
6134*062a843bSAndroid Build Coastguard Worker     RLOGD("nvResetConfigResponse: serial %d", serial);
6135*062a843bSAndroid Build Coastguard Worker #endif
6136*062a843bSAndroid Build Coastguard Worker 
6137*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6138*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6139*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6140*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6141*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
6142*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6143*062a843bSAndroid Build Coastguard Worker     } else {
6144*062a843bSAndroid Build Coastguard Worker         RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6145*062a843bSAndroid Build Coastguard Worker     }
6146*062a843bSAndroid Build Coastguard Worker 
6147*062a843bSAndroid Build Coastguard Worker     return 0;
6148*062a843bSAndroid Build Coastguard Worker }
6149*062a843bSAndroid Build Coastguard Worker 
setUiccSubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6150*062a843bSAndroid Build Coastguard Worker int radio::setUiccSubscriptionResponse(int slotId,
6151*062a843bSAndroid Build Coastguard Worker                                        int responseType, int serial, RIL_Errno e,
6152*062a843bSAndroid Build Coastguard Worker                                        void *response, size_t responseLen) {
6153*062a843bSAndroid Build Coastguard Worker #if VDBG
6154*062a843bSAndroid Build Coastguard Worker     RLOGD("setUiccSubscriptionResponse: serial %d", serial);
6155*062a843bSAndroid Build Coastguard Worker #endif
6156*062a843bSAndroid Build Coastguard Worker 
6157*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6158*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6159*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6160*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6161*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
6162*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6163*062a843bSAndroid Build Coastguard Worker     } else {
6164*062a843bSAndroid Build Coastguard Worker         RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6165*062a843bSAndroid Build Coastguard Worker                 slotId);
6166*062a843bSAndroid Build Coastguard Worker     }
6167*062a843bSAndroid Build Coastguard Worker 
6168*062a843bSAndroid Build Coastguard Worker     return 0;
6169*062a843bSAndroid Build Coastguard Worker }
6170*062a843bSAndroid Build Coastguard Worker 
setDataAllowedResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6171*062a843bSAndroid Build Coastguard Worker int radio::setDataAllowedResponse(int slotId,
6172*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
6173*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
6174*062a843bSAndroid Build Coastguard Worker #if VDBG
6175*062a843bSAndroid Build Coastguard Worker     RLOGD("setDataAllowedResponse: serial %d", serial);
6176*062a843bSAndroid Build Coastguard Worker #endif
6177*062a843bSAndroid Build Coastguard Worker 
6178*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6179*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6180*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6181*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6182*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6183*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6184*062a843bSAndroid Build Coastguard Worker     } else {
6185*062a843bSAndroid Build Coastguard Worker         RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6186*062a843bSAndroid Build Coastguard Worker     }
6187*062a843bSAndroid Build Coastguard Worker 
6188*062a843bSAndroid Build Coastguard Worker     return 0;
6189*062a843bSAndroid Build Coastguard Worker }
6190*062a843bSAndroid Build Coastguard Worker 
getHardwareConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6191*062a843bSAndroid Build Coastguard Worker int radio::getHardwareConfigResponse(int slotId,
6192*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
6193*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
6194*062a843bSAndroid Build Coastguard Worker #if VDBG
6195*062a843bSAndroid Build Coastguard Worker     RLOGD("getHardwareConfigResponse: serial %d", serial);
6196*062a843bSAndroid Build Coastguard Worker #endif
6197*062a843bSAndroid Build Coastguard Worker 
6198*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6199*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6200*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6201*062a843bSAndroid Build Coastguard Worker 
6202*062a843bSAndroid Build Coastguard Worker         hidl_vec<HardwareConfig> result;
6203*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
6204*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6205*062a843bSAndroid Build Coastguard Worker             RLOGE("hardwareConfigChangedInd: invalid response");
6206*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6207*062a843bSAndroid Build Coastguard Worker         } else {
6208*062a843bSAndroid Build Coastguard Worker             convertRilHardwareConfigListToHal(response, responseLen, result);
6209*062a843bSAndroid Build Coastguard Worker         }
6210*062a843bSAndroid Build Coastguard Worker 
6211*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6212*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
6213*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6214*062a843bSAndroid Build Coastguard Worker     } else {
6215*062a843bSAndroid Build Coastguard Worker         RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6216*062a843bSAndroid Build Coastguard Worker     }
6217*062a843bSAndroid Build Coastguard Worker 
6218*062a843bSAndroid Build Coastguard Worker     return 0;
6219*062a843bSAndroid Build Coastguard Worker }
6220*062a843bSAndroid Build Coastguard Worker 
requestIccSimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6221*062a843bSAndroid Build Coastguard Worker int radio::requestIccSimAuthenticationResponse(int slotId,
6222*062a843bSAndroid Build Coastguard Worker                                                int responseType, int serial, RIL_Errno e,
6223*062a843bSAndroid Build Coastguard Worker                                                void *response, size_t responseLen) {
6224*062a843bSAndroid Build Coastguard Worker #if VDBG
6225*062a843bSAndroid Build Coastguard Worker     RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6226*062a843bSAndroid Build Coastguard Worker #endif
6227*062a843bSAndroid Build Coastguard Worker 
6228*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6229*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6230*062a843bSAndroid Build Coastguard Worker         IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6231*062a843bSAndroid Build Coastguard Worker                 responseLen);
6232*062a843bSAndroid Build Coastguard Worker 
6233*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6234*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6235*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
6236*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6237*062a843bSAndroid Build Coastguard Worker     } else {
6238*062a843bSAndroid Build Coastguard Worker         RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6239*062a843bSAndroid Build Coastguard Worker                 "== NULL", slotId);
6240*062a843bSAndroid Build Coastguard Worker     }
6241*062a843bSAndroid Build Coastguard Worker 
6242*062a843bSAndroid Build Coastguard Worker     return 0;
6243*062a843bSAndroid Build Coastguard Worker }
6244*062a843bSAndroid Build Coastguard Worker 
setDataProfileResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6245*062a843bSAndroid Build Coastguard Worker int radio::setDataProfileResponse(int slotId,
6246*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
6247*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
6248*062a843bSAndroid Build Coastguard Worker #if VDBG
6249*062a843bSAndroid Build Coastguard Worker     RLOGD("setDataProfileResponse: serial %d", serial);
6250*062a843bSAndroid Build Coastguard Worker #endif
6251*062a843bSAndroid Build Coastguard Worker 
6252*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6253*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6254*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6255*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6256*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6257*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6258*062a843bSAndroid Build Coastguard Worker     } else {
6259*062a843bSAndroid Build Coastguard Worker         RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6260*062a843bSAndroid Build Coastguard Worker     }
6261*062a843bSAndroid Build Coastguard Worker 
6262*062a843bSAndroid Build Coastguard Worker     return 0;
6263*062a843bSAndroid Build Coastguard Worker }
6264*062a843bSAndroid Build Coastguard Worker 
requestShutdownResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6265*062a843bSAndroid Build Coastguard Worker int radio::requestShutdownResponse(int slotId,
6266*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
6267*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
6268*062a843bSAndroid Build Coastguard Worker #if VDBG
6269*062a843bSAndroid Build Coastguard Worker     RLOGD("requestShutdownResponse: serial %d", serial);
6270*062a843bSAndroid Build Coastguard Worker #endif
6271*062a843bSAndroid Build Coastguard Worker 
6272*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6273*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6274*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6275*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6276*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6277*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6278*062a843bSAndroid Build Coastguard Worker     } else {
6279*062a843bSAndroid Build Coastguard Worker         RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6280*062a843bSAndroid Build Coastguard Worker     }
6281*062a843bSAndroid Build Coastguard Worker 
6282*062a843bSAndroid Build Coastguard Worker     return 0;
6283*062a843bSAndroid Build Coastguard Worker }
6284*062a843bSAndroid Build Coastguard Worker 
responseRadioCapability(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen,RadioCapability & rc)6285*062a843bSAndroid Build Coastguard Worker void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6286*062a843bSAndroid Build Coastguard Worker         int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6287*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
6288*062a843bSAndroid Build Coastguard Worker 
6289*062a843bSAndroid Build Coastguard Worker     if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6290*062a843bSAndroid Build Coastguard Worker         RLOGE("responseRadioCapability: Invalid response");
6291*062a843bSAndroid Build Coastguard Worker         if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6292*062a843bSAndroid Build Coastguard Worker         rc.logicalModemUuid = hidl_string();
6293*062a843bSAndroid Build Coastguard Worker     } else {
6294*062a843bSAndroid Build Coastguard Worker         convertRilRadioCapabilityToHal(response, responseLen, rc);
6295*062a843bSAndroid Build Coastguard Worker     }
6296*062a843bSAndroid Build Coastguard Worker }
6297*062a843bSAndroid Build Coastguard Worker 
getRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6298*062a843bSAndroid Build Coastguard Worker int radio::getRadioCapabilityResponse(int slotId,
6299*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
6300*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
6301*062a843bSAndroid Build Coastguard Worker #if VDBG
6302*062a843bSAndroid Build Coastguard Worker     RLOGD("getRadioCapabilityResponse: serial %d", serial);
6303*062a843bSAndroid Build Coastguard Worker #endif
6304*062a843bSAndroid Build Coastguard Worker 
6305*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6306*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6307*062a843bSAndroid Build Coastguard Worker         RadioCapability result = {};
6308*062a843bSAndroid Build Coastguard Worker         responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6309*062a843bSAndroid Build Coastguard Worker                 result);
6310*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6311*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
6312*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6313*062a843bSAndroid Build Coastguard Worker     } else {
6314*062a843bSAndroid Build Coastguard Worker         RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6315*062a843bSAndroid Build Coastguard Worker     }
6316*062a843bSAndroid Build Coastguard Worker 
6317*062a843bSAndroid Build Coastguard Worker     return 0;
6318*062a843bSAndroid Build Coastguard Worker }
6319*062a843bSAndroid Build Coastguard Worker 
setRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6320*062a843bSAndroid Build Coastguard Worker int radio::setRadioCapabilityResponse(int slotId,
6321*062a843bSAndroid Build Coastguard Worker                                      int responseType, int serial, RIL_Errno e,
6322*062a843bSAndroid Build Coastguard Worker                                      void *response, size_t responseLen) {
6323*062a843bSAndroid Build Coastguard Worker #if VDBG
6324*062a843bSAndroid Build Coastguard Worker     RLOGD("setRadioCapabilityResponse: serial %d", serial);
6325*062a843bSAndroid Build Coastguard Worker #endif
6326*062a843bSAndroid Build Coastguard Worker 
6327*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6328*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6329*062a843bSAndroid Build Coastguard Worker         RadioCapability result = {};
6330*062a843bSAndroid Build Coastguard Worker         responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6331*062a843bSAndroid Build Coastguard Worker                 result);
6332*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6333*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
6334*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6335*062a843bSAndroid Build Coastguard Worker     } else {
6336*062a843bSAndroid Build Coastguard Worker         RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6337*062a843bSAndroid Build Coastguard Worker     }
6338*062a843bSAndroid Build Coastguard Worker 
6339*062a843bSAndroid Build Coastguard Worker     return 0;
6340*062a843bSAndroid Build Coastguard Worker }
6341*062a843bSAndroid Build Coastguard Worker 
responseLceStatusInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6342*062a843bSAndroid Build Coastguard Worker LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6343*062a843bSAndroid Build Coastguard Worker                                     RIL_Errno e, void *response, size_t responseLen) {
6344*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
6345*062a843bSAndroid Build Coastguard Worker     LceStatusInfo result = {};
6346*062a843bSAndroid Build Coastguard Worker 
6347*062a843bSAndroid Build Coastguard Worker     if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6348*062a843bSAndroid Build Coastguard Worker         RLOGE("Invalid response: NULL");
6349*062a843bSAndroid Build Coastguard Worker         if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6350*062a843bSAndroid Build Coastguard Worker     } else {
6351*062a843bSAndroid Build Coastguard Worker         RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6352*062a843bSAndroid Build Coastguard Worker         result.lceStatus = (LceStatus) resp->lce_status;
6353*062a843bSAndroid Build Coastguard Worker         result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6354*062a843bSAndroid Build Coastguard Worker     }
6355*062a843bSAndroid Build Coastguard Worker     return result;
6356*062a843bSAndroid Build Coastguard Worker }
6357*062a843bSAndroid Build Coastguard Worker 
startLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6358*062a843bSAndroid Build Coastguard Worker int radio::startLceServiceResponse(int slotId,
6359*062a843bSAndroid Build Coastguard Worker                                    int responseType, int serial, RIL_Errno e,
6360*062a843bSAndroid Build Coastguard Worker                                    void *response, size_t responseLen) {
6361*062a843bSAndroid Build Coastguard Worker #if VDBG
6362*062a843bSAndroid Build Coastguard Worker     RLOGD("startLceServiceResponse: serial %d", serial);
6363*062a843bSAndroid Build Coastguard Worker #endif
6364*062a843bSAndroid Build Coastguard Worker 
6365*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6366*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6367*062a843bSAndroid Build Coastguard Worker         LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6368*062a843bSAndroid Build Coastguard Worker                 response, responseLen);
6369*062a843bSAndroid Build Coastguard Worker 
6370*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6371*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6372*062a843bSAndroid Build Coastguard Worker                 result);
6373*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6374*062a843bSAndroid Build Coastguard Worker     } else {
6375*062a843bSAndroid Build Coastguard Worker         RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6376*062a843bSAndroid Build Coastguard Worker     }
6377*062a843bSAndroid Build Coastguard Worker 
6378*062a843bSAndroid Build Coastguard Worker     return 0;
6379*062a843bSAndroid Build Coastguard Worker }
6380*062a843bSAndroid Build Coastguard Worker 
stopLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6381*062a843bSAndroid Build Coastguard Worker int radio::stopLceServiceResponse(int slotId,
6382*062a843bSAndroid Build Coastguard Worker                                   int responseType, int serial, RIL_Errno e,
6383*062a843bSAndroid Build Coastguard Worker                                   void *response, size_t responseLen) {
6384*062a843bSAndroid Build Coastguard Worker #if VDBG
6385*062a843bSAndroid Build Coastguard Worker     RLOGD("stopLceServiceResponse: serial %d", serial);
6386*062a843bSAndroid Build Coastguard Worker #endif
6387*062a843bSAndroid Build Coastguard Worker 
6388*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6389*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6390*062a843bSAndroid Build Coastguard Worker         LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6391*062a843bSAndroid Build Coastguard Worker                 response, responseLen);
6392*062a843bSAndroid Build Coastguard Worker 
6393*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6394*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6395*062a843bSAndroid Build Coastguard Worker                 result);
6396*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6397*062a843bSAndroid Build Coastguard Worker     } else {
6398*062a843bSAndroid Build Coastguard Worker         RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6399*062a843bSAndroid Build Coastguard Worker     }
6400*062a843bSAndroid Build Coastguard Worker 
6401*062a843bSAndroid Build Coastguard Worker     return 0;
6402*062a843bSAndroid Build Coastguard Worker }
6403*062a843bSAndroid Build Coastguard Worker 
pullLceDataResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6404*062a843bSAndroid Build Coastguard Worker int radio::pullLceDataResponse(int slotId,
6405*062a843bSAndroid Build Coastguard Worker                                int responseType, int serial, RIL_Errno e,
6406*062a843bSAndroid Build Coastguard Worker                                void *response, size_t responseLen) {
6407*062a843bSAndroid Build Coastguard Worker #if VDBG
6408*062a843bSAndroid Build Coastguard Worker     RLOGD("pullLceDataResponse: serial %d", serial);
6409*062a843bSAndroid Build Coastguard Worker #endif
6410*062a843bSAndroid Build Coastguard Worker 
6411*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6412*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6413*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6414*062a843bSAndroid Build Coastguard Worker 
6415*062a843bSAndroid Build Coastguard Worker         LceDataInfo result = {};
6416*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6417*062a843bSAndroid Build Coastguard Worker             RLOGE("pullLceDataResponse: Invalid response");
6418*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6419*062a843bSAndroid Build Coastguard Worker         } else {
6420*062a843bSAndroid Build Coastguard Worker             convertRilLceDataInfoToHal(response, responseLen, result);
6421*062a843bSAndroid Build Coastguard Worker         }
6422*062a843bSAndroid Build Coastguard Worker 
6423*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6424*062a843bSAndroid Build Coastguard Worker                 responseInfo, result);
6425*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6426*062a843bSAndroid Build Coastguard Worker     } else {
6427*062a843bSAndroid Build Coastguard Worker         RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6428*062a843bSAndroid Build Coastguard Worker     }
6429*062a843bSAndroid Build Coastguard Worker 
6430*062a843bSAndroid Build Coastguard Worker     return 0;
6431*062a843bSAndroid Build Coastguard Worker }
6432*062a843bSAndroid Build Coastguard Worker 
getModemActivityInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6433*062a843bSAndroid Build Coastguard Worker int radio::getModemActivityInfoResponse(int slotId,
6434*062a843bSAndroid Build Coastguard Worker                                         int responseType, int serial, RIL_Errno e,
6435*062a843bSAndroid Build Coastguard Worker                                         void *response, size_t responseLen) {
6436*062a843bSAndroid Build Coastguard Worker #if VDBG
6437*062a843bSAndroid Build Coastguard Worker     RLOGD("getModemActivityInfoResponse: serial %d", serial);
6438*062a843bSAndroid Build Coastguard Worker #endif
6439*062a843bSAndroid Build Coastguard Worker 
6440*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6441*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6442*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6443*062a843bSAndroid Build Coastguard Worker         ActivityStatsInfo info;
6444*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6445*062a843bSAndroid Build Coastguard Worker             RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6446*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6447*062a843bSAndroid Build Coastguard Worker         } else {
6448*062a843bSAndroid Build Coastguard Worker             RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6449*062a843bSAndroid Build Coastguard Worker             info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6450*062a843bSAndroid Build Coastguard Worker             info.idleModeTimeMs = resp->idle_mode_time_ms;
6451*062a843bSAndroid Build Coastguard Worker             for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6452*062a843bSAndroid Build Coastguard Worker                 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6453*062a843bSAndroid Build Coastguard Worker             }
6454*062a843bSAndroid Build Coastguard Worker             info.rxModeTimeMs = resp->rx_mode_time_ms;
6455*062a843bSAndroid Build Coastguard Worker         }
6456*062a843bSAndroid Build Coastguard Worker 
6457*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6458*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6459*062a843bSAndroid Build Coastguard Worker                 info);
6460*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6461*062a843bSAndroid Build Coastguard Worker     } else {
6462*062a843bSAndroid Build Coastguard Worker         RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6463*062a843bSAndroid Build Coastguard Worker                 slotId);
6464*062a843bSAndroid Build Coastguard Worker     }
6465*062a843bSAndroid Build Coastguard Worker 
6466*062a843bSAndroid Build Coastguard Worker     return 0;
6467*062a843bSAndroid Build Coastguard Worker }
6468*062a843bSAndroid Build Coastguard Worker 
setAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6469*062a843bSAndroid Build Coastguard Worker int radio::setAllowedCarriersResponse(int slotId,
6470*062a843bSAndroid Build Coastguard Worker                                       int responseType, int serial, RIL_Errno e,
6471*062a843bSAndroid Build Coastguard Worker                                       void *response, size_t responseLen) {
6472*062a843bSAndroid Build Coastguard Worker #if VDBG
6473*062a843bSAndroid Build Coastguard Worker     RLOGD("setAllowedCarriersResponse: serial %d", serial);
6474*062a843bSAndroid Build Coastguard Worker #endif
6475*062a843bSAndroid Build Coastguard Worker 
6476*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6477*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6478*062a843bSAndroid Build Coastguard Worker         int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6479*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6480*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6481*062a843bSAndroid Build Coastguard Worker                 ret);
6482*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6483*062a843bSAndroid Build Coastguard Worker     } else {
6484*062a843bSAndroid Build Coastguard Worker         RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6485*062a843bSAndroid Build Coastguard Worker                 slotId);
6486*062a843bSAndroid Build Coastguard Worker     }
6487*062a843bSAndroid Build Coastguard Worker 
6488*062a843bSAndroid Build Coastguard Worker     return 0;
6489*062a843bSAndroid Build Coastguard Worker }
6490*062a843bSAndroid Build Coastguard Worker 
getAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6491*062a843bSAndroid Build Coastguard Worker int radio::getAllowedCarriersResponse(int slotId,
6492*062a843bSAndroid Build Coastguard Worker                                       int responseType, int serial, RIL_Errno e,
6493*062a843bSAndroid Build Coastguard Worker                                       void *response, size_t responseLen) {
6494*062a843bSAndroid Build Coastguard Worker #if VDBG
6495*062a843bSAndroid Build Coastguard Worker     RLOGD("getAllowedCarriersResponse: serial %d", serial);
6496*062a843bSAndroid Build Coastguard Worker #endif
6497*062a843bSAndroid Build Coastguard Worker 
6498*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6499*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6500*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6501*062a843bSAndroid Build Coastguard Worker         CarrierRestrictions carrierInfo = {};
6502*062a843bSAndroid Build Coastguard Worker         bool allAllowed = true;
6503*062a843bSAndroid Build Coastguard Worker         if (response == NULL) {
6504*062a843bSAndroid Build Coastguard Worker #if VDBG
6505*062a843bSAndroid Build Coastguard Worker             RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6506*062a843bSAndroid Build Coastguard Worker #endif
6507*062a843bSAndroid Build Coastguard Worker             carrierInfo.allowedCarriers.resize(0);
6508*062a843bSAndroid Build Coastguard Worker             carrierInfo.excludedCarriers.resize(0);
6509*062a843bSAndroid Build Coastguard Worker         } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6510*062a843bSAndroid Build Coastguard Worker             RLOGE("getAllowedCarriersResponse Invalid response");
6511*062a843bSAndroid Build Coastguard Worker             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6512*062a843bSAndroid Build Coastguard Worker         } else {
6513*062a843bSAndroid Build Coastguard Worker             RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6514*062a843bSAndroid Build Coastguard Worker             if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6515*062a843bSAndroid Build Coastguard Worker                 allAllowed = false;
6516*062a843bSAndroid Build Coastguard Worker             }
6517*062a843bSAndroid Build Coastguard Worker 
6518*062a843bSAndroid Build Coastguard Worker             carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6519*062a843bSAndroid Build Coastguard Worker             for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6520*062a843bSAndroid Build Coastguard Worker                 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6521*062a843bSAndroid Build Coastguard Worker                 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6522*062a843bSAndroid Build Coastguard Worker                 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6523*062a843bSAndroid Build Coastguard Worker                 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6524*062a843bSAndroid Build Coastguard Worker                 carrierInfo.allowedCarriers[i].matchData =
6525*062a843bSAndroid Build Coastguard Worker                         convertCharPtrToHidlString(carrier->match_data);
6526*062a843bSAndroid Build Coastguard Worker             }
6527*062a843bSAndroid Build Coastguard Worker 
6528*062a843bSAndroid Build Coastguard Worker             carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6529*062a843bSAndroid Build Coastguard Worker             for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6530*062a843bSAndroid Build Coastguard Worker                 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6531*062a843bSAndroid Build Coastguard Worker                 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6532*062a843bSAndroid Build Coastguard Worker                 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6533*062a843bSAndroid Build Coastguard Worker                 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6534*062a843bSAndroid Build Coastguard Worker                 carrierInfo.excludedCarriers[i].matchData =
6535*062a843bSAndroid Build Coastguard Worker                         convertCharPtrToHidlString(carrier->match_data);
6536*062a843bSAndroid Build Coastguard Worker             }
6537*062a843bSAndroid Build Coastguard Worker         }
6538*062a843bSAndroid Build Coastguard Worker 
6539*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6540*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6541*062a843bSAndroid Build Coastguard Worker                 allAllowed, carrierInfo);
6542*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6543*062a843bSAndroid Build Coastguard Worker     } else {
6544*062a843bSAndroid Build Coastguard Worker         RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6545*062a843bSAndroid Build Coastguard Worker                 slotId);
6546*062a843bSAndroid Build Coastguard Worker     }
6547*062a843bSAndroid Build Coastguard Worker 
6548*062a843bSAndroid Build Coastguard Worker     return 0;
6549*062a843bSAndroid Build Coastguard Worker }
6550*062a843bSAndroid Build Coastguard Worker 
sendDeviceStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)6551*062a843bSAndroid Build Coastguard Worker int radio::sendDeviceStateResponse(int slotId,
6552*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e,
6553*062a843bSAndroid Build Coastguard Worker                               void *response, size_t responselen) {
6554*062a843bSAndroid Build Coastguard Worker #if VDBG
6555*062a843bSAndroid Build Coastguard Worker     RLOGD("sendDeviceStateResponse: serial %d", serial);
6556*062a843bSAndroid Build Coastguard Worker #endif
6557*062a843bSAndroid Build Coastguard Worker 
6558*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6559*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6560*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6561*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6562*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6563*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6564*062a843bSAndroid Build Coastguard Worker     } else {
6565*062a843bSAndroid Build Coastguard Worker         RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6566*062a843bSAndroid Build Coastguard Worker     }
6567*062a843bSAndroid Build Coastguard Worker 
6568*062a843bSAndroid Build Coastguard Worker     return 0;
6569*062a843bSAndroid Build Coastguard Worker }
6570*062a843bSAndroid Build Coastguard Worker 
setCarrierInfoForImsiEncryptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6571*062a843bSAndroid Build Coastguard Worker int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6572*062a843bSAndroid Build Coastguard Worker                                int responseType, int serial, RIL_Errno e,
6573*062a843bSAndroid Build Coastguard Worker                                void *response, size_t responseLen) {
6574*062a843bSAndroid Build Coastguard Worker     RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6575*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6576*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6577*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6578*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6579*062a843bSAndroid Build Coastguard Worker                 setCarrierInfoForImsiEncryptionResponse(responseInfo);
6580*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6581*062a843bSAndroid Build Coastguard Worker     } else {
6582*062a843bSAndroid Build Coastguard Worker         RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
6583*062a843bSAndroid Build Coastguard Worker                 "NULL", slotId);
6584*062a843bSAndroid Build Coastguard Worker     }
6585*062a843bSAndroid Build Coastguard Worker     return 0;
6586*062a843bSAndroid Build Coastguard Worker }
6587*062a843bSAndroid Build Coastguard Worker 
setIndicationFilterResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)6588*062a843bSAndroid Build Coastguard Worker int radio::setIndicationFilterResponse(int slotId,
6589*062a843bSAndroid Build Coastguard Worker                               int responseType, int serial, RIL_Errno e,
6590*062a843bSAndroid Build Coastguard Worker                               void *response, size_t responselen) {
6591*062a843bSAndroid Build Coastguard Worker #if VDBG
6592*062a843bSAndroid Build Coastguard Worker     RLOGD("setIndicationFilterResponse: serial %d", serial);
6593*062a843bSAndroid Build Coastguard Worker #endif
6594*062a843bSAndroid Build Coastguard Worker 
6595*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL) {
6596*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6597*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6598*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6599*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6600*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6601*062a843bSAndroid Build Coastguard Worker     } else {
6602*062a843bSAndroid Build Coastguard Worker         RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6603*062a843bSAndroid Build Coastguard Worker                 slotId);
6604*062a843bSAndroid Build Coastguard Worker     }
6605*062a843bSAndroid Build Coastguard Worker 
6606*062a843bSAndroid Build Coastguard Worker     return 0;
6607*062a843bSAndroid Build Coastguard Worker }
6608*062a843bSAndroid Build Coastguard Worker 
setSimCardPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6609*062a843bSAndroid Build Coastguard Worker int radio::setSimCardPowerResponse(int slotId,
6610*062a843bSAndroid Build Coastguard Worker                                    int responseType, int serial, RIL_Errno e,
6611*062a843bSAndroid Build Coastguard Worker                                    void *response, size_t responseLen) {
6612*062a843bSAndroid Build Coastguard Worker #if VDBG
6613*062a843bSAndroid Build Coastguard Worker     RLOGD("setSimCardPowerResponse: serial %d", serial);
6614*062a843bSAndroid Build Coastguard Worker #endif
6615*062a843bSAndroid Build Coastguard Worker 
6616*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponse != NULL
6617*062a843bSAndroid Build Coastguard Worker             || radioService[slotId]->mRadioResponseV1_1 != NULL) {
6618*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6619*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6620*062a843bSAndroid Build Coastguard Worker         if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6621*062a843bSAndroid Build Coastguard Worker             Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6622*062a843bSAndroid Build Coastguard Worker                     setSimCardPowerResponse_1_1(responseInfo);
6623*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->checkReturnStatus(retStatus);
6624*062a843bSAndroid Build Coastguard Worker         } else {
6625*062a843bSAndroid Build Coastguard Worker             RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_1 == NULL",
6626*062a843bSAndroid Build Coastguard Worker                     slotId);
6627*062a843bSAndroid Build Coastguard Worker             Return<void> retStatus
6628*062a843bSAndroid Build Coastguard Worker                     = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6629*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->checkReturnStatus(retStatus);
6630*062a843bSAndroid Build Coastguard Worker         }
6631*062a843bSAndroid Build Coastguard Worker     } else {
6632*062a843bSAndroid Build Coastguard Worker         RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
6633*062a843bSAndroid Build Coastguard Worker                 "radioService[%d]->mRadioResponseV1_1 == NULL", slotId, slotId);
6634*062a843bSAndroid Build Coastguard Worker     }
6635*062a843bSAndroid Build Coastguard Worker     return 0;
6636*062a843bSAndroid Build Coastguard Worker }
6637*062a843bSAndroid Build Coastguard Worker 
startNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6638*062a843bSAndroid Build Coastguard Worker int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6639*062a843bSAndroid Build Coastguard Worker                                     void *response, size_t responseLen) {
6640*062a843bSAndroid Build Coastguard Worker #if VDBG
6641*062a843bSAndroid Build Coastguard Worker     RLOGD("startNetworkScanResponse: serial %d", serial);
6642*062a843bSAndroid Build Coastguard Worker #endif
6643*062a843bSAndroid Build Coastguard Worker 
6644*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6645*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6646*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6647*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6648*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponseV1_1->startNetworkScanResponse(responseInfo);
6649*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6650*062a843bSAndroid Build Coastguard Worker     } else {
6651*062a843bSAndroid Build Coastguard Worker         RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6652*062a843bSAndroid Build Coastguard Worker     }
6653*062a843bSAndroid Build Coastguard Worker 
6654*062a843bSAndroid Build Coastguard Worker     return 0;
6655*062a843bSAndroid Build Coastguard Worker }
6656*062a843bSAndroid Build Coastguard Worker 
stopNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6657*062a843bSAndroid Build Coastguard Worker int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6658*062a843bSAndroid Build Coastguard Worker                                    void *response, size_t responseLen) {
6659*062a843bSAndroid Build Coastguard Worker #if VDBG
6660*062a843bSAndroid Build Coastguard Worker     RLOGD("stopNetworkScanResponse: serial %d", serial);
6661*062a843bSAndroid Build Coastguard Worker #endif
6662*062a843bSAndroid Build Coastguard Worker 
6663*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6664*062a843bSAndroid Build Coastguard Worker         RadioResponseInfo responseInfo = {};
6665*062a843bSAndroid Build Coastguard Worker         populateResponseInfo(responseInfo, serial, responseType, e);
6666*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus
6667*062a843bSAndroid Build Coastguard Worker                 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
6668*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6669*062a843bSAndroid Build Coastguard Worker     } else {
6670*062a843bSAndroid Build Coastguard Worker         RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6671*062a843bSAndroid Build Coastguard Worker     }
6672*062a843bSAndroid Build Coastguard Worker 
6673*062a843bSAndroid Build Coastguard Worker     return 0;
6674*062a843bSAndroid Build Coastguard Worker }
6675*062a843bSAndroid Build Coastguard Worker 
convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus * rilStatus,V1_1::KeepaliveStatus & halStatus)6676*062a843bSAndroid Build Coastguard Worker void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
6677*062a843bSAndroid Build Coastguard Worker         V1_1::KeepaliveStatus& halStatus) {
6678*062a843bSAndroid Build Coastguard Worker     halStatus.sessionHandle = rilStatus->sessionHandle;
6679*062a843bSAndroid Build Coastguard Worker     halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
6680*062a843bSAndroid Build Coastguard Worker }
6681*062a843bSAndroid Build Coastguard Worker 
startKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6682*062a843bSAndroid Build Coastguard Worker int radio::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6683*062a843bSAndroid Build Coastguard Worker                                     void *response, size_t responseLen) {
6684*062a843bSAndroid Build Coastguard Worker #if VDBG
6685*062a843bSAndroid Build Coastguard Worker     RLOGD("%s(): %d", __FUNCTION__, serial);
6686*062a843bSAndroid Build Coastguard Worker #endif
6687*062a843bSAndroid Build Coastguard Worker     RadioResponseInfo responseInfo = {};
6688*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
6689*062a843bSAndroid Build Coastguard Worker 
6690*062a843bSAndroid Build Coastguard Worker     // If we don't have a radio service, there's nothing we can do
6691*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6692*062a843bSAndroid Build Coastguard Worker         RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6693*062a843bSAndroid Build Coastguard Worker         return 0;
6694*062a843bSAndroid Build Coastguard Worker     }
6695*062a843bSAndroid Build Coastguard Worker 
6696*062a843bSAndroid Build Coastguard Worker     V1_1::KeepaliveStatus ks = {};
6697*062a843bSAndroid Build Coastguard Worker     if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
6698*062a843bSAndroid Build Coastguard Worker         RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
6699*062a843bSAndroid Build Coastguard Worker         if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6700*062a843bSAndroid Build Coastguard Worker     } else {
6701*062a843bSAndroid Build Coastguard Worker         convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
6702*062a843bSAndroid Build Coastguard Worker     }
6703*062a843bSAndroid Build Coastguard Worker 
6704*062a843bSAndroid Build Coastguard Worker     Return<void> retStatus =
6705*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
6706*062a843bSAndroid Build Coastguard Worker     radioService[slotId]->checkReturnStatus(retStatus);
6707*062a843bSAndroid Build Coastguard Worker     return 0;
6708*062a843bSAndroid Build Coastguard Worker }
6709*062a843bSAndroid Build Coastguard Worker 
stopKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6710*062a843bSAndroid Build Coastguard Worker int radio::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6711*062a843bSAndroid Build Coastguard Worker                                     void *response, size_t responseLen) {
6712*062a843bSAndroid Build Coastguard Worker #if VDBG
6713*062a843bSAndroid Build Coastguard Worker     RLOGD("%s(): %d", __FUNCTION__, serial);
6714*062a843bSAndroid Build Coastguard Worker #endif
6715*062a843bSAndroid Build Coastguard Worker     RadioResponseInfo responseInfo = {};
6716*062a843bSAndroid Build Coastguard Worker     populateResponseInfo(responseInfo, serial, responseType, e);
6717*062a843bSAndroid Build Coastguard Worker 
6718*062a843bSAndroid Build Coastguard Worker     // If we don't have a radio service, there's nothing we can do
6719*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6720*062a843bSAndroid Build Coastguard Worker         RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6721*062a843bSAndroid Build Coastguard Worker         return 0;
6722*062a843bSAndroid Build Coastguard Worker     }
6723*062a843bSAndroid Build Coastguard Worker 
6724*062a843bSAndroid Build Coastguard Worker     Return<void> retStatus =
6725*062a843bSAndroid Build Coastguard Worker             radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
6726*062a843bSAndroid Build Coastguard Worker     radioService[slotId]->checkReturnStatus(retStatus);
6727*062a843bSAndroid Build Coastguard Worker     return 0;
6728*062a843bSAndroid Build Coastguard Worker }
6729*062a843bSAndroid Build Coastguard Worker 
6730*062a843bSAndroid Build Coastguard Worker /***************************************************************************************************
6731*062a843bSAndroid Build Coastguard Worker  * INDICATION FUNCTIONS
6732*062a843bSAndroid Build Coastguard Worker  * The below function handle unsolicited messages coming from the Radio
6733*062a843bSAndroid Build Coastguard Worker  * (messages for which there is no pending request)
6734*062a843bSAndroid Build Coastguard Worker  **************************************************************************************************/
6735*062a843bSAndroid Build Coastguard Worker 
convertIntToRadioIndicationType(int indicationType)6736*062a843bSAndroid Build Coastguard Worker RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6737*062a843bSAndroid Build Coastguard Worker     return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6738*062a843bSAndroid Build Coastguard Worker             (RadioIndicationType::UNSOLICITED_ACK_EXP);
6739*062a843bSAndroid Build Coastguard Worker }
6740*062a843bSAndroid Build Coastguard Worker 
radioStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6741*062a843bSAndroid Build Coastguard Worker int radio::radioStateChangedInd(int slotId,
6742*062a843bSAndroid Build Coastguard Worker                                  int indicationType, int token, RIL_Errno e, void *response,
6743*062a843bSAndroid Build Coastguard Worker                                  size_t responseLen) {
6744*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6745*062a843bSAndroid Build Coastguard Worker         RadioState radioState =
6746*062a843bSAndroid Build Coastguard Worker                 (RadioState) CALL_ONSTATEREQUEST(slotId);
6747*062a843bSAndroid Build Coastguard Worker         RLOGD("radioStateChangedInd: radioState %d", radioState);
6748*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6749*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), radioState);
6750*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6751*062a843bSAndroid Build Coastguard Worker     } else {
6752*062a843bSAndroid Build Coastguard Worker         RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6753*062a843bSAndroid Build Coastguard Worker     }
6754*062a843bSAndroid Build Coastguard Worker 
6755*062a843bSAndroid Build Coastguard Worker     return 0;
6756*062a843bSAndroid Build Coastguard Worker }
6757*062a843bSAndroid Build Coastguard Worker 
callStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6758*062a843bSAndroid Build Coastguard Worker int radio::callStateChangedInd(int slotId,
6759*062a843bSAndroid Build Coastguard Worker                                int indicationType, int token, RIL_Errno e, void *response,
6760*062a843bSAndroid Build Coastguard Worker                                size_t responseLen) {
6761*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6762*062a843bSAndroid Build Coastguard Worker #if VDBG
6763*062a843bSAndroid Build Coastguard Worker         RLOGD("callStateChangedInd");
6764*062a843bSAndroid Build Coastguard Worker #endif
6765*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6766*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
6767*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6768*062a843bSAndroid Build Coastguard Worker     } else {
6769*062a843bSAndroid Build Coastguard Worker         RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6770*062a843bSAndroid Build Coastguard Worker     }
6771*062a843bSAndroid Build Coastguard Worker 
6772*062a843bSAndroid Build Coastguard Worker     return 0;
6773*062a843bSAndroid Build Coastguard Worker }
6774*062a843bSAndroid Build Coastguard Worker 
networkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6775*062a843bSAndroid Build Coastguard Worker int radio::networkStateChangedInd(int slotId,
6776*062a843bSAndroid Build Coastguard Worker                                   int indicationType, int token, RIL_Errno e, void *response,
6777*062a843bSAndroid Build Coastguard Worker                                   size_t responseLen) {
6778*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6779*062a843bSAndroid Build Coastguard Worker #if VDBG
6780*062a843bSAndroid Build Coastguard Worker         RLOGD("networkStateChangedInd");
6781*062a843bSAndroid Build Coastguard Worker #endif
6782*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6783*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
6784*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6785*062a843bSAndroid Build Coastguard Worker     } else {
6786*062a843bSAndroid Build Coastguard Worker         RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6787*062a843bSAndroid Build Coastguard Worker                 slotId);
6788*062a843bSAndroid Build Coastguard Worker     }
6789*062a843bSAndroid Build Coastguard Worker 
6790*062a843bSAndroid Build Coastguard Worker     return 0;
6791*062a843bSAndroid Build Coastguard Worker }
6792*062a843bSAndroid Build Coastguard Worker 
hexCharToInt(uint8_t c)6793*062a843bSAndroid Build Coastguard Worker uint8_t hexCharToInt(uint8_t c) {
6794*062a843bSAndroid Build Coastguard Worker     if (c >= '0' && c <= '9') return (c - '0');
6795*062a843bSAndroid Build Coastguard Worker     if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6796*062a843bSAndroid Build Coastguard Worker     if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6797*062a843bSAndroid Build Coastguard Worker 
6798*062a843bSAndroid Build Coastguard Worker     return INVALID_HEX_CHAR;
6799*062a843bSAndroid Build Coastguard Worker }
6800*062a843bSAndroid Build Coastguard Worker 
convertHexStringToBytes(void * response,size_t responseLen)6801*062a843bSAndroid Build Coastguard Worker uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6802*062a843bSAndroid Build Coastguard Worker     if (responseLen % 2 != 0) {
6803*062a843bSAndroid Build Coastguard Worker         return NULL;
6804*062a843bSAndroid Build Coastguard Worker     }
6805*062a843bSAndroid Build Coastguard Worker 
6806*062a843bSAndroid Build Coastguard Worker     uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6807*062a843bSAndroid Build Coastguard Worker     if (bytes == NULL) {
6808*062a843bSAndroid Build Coastguard Worker         RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6809*062a843bSAndroid Build Coastguard Worker         return NULL;
6810*062a843bSAndroid Build Coastguard Worker     }
6811*062a843bSAndroid Build Coastguard Worker     uint8_t *hexString = (uint8_t *)response;
6812*062a843bSAndroid Build Coastguard Worker 
6813*062a843bSAndroid Build Coastguard Worker     for (size_t i = 0; i < responseLen; i += 2) {
6814*062a843bSAndroid Build Coastguard Worker         uint8_t hexChar1 = hexCharToInt(hexString[i]);
6815*062a843bSAndroid Build Coastguard Worker         uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6816*062a843bSAndroid Build Coastguard Worker 
6817*062a843bSAndroid Build Coastguard Worker         if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6818*062a843bSAndroid Build Coastguard Worker             RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6819*062a843bSAndroid Build Coastguard Worker                     hexString[i], hexString[i + 1]);
6820*062a843bSAndroid Build Coastguard Worker             free(bytes);
6821*062a843bSAndroid Build Coastguard Worker             return NULL;
6822*062a843bSAndroid Build Coastguard Worker         }
6823*062a843bSAndroid Build Coastguard Worker         bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6824*062a843bSAndroid Build Coastguard Worker     }
6825*062a843bSAndroid Build Coastguard Worker 
6826*062a843bSAndroid Build Coastguard Worker     return bytes;
6827*062a843bSAndroid Build Coastguard Worker }
6828*062a843bSAndroid Build Coastguard Worker 
newSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6829*062a843bSAndroid Build Coastguard Worker int radio::newSmsInd(int slotId, int indicationType,
6830*062a843bSAndroid Build Coastguard Worker                      int token, RIL_Errno e, void *response, size_t responseLen) {
6831*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6832*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
6833*062a843bSAndroid Build Coastguard Worker             RLOGE("newSmsInd: invalid response");
6834*062a843bSAndroid Build Coastguard Worker             return 0;
6835*062a843bSAndroid Build Coastguard Worker         }
6836*062a843bSAndroid Build Coastguard Worker 
6837*062a843bSAndroid Build Coastguard Worker         uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6838*062a843bSAndroid Build Coastguard Worker         if (bytes == NULL) {
6839*062a843bSAndroid Build Coastguard Worker             RLOGE("newSmsInd: convertHexStringToBytes failed");
6840*062a843bSAndroid Build Coastguard Worker             return 0;
6841*062a843bSAndroid Build Coastguard Worker         }
6842*062a843bSAndroid Build Coastguard Worker 
6843*062a843bSAndroid Build Coastguard Worker         hidl_vec<uint8_t> pdu;
6844*062a843bSAndroid Build Coastguard Worker         pdu.setToExternal(bytes, responseLen/2);
6845*062a843bSAndroid Build Coastguard Worker #if VDBG
6846*062a843bSAndroid Build Coastguard Worker         RLOGD("newSmsInd");
6847*062a843bSAndroid Build Coastguard Worker #endif
6848*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6849*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), pdu);
6850*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6851*062a843bSAndroid Build Coastguard Worker         free(bytes);
6852*062a843bSAndroid Build Coastguard Worker     } else {
6853*062a843bSAndroid Build Coastguard Worker         RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6854*062a843bSAndroid Build Coastguard Worker     }
6855*062a843bSAndroid Build Coastguard Worker 
6856*062a843bSAndroid Build Coastguard Worker     return 0;
6857*062a843bSAndroid Build Coastguard Worker }
6858*062a843bSAndroid Build Coastguard Worker 
newSmsStatusReportInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6859*062a843bSAndroid Build Coastguard Worker int radio::newSmsStatusReportInd(int slotId,
6860*062a843bSAndroid Build Coastguard Worker                                  int indicationType, int token, RIL_Errno e, void *response,
6861*062a843bSAndroid Build Coastguard Worker                                  size_t responseLen) {
6862*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6863*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
6864*062a843bSAndroid Build Coastguard Worker             RLOGE("newSmsStatusReportInd: invalid response");
6865*062a843bSAndroid Build Coastguard Worker             return 0;
6866*062a843bSAndroid Build Coastguard Worker         }
6867*062a843bSAndroid Build Coastguard Worker 
6868*062a843bSAndroid Build Coastguard Worker         uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6869*062a843bSAndroid Build Coastguard Worker         if (bytes == NULL) {
6870*062a843bSAndroid Build Coastguard Worker             RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6871*062a843bSAndroid Build Coastguard Worker             return 0;
6872*062a843bSAndroid Build Coastguard Worker         }
6873*062a843bSAndroid Build Coastguard Worker 
6874*062a843bSAndroid Build Coastguard Worker         hidl_vec<uint8_t> pdu;
6875*062a843bSAndroid Build Coastguard Worker         pdu.setToExternal(bytes, responseLen/2);
6876*062a843bSAndroid Build Coastguard Worker #if VDBG
6877*062a843bSAndroid Build Coastguard Worker         RLOGD("newSmsStatusReportInd");
6878*062a843bSAndroid Build Coastguard Worker #endif
6879*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6880*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), pdu);
6881*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6882*062a843bSAndroid Build Coastguard Worker         free(bytes);
6883*062a843bSAndroid Build Coastguard Worker     } else {
6884*062a843bSAndroid Build Coastguard Worker         RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6885*062a843bSAndroid Build Coastguard Worker     }
6886*062a843bSAndroid Build Coastguard Worker 
6887*062a843bSAndroid Build Coastguard Worker     return 0;
6888*062a843bSAndroid Build Coastguard Worker }
6889*062a843bSAndroid Build Coastguard Worker 
newSmsOnSimInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6890*062a843bSAndroid Build Coastguard Worker int radio::newSmsOnSimInd(int slotId, int indicationType,
6891*062a843bSAndroid Build Coastguard Worker                           int token, RIL_Errno e, void *response, size_t responseLen) {
6892*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6893*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
6894*062a843bSAndroid Build Coastguard Worker             RLOGE("newSmsOnSimInd: invalid response");
6895*062a843bSAndroid Build Coastguard Worker             return 0;
6896*062a843bSAndroid Build Coastguard Worker         }
6897*062a843bSAndroid Build Coastguard Worker         int32_t recordNumber = ((int32_t *) response)[0];
6898*062a843bSAndroid Build Coastguard Worker #if VDBG
6899*062a843bSAndroid Build Coastguard Worker         RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6900*062a843bSAndroid Build Coastguard Worker #endif
6901*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6902*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), recordNumber);
6903*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6904*062a843bSAndroid Build Coastguard Worker     } else {
6905*062a843bSAndroid Build Coastguard Worker         RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6906*062a843bSAndroid Build Coastguard Worker     }
6907*062a843bSAndroid Build Coastguard Worker 
6908*062a843bSAndroid Build Coastguard Worker     return 0;
6909*062a843bSAndroid Build Coastguard Worker }
6910*062a843bSAndroid Build Coastguard Worker 
onUssdInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6911*062a843bSAndroid Build Coastguard Worker int radio::onUssdInd(int slotId, int indicationType,
6912*062a843bSAndroid Build Coastguard Worker                      int token, RIL_Errno e, void *response, size_t responseLen) {
6913*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6914*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != 2 * sizeof(char *)) {
6915*062a843bSAndroid Build Coastguard Worker             RLOGE("onUssdInd: invalid response");
6916*062a843bSAndroid Build Coastguard Worker             return 0;
6917*062a843bSAndroid Build Coastguard Worker         }
6918*062a843bSAndroid Build Coastguard Worker         char **strings = (char **) response;
6919*062a843bSAndroid Build Coastguard Worker         char *mode = strings[0];
6920*062a843bSAndroid Build Coastguard Worker         hidl_string msg = convertCharPtrToHidlString(strings[1]);
6921*062a843bSAndroid Build Coastguard Worker         UssdModeType modeType = (UssdModeType) atoi(mode);
6922*062a843bSAndroid Build Coastguard Worker #if VDBG
6923*062a843bSAndroid Build Coastguard Worker         RLOGD("onUssdInd: mode %s", mode);
6924*062a843bSAndroid Build Coastguard Worker #endif
6925*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6926*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), modeType, msg);
6927*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6928*062a843bSAndroid Build Coastguard Worker     } else {
6929*062a843bSAndroid Build Coastguard Worker         RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6930*062a843bSAndroid Build Coastguard Worker     }
6931*062a843bSAndroid Build Coastguard Worker 
6932*062a843bSAndroid Build Coastguard Worker     return 0;
6933*062a843bSAndroid Build Coastguard Worker }
6934*062a843bSAndroid Build Coastguard Worker 
nitzTimeReceivedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)6935*062a843bSAndroid Build Coastguard Worker int radio::nitzTimeReceivedInd(int slotId,
6936*062a843bSAndroid Build Coastguard Worker                                int indicationType, int token, RIL_Errno e, void *response,
6937*062a843bSAndroid Build Coastguard Worker                                size_t responseLen) {
6938*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6939*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
6940*062a843bSAndroid Build Coastguard Worker             RLOGE("nitzTimeReceivedInd: invalid response");
6941*062a843bSAndroid Build Coastguard Worker             return 0;
6942*062a843bSAndroid Build Coastguard Worker         }
6943*062a843bSAndroid Build Coastguard Worker         hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6944*062a843bSAndroid Build Coastguard Worker #if VDBG
6945*062a843bSAndroid Build Coastguard Worker         RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6946*062a843bSAndroid Build Coastguard Worker                 nitzTimeReceived[slotId]);
6947*062a843bSAndroid Build Coastguard Worker #endif
6948*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6949*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), nitzTime,
6950*062a843bSAndroid Build Coastguard Worker                 nitzTimeReceived[slotId]);
6951*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
6952*062a843bSAndroid Build Coastguard Worker     } else {
6953*062a843bSAndroid Build Coastguard Worker         RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6954*062a843bSAndroid Build Coastguard Worker         return -1;
6955*062a843bSAndroid Build Coastguard Worker     }
6956*062a843bSAndroid Build Coastguard Worker 
6957*062a843bSAndroid Build Coastguard Worker     return 0;
6958*062a843bSAndroid Build Coastguard Worker }
6959*062a843bSAndroid Build Coastguard Worker 
convertRilSignalStrengthToHal(void * response,size_t responseLen,SignalStrength & signalStrength)6960*062a843bSAndroid Build Coastguard Worker void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6961*062a843bSAndroid Build Coastguard Worker         SignalStrength& signalStrength) {
6962*062a843bSAndroid Build Coastguard Worker     RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6963*062a843bSAndroid Build Coastguard Worker 
6964*062a843bSAndroid Build Coastguard Worker     // Fixup LTE for backwards compatibility
6965*062a843bSAndroid Build Coastguard Worker     // signalStrength: -1 -> 99
6966*062a843bSAndroid Build Coastguard Worker     if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6967*062a843bSAndroid Build Coastguard Worker         rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6968*062a843bSAndroid Build Coastguard Worker     }
6969*062a843bSAndroid Build Coastguard Worker     // rsrp: -1 -> INT_MAX all other negative value to positive.
6970*062a843bSAndroid Build Coastguard Worker     // So remap here
6971*062a843bSAndroid Build Coastguard Worker     if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6972*062a843bSAndroid Build Coastguard Worker         rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6973*062a843bSAndroid Build Coastguard Worker     } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6974*062a843bSAndroid Build Coastguard Worker         rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6975*062a843bSAndroid Build Coastguard Worker     }
6976*062a843bSAndroid Build Coastguard Worker     // rsrq: -1 -> INT_MAX
6977*062a843bSAndroid Build Coastguard Worker     if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6978*062a843bSAndroid Build Coastguard Worker         rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6979*062a843bSAndroid Build Coastguard Worker     }
6980*062a843bSAndroid Build Coastguard Worker     // Not remapping rssnr is already using INT_MAX
6981*062a843bSAndroid Build Coastguard Worker     // cqi: -1 -> INT_MAX
6982*062a843bSAndroid Build Coastguard Worker     if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6983*062a843bSAndroid Build Coastguard Worker         rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6984*062a843bSAndroid Build Coastguard Worker     }
6985*062a843bSAndroid Build Coastguard Worker 
6986*062a843bSAndroid Build Coastguard Worker     signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6987*062a843bSAndroid Build Coastguard Worker     signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6988*062a843bSAndroid Build Coastguard Worker     // RIL_SignalStrength_v10 not support gw.timingAdvance. Set to INT_MAX as
6989*062a843bSAndroid Build Coastguard Worker     // invalid value.
6990*062a843bSAndroid Build Coastguard Worker     signalStrength.gw.timingAdvance = INT_MAX;
6991*062a843bSAndroid Build Coastguard Worker 
6992*062a843bSAndroid Build Coastguard Worker     signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6993*062a843bSAndroid Build Coastguard Worker     signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6994*062a843bSAndroid Build Coastguard Worker     signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6995*062a843bSAndroid Build Coastguard Worker     signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6996*062a843bSAndroid Build Coastguard Worker     signalStrength.evdo.signalNoiseRatio =
6997*062a843bSAndroid Build Coastguard Worker             rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6998*062a843bSAndroid Build Coastguard Worker     signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6999*062a843bSAndroid Build Coastguard Worker     signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
7000*062a843bSAndroid Build Coastguard Worker     signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
7001*062a843bSAndroid Build Coastguard Worker     signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
7002*062a843bSAndroid Build Coastguard Worker     signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
7003*062a843bSAndroid Build Coastguard Worker     signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
7004*062a843bSAndroid Build Coastguard Worker     signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
7005*062a843bSAndroid Build Coastguard Worker }
7006*062a843bSAndroid Build Coastguard Worker 
currentSignalStrengthInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7007*062a843bSAndroid Build Coastguard Worker int radio::currentSignalStrengthInd(int slotId,
7008*062a843bSAndroid Build Coastguard Worker                                     int indicationType, int token, RIL_Errno e,
7009*062a843bSAndroid Build Coastguard Worker                                     void *response, size_t responseLen) {
7010*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7011*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
7012*062a843bSAndroid Build Coastguard Worker             RLOGE("currentSignalStrengthInd: invalid response");
7013*062a843bSAndroid Build Coastguard Worker             return 0;
7014*062a843bSAndroid Build Coastguard Worker         }
7015*062a843bSAndroid Build Coastguard Worker 
7016*062a843bSAndroid Build Coastguard Worker         SignalStrength signalStrength = {};
7017*062a843bSAndroid Build Coastguard Worker         convertRilSignalStrengthToHal(response, responseLen, signalStrength);
7018*062a843bSAndroid Build Coastguard Worker 
7019*062a843bSAndroid Build Coastguard Worker #if VDBG
7020*062a843bSAndroid Build Coastguard Worker         RLOGD("currentSignalStrengthInd");
7021*062a843bSAndroid Build Coastguard Worker #endif
7022*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
7023*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), signalStrength);
7024*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7025*062a843bSAndroid Build Coastguard Worker     } else {
7026*062a843bSAndroid Build Coastguard Worker         RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
7027*062a843bSAndroid Build Coastguard Worker                 slotId);
7028*062a843bSAndroid Build Coastguard Worker     }
7029*062a843bSAndroid Build Coastguard Worker 
7030*062a843bSAndroid Build Coastguard Worker     return 0;
7031*062a843bSAndroid Build Coastguard Worker }
7032*062a843bSAndroid Build Coastguard Worker 
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,SetupDataCallResult & dcResult)7033*062a843bSAndroid Build Coastguard Worker void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
7034*062a843bSAndroid Build Coastguard Worker         SetupDataCallResult& dcResult) {
7035*062a843bSAndroid Build Coastguard Worker     dcResult.status = (DataCallFailCause) dcResponse->status;
7036*062a843bSAndroid Build Coastguard Worker     dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7037*062a843bSAndroid Build Coastguard Worker     dcResult.cid = dcResponse->cid;
7038*062a843bSAndroid Build Coastguard Worker     dcResult.active = dcResponse->active;
7039*062a843bSAndroid Build Coastguard Worker     dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7040*062a843bSAndroid Build Coastguard Worker     dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7041*062a843bSAndroid Build Coastguard Worker     dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7042*062a843bSAndroid Build Coastguard Worker     dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
7043*062a843bSAndroid Build Coastguard Worker     dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
7044*062a843bSAndroid Build Coastguard Worker     dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
7045*062a843bSAndroid Build Coastguard Worker     dcResult.mtu = dcResponse->mtu;
7046*062a843bSAndroid Build Coastguard Worker }
7047*062a843bSAndroid Build Coastguard Worker 
convertRilDataCallListToHal(void * response,size_t responseLen,hidl_vec<SetupDataCallResult> & dcResultList)7048*062a843bSAndroid Build Coastguard Worker void convertRilDataCallListToHal(void *response, size_t responseLen,
7049*062a843bSAndroid Build Coastguard Worker         hidl_vec<SetupDataCallResult>& dcResultList) {
7050*062a843bSAndroid Build Coastguard Worker     int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
7051*062a843bSAndroid Build Coastguard Worker 
7052*062a843bSAndroid Build Coastguard Worker     RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
7053*062a843bSAndroid Build Coastguard Worker     dcResultList.resize(num);
7054*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < num; i++) {
7055*062a843bSAndroid Build Coastguard Worker         convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
7056*062a843bSAndroid Build Coastguard Worker     }
7057*062a843bSAndroid Build Coastguard Worker }
7058*062a843bSAndroid Build Coastguard Worker 
dataCallListChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7059*062a843bSAndroid Build Coastguard Worker int radio::dataCallListChangedInd(int slotId,
7060*062a843bSAndroid Build Coastguard Worker                                   int indicationType, int token, RIL_Errno e, void *response,
7061*062a843bSAndroid Build Coastguard Worker                                   size_t responseLen) {
7062*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7063*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
7064*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7065*062a843bSAndroid Build Coastguard Worker             RLOGE("dataCallListChangedInd: invalid response");
7066*062a843bSAndroid Build Coastguard Worker             return 0;
7067*062a843bSAndroid Build Coastguard Worker         }
7068*062a843bSAndroid Build Coastguard Worker         hidl_vec<SetupDataCallResult> dcList;
7069*062a843bSAndroid Build Coastguard Worker         convertRilDataCallListToHal(response, responseLen, dcList);
7070*062a843bSAndroid Build Coastguard Worker #if VDBG
7071*062a843bSAndroid Build Coastguard Worker         RLOGD("dataCallListChangedInd");
7072*062a843bSAndroid Build Coastguard Worker #endif
7073*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7074*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), dcList);
7075*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7076*062a843bSAndroid Build Coastguard Worker     } else {
7077*062a843bSAndroid Build Coastguard Worker         RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7078*062a843bSAndroid Build Coastguard Worker     }
7079*062a843bSAndroid Build Coastguard Worker 
7080*062a843bSAndroid Build Coastguard Worker     return 0;
7081*062a843bSAndroid Build Coastguard Worker }
7082*062a843bSAndroid Build Coastguard Worker 
suppSvcNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7083*062a843bSAndroid Build Coastguard Worker int radio::suppSvcNotifyInd(int slotId, int indicationType,
7084*062a843bSAndroid Build Coastguard Worker                             int token, RIL_Errno e, void *response, size_t responseLen) {
7085*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7086*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7087*062a843bSAndroid Build Coastguard Worker             RLOGE("suppSvcNotifyInd: invalid response");
7088*062a843bSAndroid Build Coastguard Worker             return 0;
7089*062a843bSAndroid Build Coastguard Worker         }
7090*062a843bSAndroid Build Coastguard Worker 
7091*062a843bSAndroid Build Coastguard Worker         SuppSvcNotification suppSvc = {};
7092*062a843bSAndroid Build Coastguard Worker         RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7093*062a843bSAndroid Build Coastguard Worker         suppSvc.isMT = ssn->notificationType;
7094*062a843bSAndroid Build Coastguard Worker         suppSvc.code = ssn->code;
7095*062a843bSAndroid Build Coastguard Worker         suppSvc.index = ssn->index;
7096*062a843bSAndroid Build Coastguard Worker         suppSvc.type = ssn->type;
7097*062a843bSAndroid Build Coastguard Worker         suppSvc.number = convertCharPtrToHidlString(ssn->number);
7098*062a843bSAndroid Build Coastguard Worker 
7099*062a843bSAndroid Build Coastguard Worker #if VDBG
7100*062a843bSAndroid Build Coastguard Worker         RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7101*062a843bSAndroid Build Coastguard Worker                 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7102*062a843bSAndroid Build Coastguard Worker #endif
7103*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7104*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), suppSvc);
7105*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7106*062a843bSAndroid Build Coastguard Worker     } else {
7107*062a843bSAndroid Build Coastguard Worker         RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7108*062a843bSAndroid Build Coastguard Worker     }
7109*062a843bSAndroid Build Coastguard Worker 
7110*062a843bSAndroid Build Coastguard Worker     return 0;
7111*062a843bSAndroid Build Coastguard Worker }
7112*062a843bSAndroid Build Coastguard Worker 
stkSessionEndInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7113*062a843bSAndroid Build Coastguard Worker int radio::stkSessionEndInd(int slotId, int indicationType,
7114*062a843bSAndroid Build Coastguard Worker                             int token, RIL_Errno e, void *response, size_t responseLen) {
7115*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7116*062a843bSAndroid Build Coastguard Worker #if VDBG
7117*062a843bSAndroid Build Coastguard Worker         RLOGD("stkSessionEndInd");
7118*062a843bSAndroid Build Coastguard Worker #endif
7119*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7120*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7121*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7122*062a843bSAndroid Build Coastguard Worker     } else {
7123*062a843bSAndroid Build Coastguard Worker         RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7124*062a843bSAndroid Build Coastguard Worker     }
7125*062a843bSAndroid Build Coastguard Worker 
7126*062a843bSAndroid Build Coastguard Worker     return 0;
7127*062a843bSAndroid Build Coastguard Worker }
7128*062a843bSAndroid Build Coastguard Worker 
stkProactiveCommandInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7129*062a843bSAndroid Build Coastguard Worker int radio::stkProactiveCommandInd(int slotId,
7130*062a843bSAndroid Build Coastguard Worker                                   int indicationType, int token, RIL_Errno e, void *response,
7131*062a843bSAndroid Build Coastguard Worker                                   size_t responseLen) {
7132*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7133*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
7134*062a843bSAndroid Build Coastguard Worker             RLOGE("stkProactiveCommandInd: invalid response");
7135*062a843bSAndroid Build Coastguard Worker             return 0;
7136*062a843bSAndroid Build Coastguard Worker         }
7137*062a843bSAndroid Build Coastguard Worker #if VDBG
7138*062a843bSAndroid Build Coastguard Worker         RLOGD("stkProactiveCommandInd");
7139*062a843bSAndroid Build Coastguard Worker #endif
7140*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7141*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType),
7142*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
7143*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7144*062a843bSAndroid Build Coastguard Worker     } else {
7145*062a843bSAndroid Build Coastguard Worker         RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7146*062a843bSAndroid Build Coastguard Worker     }
7147*062a843bSAndroid Build Coastguard Worker 
7148*062a843bSAndroid Build Coastguard Worker     return 0;
7149*062a843bSAndroid Build Coastguard Worker }
7150*062a843bSAndroid Build Coastguard Worker 
stkEventNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7151*062a843bSAndroid Build Coastguard Worker int radio::stkEventNotifyInd(int slotId, int indicationType,
7152*062a843bSAndroid Build Coastguard Worker                              int token, RIL_Errno e, void *response, size_t responseLen) {
7153*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7154*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
7155*062a843bSAndroid Build Coastguard Worker             RLOGE("stkEventNotifyInd: invalid response");
7156*062a843bSAndroid Build Coastguard Worker             return 0;
7157*062a843bSAndroid Build Coastguard Worker         }
7158*062a843bSAndroid Build Coastguard Worker #if VDBG
7159*062a843bSAndroid Build Coastguard Worker         RLOGD("stkEventNotifyInd");
7160*062a843bSAndroid Build Coastguard Worker #endif
7161*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7162*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType),
7163*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
7164*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7165*062a843bSAndroid Build Coastguard Worker     } else {
7166*062a843bSAndroid Build Coastguard Worker         RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7167*062a843bSAndroid Build Coastguard Worker     }
7168*062a843bSAndroid Build Coastguard Worker 
7169*062a843bSAndroid Build Coastguard Worker     return 0;
7170*062a843bSAndroid Build Coastguard Worker }
7171*062a843bSAndroid Build Coastguard Worker 
stkCallSetupInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7172*062a843bSAndroid Build Coastguard Worker int radio::stkCallSetupInd(int slotId, int indicationType,
7173*062a843bSAndroid Build Coastguard Worker                            int token, RIL_Errno e, void *response, size_t responseLen) {
7174*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7175*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7176*062a843bSAndroid Build Coastguard Worker             RLOGE("stkCallSetupInd: invalid response");
7177*062a843bSAndroid Build Coastguard Worker             return 0;
7178*062a843bSAndroid Build Coastguard Worker         }
7179*062a843bSAndroid Build Coastguard Worker         int32_t timeout = ((int32_t *) response)[0];
7180*062a843bSAndroid Build Coastguard Worker #if VDBG
7181*062a843bSAndroid Build Coastguard Worker         RLOGD("stkCallSetupInd: timeout %d", timeout);
7182*062a843bSAndroid Build Coastguard Worker #endif
7183*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7184*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), timeout);
7185*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7186*062a843bSAndroid Build Coastguard Worker     } else {
7187*062a843bSAndroid Build Coastguard Worker         RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7188*062a843bSAndroid Build Coastguard Worker     }
7189*062a843bSAndroid Build Coastguard Worker 
7190*062a843bSAndroid Build Coastguard Worker     return 0;
7191*062a843bSAndroid Build Coastguard Worker }
7192*062a843bSAndroid Build Coastguard Worker 
simSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7193*062a843bSAndroid Build Coastguard Worker int radio::simSmsStorageFullInd(int slotId,
7194*062a843bSAndroid Build Coastguard Worker                                 int indicationType, int token, RIL_Errno e, void *response,
7195*062a843bSAndroid Build Coastguard Worker                                 size_t responseLen) {
7196*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7197*062a843bSAndroid Build Coastguard Worker #if VDBG
7198*062a843bSAndroid Build Coastguard Worker         RLOGD("simSmsStorageFullInd");
7199*062a843bSAndroid Build Coastguard Worker #endif
7200*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7201*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7202*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7203*062a843bSAndroid Build Coastguard Worker     } else {
7204*062a843bSAndroid Build Coastguard Worker         RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7205*062a843bSAndroid Build Coastguard Worker     }
7206*062a843bSAndroid Build Coastguard Worker 
7207*062a843bSAndroid Build Coastguard Worker     return 0;
7208*062a843bSAndroid Build Coastguard Worker }
7209*062a843bSAndroid Build Coastguard Worker 
simRefreshInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7210*062a843bSAndroid Build Coastguard Worker int radio::simRefreshInd(int slotId, int indicationType,
7211*062a843bSAndroid Build Coastguard Worker                          int token, RIL_Errno e, void *response, size_t responseLen) {
7212*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7213*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7214*062a843bSAndroid Build Coastguard Worker             RLOGE("simRefreshInd: invalid response");
7215*062a843bSAndroid Build Coastguard Worker             return 0;
7216*062a843bSAndroid Build Coastguard Worker         }
7217*062a843bSAndroid Build Coastguard Worker 
7218*062a843bSAndroid Build Coastguard Worker         SimRefreshResult refreshResult = {};
7219*062a843bSAndroid Build Coastguard Worker         RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7220*062a843bSAndroid Build Coastguard Worker         refreshResult.type =
7221*062a843bSAndroid Build Coastguard Worker                 (V1_0::SimRefreshType) simRefreshResponse->result;
7222*062a843bSAndroid Build Coastguard Worker         refreshResult.efId = simRefreshResponse->ef_id;
7223*062a843bSAndroid Build Coastguard Worker         refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7224*062a843bSAndroid Build Coastguard Worker 
7225*062a843bSAndroid Build Coastguard Worker #if VDBG
7226*062a843bSAndroid Build Coastguard Worker         RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7227*062a843bSAndroid Build Coastguard Worker #endif
7228*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7229*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), refreshResult);
7230*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7231*062a843bSAndroid Build Coastguard Worker     } else {
7232*062a843bSAndroid Build Coastguard Worker         RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7233*062a843bSAndroid Build Coastguard Worker     }
7234*062a843bSAndroid Build Coastguard Worker 
7235*062a843bSAndroid Build Coastguard Worker     return 0;
7236*062a843bSAndroid Build Coastguard Worker }
7237*062a843bSAndroid Build Coastguard Worker 
convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord * signalInfoRecord,CdmaSignalInfoRecord & record)7238*062a843bSAndroid Build Coastguard Worker void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7239*062a843bSAndroid Build Coastguard Worker         CdmaSignalInfoRecord& record) {
7240*062a843bSAndroid Build Coastguard Worker     record.isPresent = signalInfoRecord->isPresent;
7241*062a843bSAndroid Build Coastguard Worker     record.signalType = signalInfoRecord->signalType;
7242*062a843bSAndroid Build Coastguard Worker     record.alertPitch = signalInfoRecord->alertPitch;
7243*062a843bSAndroid Build Coastguard Worker     record.signal = signalInfoRecord->signal;
7244*062a843bSAndroid Build Coastguard Worker }
7245*062a843bSAndroid Build Coastguard Worker 
callRingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7246*062a843bSAndroid Build Coastguard Worker int radio::callRingInd(int slotId, int indicationType,
7247*062a843bSAndroid Build Coastguard Worker                        int token, RIL_Errno e, void *response, size_t responseLen) {
7248*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7249*062a843bSAndroid Build Coastguard Worker         bool isGsm;
7250*062a843bSAndroid Build Coastguard Worker         CdmaSignalInfoRecord record = {};
7251*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
7252*062a843bSAndroid Build Coastguard Worker             isGsm = true;
7253*062a843bSAndroid Build Coastguard Worker         } else {
7254*062a843bSAndroid Build Coastguard Worker             isGsm = false;
7255*062a843bSAndroid Build Coastguard Worker             if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7256*062a843bSAndroid Build Coastguard Worker                 RLOGE("callRingInd: invalid response");
7257*062a843bSAndroid Build Coastguard Worker                 return 0;
7258*062a843bSAndroid Build Coastguard Worker             }
7259*062a843bSAndroid Build Coastguard Worker             convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7260*062a843bSAndroid Build Coastguard Worker         }
7261*062a843bSAndroid Build Coastguard Worker 
7262*062a843bSAndroid Build Coastguard Worker #if VDBG
7263*062a843bSAndroid Build Coastguard Worker         RLOGD("callRingInd: isGsm %d", isGsm);
7264*062a843bSAndroid Build Coastguard Worker #endif
7265*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7266*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), isGsm, record);
7267*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7268*062a843bSAndroid Build Coastguard Worker     } else {
7269*062a843bSAndroid Build Coastguard Worker         RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7270*062a843bSAndroid Build Coastguard Worker     }
7271*062a843bSAndroid Build Coastguard Worker 
7272*062a843bSAndroid Build Coastguard Worker     return 0;
7273*062a843bSAndroid Build Coastguard Worker }
7274*062a843bSAndroid Build Coastguard Worker 
simStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7275*062a843bSAndroid Build Coastguard Worker int radio::simStatusChangedInd(int slotId,
7276*062a843bSAndroid Build Coastguard Worker                                int indicationType, int token, RIL_Errno e, void *response,
7277*062a843bSAndroid Build Coastguard Worker                                size_t responseLen) {
7278*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7279*062a843bSAndroid Build Coastguard Worker #if VDBG
7280*062a843bSAndroid Build Coastguard Worker         RLOGD("simStatusChangedInd");
7281*062a843bSAndroid Build Coastguard Worker #endif
7282*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7283*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7284*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7285*062a843bSAndroid Build Coastguard Worker     } else {
7286*062a843bSAndroid Build Coastguard Worker         RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7287*062a843bSAndroid Build Coastguard Worker     }
7288*062a843bSAndroid Build Coastguard Worker 
7289*062a843bSAndroid Build Coastguard Worker     return 0;
7290*062a843bSAndroid Build Coastguard Worker }
7291*062a843bSAndroid Build Coastguard Worker 
cdmaNewSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7292*062a843bSAndroid Build Coastguard Worker int radio::cdmaNewSmsInd(int slotId, int indicationType,
7293*062a843bSAndroid Build Coastguard Worker                          int token, RIL_Errno e, void *response, size_t responseLen) {
7294*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7295*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7296*062a843bSAndroid Build Coastguard Worker             RLOGE("cdmaNewSmsInd: invalid response");
7297*062a843bSAndroid Build Coastguard Worker             return 0;
7298*062a843bSAndroid Build Coastguard Worker         }
7299*062a843bSAndroid Build Coastguard Worker 
7300*062a843bSAndroid Build Coastguard Worker         CdmaSmsMessage msg = {};
7301*062a843bSAndroid Build Coastguard Worker         RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7302*062a843bSAndroid Build Coastguard Worker         msg.teleserviceId = rilMsg->uTeleserviceID;
7303*062a843bSAndroid Build Coastguard Worker         msg.isServicePresent = rilMsg->bIsServicePresent;
7304*062a843bSAndroid Build Coastguard Worker         msg.serviceCategory = rilMsg->uServicecategory;
7305*062a843bSAndroid Build Coastguard Worker         msg.address.digitMode =
7306*062a843bSAndroid Build Coastguard Worker                 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7307*062a843bSAndroid Build Coastguard Worker         msg.address.numberMode =
7308*062a843bSAndroid Build Coastguard Worker                 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7309*062a843bSAndroid Build Coastguard Worker         msg.address.numberType =
7310*062a843bSAndroid Build Coastguard Worker                 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7311*062a843bSAndroid Build Coastguard Worker         msg.address.numberPlan =
7312*062a843bSAndroid Build Coastguard Worker                 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7313*062a843bSAndroid Build Coastguard Worker 
7314*062a843bSAndroid Build Coastguard Worker         int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7315*062a843bSAndroid Build Coastguard Worker         msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7316*062a843bSAndroid Build Coastguard Worker 
7317*062a843bSAndroid Build Coastguard Worker         msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
7318*062a843bSAndroid Build Coastguard Worker                 rilMsg->sSubAddress.subaddressType;
7319*062a843bSAndroid Build Coastguard Worker         msg.subAddress.odd = rilMsg->sSubAddress.odd;
7320*062a843bSAndroid Build Coastguard Worker 
7321*062a843bSAndroid Build Coastguard Worker         digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7322*062a843bSAndroid Build Coastguard Worker         msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7323*062a843bSAndroid Build Coastguard Worker 
7324*062a843bSAndroid Build Coastguard Worker         digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7325*062a843bSAndroid Build Coastguard Worker         msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7326*062a843bSAndroid Build Coastguard Worker 
7327*062a843bSAndroid Build Coastguard Worker #if VDBG
7328*062a843bSAndroid Build Coastguard Worker         RLOGD("cdmaNewSmsInd");
7329*062a843bSAndroid Build Coastguard Worker #endif
7330*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7331*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), msg);
7332*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7333*062a843bSAndroid Build Coastguard Worker     } else {
7334*062a843bSAndroid Build Coastguard Worker         RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7335*062a843bSAndroid Build Coastguard Worker     }
7336*062a843bSAndroid Build Coastguard Worker 
7337*062a843bSAndroid Build Coastguard Worker     return 0;
7338*062a843bSAndroid Build Coastguard Worker }
7339*062a843bSAndroid Build Coastguard Worker 
newBroadcastSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7340*062a843bSAndroid Build Coastguard Worker int radio::newBroadcastSmsInd(int slotId,
7341*062a843bSAndroid Build Coastguard Worker                               int indicationType, int token, RIL_Errno e, void *response,
7342*062a843bSAndroid Build Coastguard Worker                               size_t responseLen) {
7343*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7344*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
7345*062a843bSAndroid Build Coastguard Worker             RLOGE("newBroadcastSmsInd: invalid response");
7346*062a843bSAndroid Build Coastguard Worker             return 0;
7347*062a843bSAndroid Build Coastguard Worker         }
7348*062a843bSAndroid Build Coastguard Worker 
7349*062a843bSAndroid Build Coastguard Worker         hidl_vec<uint8_t> data;
7350*062a843bSAndroid Build Coastguard Worker         data.setToExternal((uint8_t *) response, responseLen);
7351*062a843bSAndroid Build Coastguard Worker #if VDBG
7352*062a843bSAndroid Build Coastguard Worker         RLOGD("newBroadcastSmsInd");
7353*062a843bSAndroid Build Coastguard Worker #endif
7354*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7355*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), data);
7356*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7357*062a843bSAndroid Build Coastguard Worker     } else {
7358*062a843bSAndroid Build Coastguard Worker         RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7359*062a843bSAndroid Build Coastguard Worker     }
7360*062a843bSAndroid Build Coastguard Worker 
7361*062a843bSAndroid Build Coastguard Worker     return 0;
7362*062a843bSAndroid Build Coastguard Worker }
7363*062a843bSAndroid Build Coastguard Worker 
cdmaRuimSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7364*062a843bSAndroid Build Coastguard Worker int radio::cdmaRuimSmsStorageFullInd(int slotId,
7365*062a843bSAndroid Build Coastguard Worker                                      int indicationType, int token, RIL_Errno e, void *response,
7366*062a843bSAndroid Build Coastguard Worker                                      size_t responseLen) {
7367*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7368*062a843bSAndroid Build Coastguard Worker #if VDBG
7369*062a843bSAndroid Build Coastguard Worker         RLOGD("cdmaRuimSmsStorageFullInd");
7370*062a843bSAndroid Build Coastguard Worker #endif
7371*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7372*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7373*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7374*062a843bSAndroid Build Coastguard Worker     } else {
7375*062a843bSAndroid Build Coastguard Worker         RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7376*062a843bSAndroid Build Coastguard Worker                 slotId);
7377*062a843bSAndroid Build Coastguard Worker     }
7378*062a843bSAndroid Build Coastguard Worker 
7379*062a843bSAndroid Build Coastguard Worker     return 0;
7380*062a843bSAndroid Build Coastguard Worker }
7381*062a843bSAndroid Build Coastguard Worker 
restrictedStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7382*062a843bSAndroid Build Coastguard Worker int radio::restrictedStateChangedInd(int slotId,
7383*062a843bSAndroid Build Coastguard Worker                                      int indicationType, int token, RIL_Errno e, void *response,
7384*062a843bSAndroid Build Coastguard Worker                                      size_t responseLen) {
7385*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7386*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7387*062a843bSAndroid Build Coastguard Worker             RLOGE("restrictedStateChangedInd: invalid response");
7388*062a843bSAndroid Build Coastguard Worker             return 0;
7389*062a843bSAndroid Build Coastguard Worker         }
7390*062a843bSAndroid Build Coastguard Worker         int32_t state = ((int32_t *) response)[0];
7391*062a843bSAndroid Build Coastguard Worker #if VDBG
7392*062a843bSAndroid Build Coastguard Worker         RLOGD("restrictedStateChangedInd: state %d", state);
7393*062a843bSAndroid Build Coastguard Worker #endif
7394*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7395*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7396*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7397*062a843bSAndroid Build Coastguard Worker     } else {
7398*062a843bSAndroid Build Coastguard Worker         RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7399*062a843bSAndroid Build Coastguard Worker                 slotId);
7400*062a843bSAndroid Build Coastguard Worker     }
7401*062a843bSAndroid Build Coastguard Worker 
7402*062a843bSAndroid Build Coastguard Worker     return 0;
7403*062a843bSAndroid Build Coastguard Worker }
7404*062a843bSAndroid Build Coastguard Worker 
enterEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7405*062a843bSAndroid Build Coastguard Worker int radio::enterEmergencyCallbackModeInd(int slotId,
7406*062a843bSAndroid Build Coastguard Worker                                          int indicationType, int token, RIL_Errno e, void *response,
7407*062a843bSAndroid Build Coastguard Worker                                          size_t responseLen) {
7408*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7409*062a843bSAndroid Build Coastguard Worker #if VDBG
7410*062a843bSAndroid Build Coastguard Worker         RLOGD("enterEmergencyCallbackModeInd");
7411*062a843bSAndroid Build Coastguard Worker #endif
7412*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7413*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7414*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7415*062a843bSAndroid Build Coastguard Worker     } else {
7416*062a843bSAndroid Build Coastguard Worker         RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7417*062a843bSAndroid Build Coastguard Worker                 slotId);
7418*062a843bSAndroid Build Coastguard Worker     }
7419*062a843bSAndroid Build Coastguard Worker 
7420*062a843bSAndroid Build Coastguard Worker     return 0;
7421*062a843bSAndroid Build Coastguard Worker }
7422*062a843bSAndroid Build Coastguard Worker 
cdmaCallWaitingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7423*062a843bSAndroid Build Coastguard Worker int radio::cdmaCallWaitingInd(int slotId,
7424*062a843bSAndroid Build Coastguard Worker                               int indicationType, int token, RIL_Errno e, void *response,
7425*062a843bSAndroid Build Coastguard Worker                               size_t responseLen) {
7426*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7427*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7428*062a843bSAndroid Build Coastguard Worker             RLOGE("cdmaCallWaitingInd: invalid response");
7429*062a843bSAndroid Build Coastguard Worker             return 0;
7430*062a843bSAndroid Build Coastguard Worker         }
7431*062a843bSAndroid Build Coastguard Worker 
7432*062a843bSAndroid Build Coastguard Worker         CdmaCallWaiting callWaitingRecord = {};
7433*062a843bSAndroid Build Coastguard Worker         RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7434*062a843bSAndroid Build Coastguard Worker         callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7435*062a843bSAndroid Build Coastguard Worker         callWaitingRecord.numberPresentation =
7436*062a843bSAndroid Build Coastguard Worker                 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7437*062a843bSAndroid Build Coastguard Worker         callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7438*062a843bSAndroid Build Coastguard Worker         convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7439*062a843bSAndroid Build Coastguard Worker                 callWaitingRecord.signalInfoRecord);
7440*062a843bSAndroid Build Coastguard Worker         callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7441*062a843bSAndroid Build Coastguard Worker         callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7442*062a843bSAndroid Build Coastguard Worker 
7443*062a843bSAndroid Build Coastguard Worker #if VDBG
7444*062a843bSAndroid Build Coastguard Worker         RLOGD("cdmaCallWaitingInd");
7445*062a843bSAndroid Build Coastguard Worker #endif
7446*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7447*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7448*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7449*062a843bSAndroid Build Coastguard Worker     } else {
7450*062a843bSAndroid Build Coastguard Worker         RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7451*062a843bSAndroid Build Coastguard Worker     }
7452*062a843bSAndroid Build Coastguard Worker 
7453*062a843bSAndroid Build Coastguard Worker     return 0;
7454*062a843bSAndroid Build Coastguard Worker }
7455*062a843bSAndroid Build Coastguard Worker 
cdmaOtaProvisionStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7456*062a843bSAndroid Build Coastguard Worker int radio::cdmaOtaProvisionStatusInd(int slotId,
7457*062a843bSAndroid Build Coastguard Worker                                      int indicationType, int token, RIL_Errno e, void *response,
7458*062a843bSAndroid Build Coastguard Worker                                      size_t responseLen) {
7459*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7460*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7461*062a843bSAndroid Build Coastguard Worker             RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7462*062a843bSAndroid Build Coastguard Worker             return 0;
7463*062a843bSAndroid Build Coastguard Worker         }
7464*062a843bSAndroid Build Coastguard Worker         int32_t status = ((int32_t *) response)[0];
7465*062a843bSAndroid Build Coastguard Worker #if VDBG
7466*062a843bSAndroid Build Coastguard Worker         RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7467*062a843bSAndroid Build Coastguard Worker #endif
7468*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7469*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7470*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7471*062a843bSAndroid Build Coastguard Worker     } else {
7472*062a843bSAndroid Build Coastguard Worker         RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7473*062a843bSAndroid Build Coastguard Worker                 slotId);
7474*062a843bSAndroid Build Coastguard Worker     }
7475*062a843bSAndroid Build Coastguard Worker 
7476*062a843bSAndroid Build Coastguard Worker     return 0;
7477*062a843bSAndroid Build Coastguard Worker }
7478*062a843bSAndroid Build Coastguard Worker 
cdmaInfoRecInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7479*062a843bSAndroid Build Coastguard Worker int radio::cdmaInfoRecInd(int slotId,
7480*062a843bSAndroid Build Coastguard Worker                           int indicationType, int token, RIL_Errno e, void *response,
7481*062a843bSAndroid Build Coastguard Worker                           size_t responseLen) {
7482*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7483*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7484*062a843bSAndroid Build Coastguard Worker             RLOGE("cdmaInfoRecInd: invalid response");
7485*062a843bSAndroid Build Coastguard Worker             return 0;
7486*062a843bSAndroid Build Coastguard Worker         }
7487*062a843bSAndroid Build Coastguard Worker 
7488*062a843bSAndroid Build Coastguard Worker         CdmaInformationRecords records = {};
7489*062a843bSAndroid Build Coastguard Worker         RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7490*062a843bSAndroid Build Coastguard Worker 
7491*062a843bSAndroid Build Coastguard Worker         char* string8 = NULL;
7492*062a843bSAndroid Build Coastguard Worker         int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7493*062a843bSAndroid Build Coastguard Worker         if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7494*062a843bSAndroid Build Coastguard Worker             RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7495*062a843bSAndroid Build Coastguard Worker                     "additional ones", recordsRil->numberOfInfoRecs,
7496*062a843bSAndroid Build Coastguard Worker                     RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7497*062a843bSAndroid Build Coastguard Worker         }
7498*062a843bSAndroid Build Coastguard Worker         records.infoRec.resize(num);
7499*062a843bSAndroid Build Coastguard Worker         for (int i = 0 ; i < num ; i++) {
7500*062a843bSAndroid Build Coastguard Worker             CdmaInformationRecord *record = &records.infoRec[i];
7501*062a843bSAndroid Build Coastguard Worker             RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7502*062a843bSAndroid Build Coastguard Worker             record->name = (CdmaInfoRecName) infoRec->name;
7503*062a843bSAndroid Build Coastguard Worker             // All vectors should be size 0 except one which will be size 1. Set everything to
7504*062a843bSAndroid Build Coastguard Worker             // size 0 initially.
7505*062a843bSAndroid Build Coastguard Worker             record->display.resize(0);
7506*062a843bSAndroid Build Coastguard Worker             record->number.resize(0);
7507*062a843bSAndroid Build Coastguard Worker             record->signal.resize(0);
7508*062a843bSAndroid Build Coastguard Worker             record->redir.resize(0);
7509*062a843bSAndroid Build Coastguard Worker             record->lineCtrl.resize(0);
7510*062a843bSAndroid Build Coastguard Worker             record->clir.resize(0);
7511*062a843bSAndroid Build Coastguard Worker             record->audioCtrl.resize(0);
7512*062a843bSAndroid Build Coastguard Worker             switch (infoRec->name) {
7513*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_DISPLAY_INFO_REC:
7514*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7515*062a843bSAndroid Build Coastguard Worker                     if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7516*062a843bSAndroid Build Coastguard Worker                         RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7517*062a843bSAndroid Build Coastguard Worker                                 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7518*062a843bSAndroid Build Coastguard Worker                                 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7519*062a843bSAndroid Build Coastguard Worker                         return 0;
7520*062a843bSAndroid Build Coastguard Worker                     }
7521*062a843bSAndroid Build Coastguard Worker                     string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7522*062a843bSAndroid Build Coastguard Worker                     if (string8 == NULL) {
7523*062a843bSAndroid Build Coastguard Worker                         RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7524*062a843bSAndroid Build Coastguard Worker                                 "responseCdmaInformationRecords");
7525*062a843bSAndroid Build Coastguard Worker                         return 0;
7526*062a843bSAndroid Build Coastguard Worker                     }
7527*062a843bSAndroid Build Coastguard Worker                     memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7528*062a843bSAndroid Build Coastguard Worker                     string8[(int)infoRec->rec.display.alpha_len] = '\0';
7529*062a843bSAndroid Build Coastguard Worker 
7530*062a843bSAndroid Build Coastguard Worker                     record->display.resize(1);
7531*062a843bSAndroid Build Coastguard Worker                     record->display[0].alphaBuf = string8;
7532*062a843bSAndroid Build Coastguard Worker                     free(string8);
7533*062a843bSAndroid Build Coastguard Worker                     string8 = NULL;
7534*062a843bSAndroid Build Coastguard Worker                     break;
7535*062a843bSAndroid Build Coastguard Worker                 }
7536*062a843bSAndroid Build Coastguard Worker 
7537*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7538*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7539*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7540*062a843bSAndroid Build Coastguard Worker                     if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7541*062a843bSAndroid Build Coastguard Worker                         RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7542*062a843bSAndroid Build Coastguard Worker                                 "expected not more than %d", (int) infoRec->rec.number.len,
7543*062a843bSAndroid Build Coastguard Worker                                 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7544*062a843bSAndroid Build Coastguard Worker                         return 0;
7545*062a843bSAndroid Build Coastguard Worker                     }
7546*062a843bSAndroid Build Coastguard Worker                     string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7547*062a843bSAndroid Build Coastguard Worker                     if (string8 == NULL) {
7548*062a843bSAndroid Build Coastguard Worker                         RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7549*062a843bSAndroid Build Coastguard Worker                                 "responseCdmaInformationRecords");
7550*062a843bSAndroid Build Coastguard Worker                         return 0;
7551*062a843bSAndroid Build Coastguard Worker                     }
7552*062a843bSAndroid Build Coastguard Worker                     memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7553*062a843bSAndroid Build Coastguard Worker                     string8[(int)infoRec->rec.number.len] = '\0';
7554*062a843bSAndroid Build Coastguard Worker 
7555*062a843bSAndroid Build Coastguard Worker                     record->number.resize(1);
7556*062a843bSAndroid Build Coastguard Worker                     record->number[0].number = string8;
7557*062a843bSAndroid Build Coastguard Worker                     free(string8);
7558*062a843bSAndroid Build Coastguard Worker                     string8 = NULL;
7559*062a843bSAndroid Build Coastguard Worker                     record->number[0].numberType = infoRec->rec.number.number_type;
7560*062a843bSAndroid Build Coastguard Worker                     record->number[0].numberPlan = infoRec->rec.number.number_plan;
7561*062a843bSAndroid Build Coastguard Worker                     record->number[0].pi = infoRec->rec.number.pi;
7562*062a843bSAndroid Build Coastguard Worker                     record->number[0].si = infoRec->rec.number.si;
7563*062a843bSAndroid Build Coastguard Worker                     break;
7564*062a843bSAndroid Build Coastguard Worker                 }
7565*062a843bSAndroid Build Coastguard Worker 
7566*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_SIGNAL_INFO_REC: {
7567*062a843bSAndroid Build Coastguard Worker                     record->signal.resize(1);
7568*062a843bSAndroid Build Coastguard Worker                     record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7569*062a843bSAndroid Build Coastguard Worker                     record->signal[0].signalType = infoRec->rec.signal.signalType;
7570*062a843bSAndroid Build Coastguard Worker                     record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7571*062a843bSAndroid Build Coastguard Worker                     record->signal[0].signal = infoRec->rec.signal.signal;
7572*062a843bSAndroid Build Coastguard Worker                     break;
7573*062a843bSAndroid Build Coastguard Worker                 }
7574*062a843bSAndroid Build Coastguard Worker 
7575*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7576*062a843bSAndroid Build Coastguard Worker                     if (infoRec->rec.redir.redirectingNumber.len >
7577*062a843bSAndroid Build Coastguard Worker                                                   CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7578*062a843bSAndroid Build Coastguard Worker                         RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7579*062a843bSAndroid Build Coastguard Worker                                 "expected not more than %d\n",
7580*062a843bSAndroid Build Coastguard Worker                                 (int)infoRec->rec.redir.redirectingNumber.len,
7581*062a843bSAndroid Build Coastguard Worker                                 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7582*062a843bSAndroid Build Coastguard Worker                         return 0;
7583*062a843bSAndroid Build Coastguard Worker                     }
7584*062a843bSAndroid Build Coastguard Worker                     string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7585*062a843bSAndroid Build Coastguard Worker                             sizeof(char));
7586*062a843bSAndroid Build Coastguard Worker                     if (string8 == NULL) {
7587*062a843bSAndroid Build Coastguard Worker                         RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7588*062a843bSAndroid Build Coastguard Worker                                 "responseCdmaInformationRecords");
7589*062a843bSAndroid Build Coastguard Worker                         return 0;
7590*062a843bSAndroid Build Coastguard Worker                     }
7591*062a843bSAndroid Build Coastguard Worker                     memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7592*062a843bSAndroid Build Coastguard Worker                             infoRec->rec.redir.redirectingNumber.len);
7593*062a843bSAndroid Build Coastguard Worker                     string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7594*062a843bSAndroid Build Coastguard Worker 
7595*062a843bSAndroid Build Coastguard Worker                     record->redir.resize(1);
7596*062a843bSAndroid Build Coastguard Worker                     record->redir[0].redirectingNumber.number = string8;
7597*062a843bSAndroid Build Coastguard Worker                     free(string8);
7598*062a843bSAndroid Build Coastguard Worker                     string8 = NULL;
7599*062a843bSAndroid Build Coastguard Worker                     record->redir[0].redirectingNumber.numberType =
7600*062a843bSAndroid Build Coastguard Worker                             infoRec->rec.redir.redirectingNumber.number_type;
7601*062a843bSAndroid Build Coastguard Worker                     record->redir[0].redirectingNumber.numberPlan =
7602*062a843bSAndroid Build Coastguard Worker                             infoRec->rec.redir.redirectingNumber.number_plan;
7603*062a843bSAndroid Build Coastguard Worker                     record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7604*062a843bSAndroid Build Coastguard Worker                     record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7605*062a843bSAndroid Build Coastguard Worker                     record->redir[0].redirectingReason =
7606*062a843bSAndroid Build Coastguard Worker                             (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7607*062a843bSAndroid Build Coastguard Worker                     break;
7608*062a843bSAndroid Build Coastguard Worker                 }
7609*062a843bSAndroid Build Coastguard Worker 
7610*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7611*062a843bSAndroid Build Coastguard Worker                     record->lineCtrl.resize(1);
7612*062a843bSAndroid Build Coastguard Worker                     record->lineCtrl[0].lineCtrlPolarityIncluded =
7613*062a843bSAndroid Build Coastguard Worker                             infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7614*062a843bSAndroid Build Coastguard Worker                     record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7615*062a843bSAndroid Build Coastguard Worker                     record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7616*062a843bSAndroid Build Coastguard Worker                     record->lineCtrl[0].lineCtrlPowerDenial =
7617*062a843bSAndroid Build Coastguard Worker                             infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7618*062a843bSAndroid Build Coastguard Worker                     break;
7619*062a843bSAndroid Build Coastguard Worker                 }
7620*062a843bSAndroid Build Coastguard Worker 
7621*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_T53_CLIR_INFO_REC: {
7622*062a843bSAndroid Build Coastguard Worker                     record->clir.resize(1);
7623*062a843bSAndroid Build Coastguard Worker                     record->clir[0].cause = infoRec->rec.clir.cause;
7624*062a843bSAndroid Build Coastguard Worker                     break;
7625*062a843bSAndroid Build Coastguard Worker                 }
7626*062a843bSAndroid Build Coastguard Worker 
7627*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7628*062a843bSAndroid Build Coastguard Worker                     record->audioCtrl.resize(1);
7629*062a843bSAndroid Build Coastguard Worker                     record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7630*062a843bSAndroid Build Coastguard Worker                     record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7631*062a843bSAndroid Build Coastguard Worker                     break;
7632*062a843bSAndroid Build Coastguard Worker                 }
7633*062a843bSAndroid Build Coastguard Worker 
7634*062a843bSAndroid Build Coastguard Worker                 case RIL_CDMA_T53_RELEASE_INFO_REC:
7635*062a843bSAndroid Build Coastguard Worker                     RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7636*062a843bSAndroid Build Coastguard Worker                     return 0;
7637*062a843bSAndroid Build Coastguard Worker 
7638*062a843bSAndroid Build Coastguard Worker                 default:
7639*062a843bSAndroid Build Coastguard Worker                     RLOGE("cdmaInfoRecInd: Incorrect name value");
7640*062a843bSAndroid Build Coastguard Worker                     return 0;
7641*062a843bSAndroid Build Coastguard Worker             }
7642*062a843bSAndroid Build Coastguard Worker         }
7643*062a843bSAndroid Build Coastguard Worker 
7644*062a843bSAndroid Build Coastguard Worker #if VDBG
7645*062a843bSAndroid Build Coastguard Worker         RLOGD("cdmaInfoRecInd");
7646*062a843bSAndroid Build Coastguard Worker #endif
7647*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7648*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), records);
7649*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7650*062a843bSAndroid Build Coastguard Worker     } else {
7651*062a843bSAndroid Build Coastguard Worker         RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7652*062a843bSAndroid Build Coastguard Worker     }
7653*062a843bSAndroid Build Coastguard Worker 
7654*062a843bSAndroid Build Coastguard Worker     return 0;
7655*062a843bSAndroid Build Coastguard Worker }
7656*062a843bSAndroid Build Coastguard Worker 
indicateRingbackToneInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7657*062a843bSAndroid Build Coastguard Worker int radio::indicateRingbackToneInd(int slotId,
7658*062a843bSAndroid Build Coastguard Worker                                    int indicationType, int token, RIL_Errno e, void *response,
7659*062a843bSAndroid Build Coastguard Worker                                    size_t responseLen) {
7660*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7661*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7662*062a843bSAndroid Build Coastguard Worker             RLOGE("indicateRingbackToneInd: invalid response");
7663*062a843bSAndroid Build Coastguard Worker             return 0;
7664*062a843bSAndroid Build Coastguard Worker         }
7665*062a843bSAndroid Build Coastguard Worker         bool start = ((int32_t *) response)[0];
7666*062a843bSAndroid Build Coastguard Worker #if VDBG
7667*062a843bSAndroid Build Coastguard Worker         RLOGD("indicateRingbackToneInd: start %d", start);
7668*062a843bSAndroid Build Coastguard Worker #endif
7669*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7670*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), start);
7671*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7672*062a843bSAndroid Build Coastguard Worker     } else {
7673*062a843bSAndroid Build Coastguard Worker         RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7674*062a843bSAndroid Build Coastguard Worker     }
7675*062a843bSAndroid Build Coastguard Worker 
7676*062a843bSAndroid Build Coastguard Worker     return 0;
7677*062a843bSAndroid Build Coastguard Worker }
7678*062a843bSAndroid Build Coastguard Worker 
resendIncallMuteInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7679*062a843bSAndroid Build Coastguard Worker int radio::resendIncallMuteInd(int slotId,
7680*062a843bSAndroid Build Coastguard Worker                                int indicationType, int token, RIL_Errno e, void *response,
7681*062a843bSAndroid Build Coastguard Worker                                size_t responseLen) {
7682*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7683*062a843bSAndroid Build Coastguard Worker #if VDBG
7684*062a843bSAndroid Build Coastguard Worker         RLOGD("resendIncallMuteInd");
7685*062a843bSAndroid Build Coastguard Worker #endif
7686*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7687*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7688*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7689*062a843bSAndroid Build Coastguard Worker     } else {
7690*062a843bSAndroid Build Coastguard Worker         RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7691*062a843bSAndroid Build Coastguard Worker     }
7692*062a843bSAndroid Build Coastguard Worker 
7693*062a843bSAndroid Build Coastguard Worker     return 0;
7694*062a843bSAndroid Build Coastguard Worker }
7695*062a843bSAndroid Build Coastguard Worker 
cdmaSubscriptionSourceChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7696*062a843bSAndroid Build Coastguard Worker int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7697*062a843bSAndroid Build Coastguard Worker                                             int indicationType, int token, RIL_Errno e,
7698*062a843bSAndroid Build Coastguard Worker                                             void *response, size_t responseLen) {
7699*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7700*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7701*062a843bSAndroid Build Coastguard Worker             RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7702*062a843bSAndroid Build Coastguard Worker             return 0;
7703*062a843bSAndroid Build Coastguard Worker         }
7704*062a843bSAndroid Build Coastguard Worker         int32_t cdmaSource = ((int32_t *) response)[0];
7705*062a843bSAndroid Build Coastguard Worker #if VDBG
7706*062a843bSAndroid Build Coastguard Worker         RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7707*062a843bSAndroid Build Coastguard Worker #endif
7708*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->
7709*062a843bSAndroid Build Coastguard Worker                 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7710*062a843bSAndroid Build Coastguard Worker                 (CdmaSubscriptionSource) cdmaSource);
7711*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7712*062a843bSAndroid Build Coastguard Worker     } else {
7713*062a843bSAndroid Build Coastguard Worker         RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7714*062a843bSAndroid Build Coastguard Worker                 slotId);
7715*062a843bSAndroid Build Coastguard Worker     }
7716*062a843bSAndroid Build Coastguard Worker 
7717*062a843bSAndroid Build Coastguard Worker     return 0;
7718*062a843bSAndroid Build Coastguard Worker }
7719*062a843bSAndroid Build Coastguard Worker 
cdmaPrlChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7720*062a843bSAndroid Build Coastguard Worker int radio::cdmaPrlChangedInd(int slotId,
7721*062a843bSAndroid Build Coastguard Worker                              int indicationType, int token, RIL_Errno e, void *response,
7722*062a843bSAndroid Build Coastguard Worker                              size_t responseLen) {
7723*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7724*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7725*062a843bSAndroid Build Coastguard Worker             RLOGE("cdmaPrlChangedInd: invalid response");
7726*062a843bSAndroid Build Coastguard Worker             return 0;
7727*062a843bSAndroid Build Coastguard Worker         }
7728*062a843bSAndroid Build Coastguard Worker         int32_t version = ((int32_t *) response)[0];
7729*062a843bSAndroid Build Coastguard Worker #if VDBG
7730*062a843bSAndroid Build Coastguard Worker         RLOGD("cdmaPrlChangedInd: version %d", version);
7731*062a843bSAndroid Build Coastguard Worker #endif
7732*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7733*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), version);
7734*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7735*062a843bSAndroid Build Coastguard Worker     } else {
7736*062a843bSAndroid Build Coastguard Worker         RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7737*062a843bSAndroid Build Coastguard Worker     }
7738*062a843bSAndroid Build Coastguard Worker 
7739*062a843bSAndroid Build Coastguard Worker     return 0;
7740*062a843bSAndroid Build Coastguard Worker }
7741*062a843bSAndroid Build Coastguard Worker 
exitEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7742*062a843bSAndroid Build Coastguard Worker int radio::exitEmergencyCallbackModeInd(int slotId,
7743*062a843bSAndroid Build Coastguard Worker                                         int indicationType, int token, RIL_Errno e, void *response,
7744*062a843bSAndroid Build Coastguard Worker                                         size_t responseLen) {
7745*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7746*062a843bSAndroid Build Coastguard Worker #if VDBG
7747*062a843bSAndroid Build Coastguard Worker         RLOGD("exitEmergencyCallbackModeInd");
7748*062a843bSAndroid Build Coastguard Worker #endif
7749*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7750*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7751*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7752*062a843bSAndroid Build Coastguard Worker     } else {
7753*062a843bSAndroid Build Coastguard Worker         RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7754*062a843bSAndroid Build Coastguard Worker                 slotId);
7755*062a843bSAndroid Build Coastguard Worker     }
7756*062a843bSAndroid Build Coastguard Worker 
7757*062a843bSAndroid Build Coastguard Worker     return 0;
7758*062a843bSAndroid Build Coastguard Worker }
7759*062a843bSAndroid Build Coastguard Worker 
rilConnectedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7760*062a843bSAndroid Build Coastguard Worker int radio::rilConnectedInd(int slotId,
7761*062a843bSAndroid Build Coastguard Worker                            int indicationType, int token, RIL_Errno e, void *response,
7762*062a843bSAndroid Build Coastguard Worker                            size_t responseLen) {
7763*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7764*062a843bSAndroid Build Coastguard Worker         RLOGD("rilConnectedInd");
7765*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7766*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7767*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7768*062a843bSAndroid Build Coastguard Worker     } else {
7769*062a843bSAndroid Build Coastguard Worker         RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7770*062a843bSAndroid Build Coastguard Worker     }
7771*062a843bSAndroid Build Coastguard Worker 
7772*062a843bSAndroid Build Coastguard Worker     return 0;
7773*062a843bSAndroid Build Coastguard Worker }
7774*062a843bSAndroid Build Coastguard Worker 
voiceRadioTechChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7775*062a843bSAndroid Build Coastguard Worker int radio::voiceRadioTechChangedInd(int slotId,
7776*062a843bSAndroid Build Coastguard Worker                                     int indicationType, int token, RIL_Errno e, void *response,
7777*062a843bSAndroid Build Coastguard Worker                                     size_t responseLen) {
7778*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7779*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7780*062a843bSAndroid Build Coastguard Worker             RLOGE("voiceRadioTechChangedInd: invalid response");
7781*062a843bSAndroid Build Coastguard Worker             return 0;
7782*062a843bSAndroid Build Coastguard Worker         }
7783*062a843bSAndroid Build Coastguard Worker         int32_t rat = ((int32_t *) response)[0];
7784*062a843bSAndroid Build Coastguard Worker #if VDBG
7785*062a843bSAndroid Build Coastguard Worker         RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7786*062a843bSAndroid Build Coastguard Worker #endif
7787*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7788*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7789*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7790*062a843bSAndroid Build Coastguard Worker     } else {
7791*062a843bSAndroid Build Coastguard Worker         RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7792*062a843bSAndroid Build Coastguard Worker                 slotId);
7793*062a843bSAndroid Build Coastguard Worker     }
7794*062a843bSAndroid Build Coastguard Worker 
7795*062a843bSAndroid Build Coastguard Worker     return 0;
7796*062a843bSAndroid Build Coastguard Worker }
7797*062a843bSAndroid Build Coastguard Worker 
convertRilCellInfoListToHal(void * response,size_t responseLen,hidl_vec<CellInfo> & records)7798*062a843bSAndroid Build Coastguard Worker void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7799*062a843bSAndroid Build Coastguard Worker     int num = responseLen / sizeof(RIL_CellInfo_v12);
7800*062a843bSAndroid Build Coastguard Worker     records.resize(num);
7801*062a843bSAndroid Build Coastguard Worker 
7802*062a843bSAndroid Build Coastguard Worker     RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7803*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < num; i++) {
7804*062a843bSAndroid Build Coastguard Worker         records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7805*062a843bSAndroid Build Coastguard Worker         records[i].registered = rillCellInfo->registered;
7806*062a843bSAndroid Build Coastguard Worker         records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7807*062a843bSAndroid Build Coastguard Worker         records[i].timeStamp = rillCellInfo->timeStamp;
7808*062a843bSAndroid Build Coastguard Worker         // All vectors should be size 0 except one which will be size 1. Set everything to
7809*062a843bSAndroid Build Coastguard Worker         // size 0 initially.
7810*062a843bSAndroid Build Coastguard Worker         records[i].gsm.resize(0);
7811*062a843bSAndroid Build Coastguard Worker         records[i].wcdma.resize(0);
7812*062a843bSAndroid Build Coastguard Worker         records[i].cdma.resize(0);
7813*062a843bSAndroid Build Coastguard Worker         records[i].lte.resize(0);
7814*062a843bSAndroid Build Coastguard Worker         records[i].tdscdma.resize(0);
7815*062a843bSAndroid Build Coastguard Worker         switch(rillCellInfo->cellInfoType) {
7816*062a843bSAndroid Build Coastguard Worker             case RIL_CELL_INFO_TYPE_GSM: {
7817*062a843bSAndroid Build Coastguard Worker                 records[i].gsm.resize(1);
7818*062a843bSAndroid Build Coastguard Worker                 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7819*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->cellIdentityGsm.mcc =
7820*062a843bSAndroid Build Coastguard Worker                         ril::util::mcc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7821*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->cellIdentityGsm.mnc =
7822*062a843bSAndroid Build Coastguard Worker                         ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7823*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->cellIdentityGsm.lac =
7824*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7825*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->cellIdentityGsm.cid =
7826*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7827*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->cellIdentityGsm.arfcn =
7828*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7829*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->cellIdentityGsm.bsic =
7830*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7831*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->signalStrengthGsm.signalStrength =
7832*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7833*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7834*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7835*062a843bSAndroid Build Coastguard Worker                 cellInfoGsm->signalStrengthGsm.timingAdvance =
7836*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7837*062a843bSAndroid Build Coastguard Worker                 break;
7838*062a843bSAndroid Build Coastguard Worker             }
7839*062a843bSAndroid Build Coastguard Worker 
7840*062a843bSAndroid Build Coastguard Worker             case RIL_CELL_INFO_TYPE_WCDMA: {
7841*062a843bSAndroid Build Coastguard Worker                 records[i].wcdma.resize(1);
7842*062a843bSAndroid Build Coastguard Worker                 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7843*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->cellIdentityWcdma.mcc =
7844*062a843bSAndroid Build Coastguard Worker                         ril::util::mcc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7845*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->cellIdentityWcdma.mnc =
7846*062a843bSAndroid Build Coastguard Worker                         ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7847*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->cellIdentityWcdma.lac =
7848*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7849*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->cellIdentityWcdma.cid =
7850*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7851*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->cellIdentityWcdma.psc =
7852*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7853*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7854*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7855*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7856*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7857*062a843bSAndroid Build Coastguard Worker                 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7858*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7859*062a843bSAndroid Build Coastguard Worker                 break;
7860*062a843bSAndroid Build Coastguard Worker             }
7861*062a843bSAndroid Build Coastguard Worker 
7862*062a843bSAndroid Build Coastguard Worker             case RIL_CELL_INFO_TYPE_CDMA: {
7863*062a843bSAndroid Build Coastguard Worker                 records[i].cdma.resize(1);
7864*062a843bSAndroid Build Coastguard Worker                 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7865*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->cellIdentityCdma.networkId =
7866*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7867*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->cellIdentityCdma.systemId =
7868*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7869*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->cellIdentityCdma.baseStationId =
7870*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7871*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->cellIdentityCdma.longitude =
7872*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7873*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->cellIdentityCdma.latitude =
7874*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7875*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->signalStrengthCdma.dbm =
7876*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7877*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->signalStrengthCdma.ecio =
7878*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7879*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->signalStrengthEvdo.dbm =
7880*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7881*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->signalStrengthEvdo.ecio =
7882*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7883*062a843bSAndroid Build Coastguard Worker                 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7884*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7885*062a843bSAndroid Build Coastguard Worker                 break;
7886*062a843bSAndroid Build Coastguard Worker             }
7887*062a843bSAndroid Build Coastguard Worker 
7888*062a843bSAndroid Build Coastguard Worker             case RIL_CELL_INFO_TYPE_LTE: {
7889*062a843bSAndroid Build Coastguard Worker                 records[i].lte.resize(1);
7890*062a843bSAndroid Build Coastguard Worker                 CellInfoLte *cellInfoLte = &records[i].lte[0];
7891*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->cellIdentityLte.mcc =
7892*062a843bSAndroid Build Coastguard Worker                         ril::util::mcc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7893*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->cellIdentityLte.mnc =
7894*062a843bSAndroid Build Coastguard Worker                         ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7895*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->cellIdentityLte.ci =
7896*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7897*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->cellIdentityLte.pci =
7898*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7899*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->cellIdentityLte.tac =
7900*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7901*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->cellIdentityLte.earfcn =
7902*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7903*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->signalStrengthLte.signalStrength =
7904*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7905*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->signalStrengthLte.rsrp =
7906*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7907*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->signalStrengthLte.rsrq =
7908*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7909*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->signalStrengthLte.rssnr =
7910*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7911*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->signalStrengthLte.cqi =
7912*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7913*062a843bSAndroid Build Coastguard Worker                 cellInfoLte->signalStrengthLte.timingAdvance =
7914*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7915*062a843bSAndroid Build Coastguard Worker                 break;
7916*062a843bSAndroid Build Coastguard Worker             }
7917*062a843bSAndroid Build Coastguard Worker 
7918*062a843bSAndroid Build Coastguard Worker             case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7919*062a843bSAndroid Build Coastguard Worker                 records[i].tdscdma.resize(1);
7920*062a843bSAndroid Build Coastguard Worker                 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7921*062a843bSAndroid Build Coastguard Worker                 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7922*062a843bSAndroid Build Coastguard Worker                         ril::util::mcc::decode(
7923*062a843bSAndroid Build Coastguard Worker                                 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7924*062a843bSAndroid Build Coastguard Worker                 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7925*062a843bSAndroid Build Coastguard Worker                         ril::util::mnc::decode(
7926*062a843bSAndroid Build Coastguard Worker                                 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7927*062a843bSAndroid Build Coastguard Worker                 cellInfoTdscdma->cellIdentityTdscdma.lac =
7928*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7929*062a843bSAndroid Build Coastguard Worker                 cellInfoTdscdma->cellIdentityTdscdma.cid =
7930*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7931*062a843bSAndroid Build Coastguard Worker                 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7932*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7933*062a843bSAndroid Build Coastguard Worker                 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7934*062a843bSAndroid Build Coastguard Worker                         rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7935*062a843bSAndroid Build Coastguard Worker                 break;
7936*062a843bSAndroid Build Coastguard Worker             }
7937*062a843bSAndroid Build Coastguard Worker             default: {
7938*062a843bSAndroid Build Coastguard Worker                 break;
7939*062a843bSAndroid Build Coastguard Worker             }
7940*062a843bSAndroid Build Coastguard Worker         }
7941*062a843bSAndroid Build Coastguard Worker         rillCellInfo += 1;
7942*062a843bSAndroid Build Coastguard Worker     }
7943*062a843bSAndroid Build Coastguard Worker }
7944*062a843bSAndroid Build Coastguard Worker 
cellInfoListInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7945*062a843bSAndroid Build Coastguard Worker int radio::cellInfoListInd(int slotId,
7946*062a843bSAndroid Build Coastguard Worker                            int indicationType, int token, RIL_Errno e, void *response,
7947*062a843bSAndroid Build Coastguard Worker                            size_t responseLen) {
7948*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7949*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7950*062a843bSAndroid Build Coastguard Worker             RLOGE("cellInfoListInd: invalid response");
7951*062a843bSAndroid Build Coastguard Worker             return 0;
7952*062a843bSAndroid Build Coastguard Worker         }
7953*062a843bSAndroid Build Coastguard Worker 
7954*062a843bSAndroid Build Coastguard Worker         hidl_vec<CellInfo> records;
7955*062a843bSAndroid Build Coastguard Worker         convertRilCellInfoListToHal(response, responseLen, records);
7956*062a843bSAndroid Build Coastguard Worker 
7957*062a843bSAndroid Build Coastguard Worker #if VDBG
7958*062a843bSAndroid Build Coastguard Worker         RLOGD("cellInfoListInd");
7959*062a843bSAndroid Build Coastguard Worker #endif
7960*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7961*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), records);
7962*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7963*062a843bSAndroid Build Coastguard Worker     } else {
7964*062a843bSAndroid Build Coastguard Worker         RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7965*062a843bSAndroid Build Coastguard Worker     }
7966*062a843bSAndroid Build Coastguard Worker 
7967*062a843bSAndroid Build Coastguard Worker     return 0;
7968*062a843bSAndroid Build Coastguard Worker }
7969*062a843bSAndroid Build Coastguard Worker 
imsNetworkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7970*062a843bSAndroid Build Coastguard Worker int radio::imsNetworkStateChangedInd(int slotId,
7971*062a843bSAndroid Build Coastguard Worker                                      int indicationType, int token, RIL_Errno e, void *response,
7972*062a843bSAndroid Build Coastguard Worker                                      size_t responseLen) {
7973*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7974*062a843bSAndroid Build Coastguard Worker #if VDBG
7975*062a843bSAndroid Build Coastguard Worker         RLOGD("imsNetworkStateChangedInd");
7976*062a843bSAndroid Build Coastguard Worker #endif
7977*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7978*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType));
7979*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
7980*062a843bSAndroid Build Coastguard Worker     } else {
7981*062a843bSAndroid Build Coastguard Worker         RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7982*062a843bSAndroid Build Coastguard Worker                 slotId);
7983*062a843bSAndroid Build Coastguard Worker     }
7984*062a843bSAndroid Build Coastguard Worker 
7985*062a843bSAndroid Build Coastguard Worker     return 0;
7986*062a843bSAndroid Build Coastguard Worker }
7987*062a843bSAndroid Build Coastguard Worker 
subscriptionStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)7988*062a843bSAndroid Build Coastguard Worker int radio::subscriptionStatusChangedInd(int slotId,
7989*062a843bSAndroid Build Coastguard Worker                                         int indicationType, int token, RIL_Errno e, void *response,
7990*062a843bSAndroid Build Coastguard Worker                                         size_t responseLen) {
7991*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7992*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
7993*062a843bSAndroid Build Coastguard Worker             RLOGE("subscriptionStatusChangedInd: invalid response");
7994*062a843bSAndroid Build Coastguard Worker             return 0;
7995*062a843bSAndroid Build Coastguard Worker         }
7996*062a843bSAndroid Build Coastguard Worker         bool activate = ((int32_t *) response)[0];
7997*062a843bSAndroid Build Coastguard Worker #if VDBG
7998*062a843bSAndroid Build Coastguard Worker         RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7999*062a843bSAndroid Build Coastguard Worker #endif
8000*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
8001*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), activate);
8002*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8003*062a843bSAndroid Build Coastguard Worker     } else {
8004*062a843bSAndroid Build Coastguard Worker         RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
8005*062a843bSAndroid Build Coastguard Worker                 slotId);
8006*062a843bSAndroid Build Coastguard Worker     }
8007*062a843bSAndroid Build Coastguard Worker 
8008*062a843bSAndroid Build Coastguard Worker     return 0;
8009*062a843bSAndroid Build Coastguard Worker }
8010*062a843bSAndroid Build Coastguard Worker 
srvccStateNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8011*062a843bSAndroid Build Coastguard Worker int radio::srvccStateNotifyInd(int slotId,
8012*062a843bSAndroid Build Coastguard Worker                                int indicationType, int token, RIL_Errno e, void *response,
8013*062a843bSAndroid Build Coastguard Worker                                size_t responseLen) {
8014*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8015*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(int)) {
8016*062a843bSAndroid Build Coastguard Worker             RLOGE("srvccStateNotifyInd: invalid response");
8017*062a843bSAndroid Build Coastguard Worker             return 0;
8018*062a843bSAndroid Build Coastguard Worker         }
8019*062a843bSAndroid Build Coastguard Worker         int32_t state = ((int32_t *) response)[0];
8020*062a843bSAndroid Build Coastguard Worker #if VDBG
8021*062a843bSAndroid Build Coastguard Worker         RLOGD("srvccStateNotifyInd: rat %d", state);
8022*062a843bSAndroid Build Coastguard Worker #endif
8023*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
8024*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
8025*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8026*062a843bSAndroid Build Coastguard Worker     } else {
8027*062a843bSAndroid Build Coastguard Worker         RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8028*062a843bSAndroid Build Coastguard Worker     }
8029*062a843bSAndroid Build Coastguard Worker 
8030*062a843bSAndroid Build Coastguard Worker     return 0;
8031*062a843bSAndroid Build Coastguard Worker }
8032*062a843bSAndroid Build Coastguard Worker 
convertRilHardwareConfigListToHal(void * response,size_t responseLen,hidl_vec<HardwareConfig> & records)8033*062a843bSAndroid Build Coastguard Worker void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
8034*062a843bSAndroid Build Coastguard Worker         hidl_vec<HardwareConfig>& records) {
8035*062a843bSAndroid Build Coastguard Worker     int num = responseLen / sizeof(RIL_HardwareConfig);
8036*062a843bSAndroid Build Coastguard Worker     records.resize(num);
8037*062a843bSAndroid Build Coastguard Worker 
8038*062a843bSAndroid Build Coastguard Worker     RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
8039*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < num; i++) {
8040*062a843bSAndroid Build Coastguard Worker         records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
8041*062a843bSAndroid Build Coastguard Worker         records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
8042*062a843bSAndroid Build Coastguard Worker         records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
8043*062a843bSAndroid Build Coastguard Worker         switch (rilHardwareConfig[i].type) {
8044*062a843bSAndroid Build Coastguard Worker             case RIL_HARDWARE_CONFIG_MODEM: {
8045*062a843bSAndroid Build Coastguard Worker                 records[i].modem.resize(1);
8046*062a843bSAndroid Build Coastguard Worker                 records[i].sim.resize(0);
8047*062a843bSAndroid Build Coastguard Worker                 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
8048*062a843bSAndroid Build Coastguard Worker                 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
8049*062a843bSAndroid Build Coastguard Worker                 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
8050*062a843bSAndroid Build Coastguard Worker                 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
8051*062a843bSAndroid Build Coastguard Worker                 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
8052*062a843bSAndroid Build Coastguard Worker                 break;
8053*062a843bSAndroid Build Coastguard Worker             }
8054*062a843bSAndroid Build Coastguard Worker 
8055*062a843bSAndroid Build Coastguard Worker             case RIL_HARDWARE_CONFIG_SIM: {
8056*062a843bSAndroid Build Coastguard Worker                 records[i].sim.resize(1);
8057*062a843bSAndroid Build Coastguard Worker                 records[i].modem.resize(0);
8058*062a843bSAndroid Build Coastguard Worker                 records[i].sim[0].modemUuid =
8059*062a843bSAndroid Build Coastguard Worker                         convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
8060*062a843bSAndroid Build Coastguard Worker                 break;
8061*062a843bSAndroid Build Coastguard Worker             }
8062*062a843bSAndroid Build Coastguard Worker         }
8063*062a843bSAndroid Build Coastguard Worker     }
8064*062a843bSAndroid Build Coastguard Worker }
8065*062a843bSAndroid Build Coastguard Worker 
hardwareConfigChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8066*062a843bSAndroid Build Coastguard Worker int radio::hardwareConfigChangedInd(int slotId,
8067*062a843bSAndroid Build Coastguard Worker                                     int indicationType, int token, RIL_Errno e, void *response,
8068*062a843bSAndroid Build Coastguard Worker                                     size_t responseLen) {
8069*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8070*062a843bSAndroid Build Coastguard Worker         if ((response == NULL && responseLen != 0)
8071*062a843bSAndroid Build Coastguard Worker                 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
8072*062a843bSAndroid Build Coastguard Worker             RLOGE("hardwareConfigChangedInd: invalid response");
8073*062a843bSAndroid Build Coastguard Worker             return 0;
8074*062a843bSAndroid Build Coastguard Worker         }
8075*062a843bSAndroid Build Coastguard Worker 
8076*062a843bSAndroid Build Coastguard Worker         hidl_vec<HardwareConfig> configs;
8077*062a843bSAndroid Build Coastguard Worker         convertRilHardwareConfigListToHal(response, responseLen, configs);
8078*062a843bSAndroid Build Coastguard Worker 
8079*062a843bSAndroid Build Coastguard Worker #if VDBG
8080*062a843bSAndroid Build Coastguard Worker         RLOGD("hardwareConfigChangedInd");
8081*062a843bSAndroid Build Coastguard Worker #endif
8082*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8083*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), configs);
8084*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8085*062a843bSAndroid Build Coastguard Worker     } else {
8086*062a843bSAndroid Build Coastguard Worker         RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8087*062a843bSAndroid Build Coastguard Worker                 slotId);
8088*062a843bSAndroid Build Coastguard Worker     }
8089*062a843bSAndroid Build Coastguard Worker 
8090*062a843bSAndroid Build Coastguard Worker     return 0;
8091*062a843bSAndroid Build Coastguard Worker }
8092*062a843bSAndroid Build Coastguard Worker 
convertRilRadioCapabilityToHal(void * response,size_t responseLen,RadioCapability & rc)8093*062a843bSAndroid Build Coastguard Worker void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8094*062a843bSAndroid Build Coastguard Worker     RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8095*062a843bSAndroid Build Coastguard Worker     rc.session = rilRadioCapability->session;
8096*062a843bSAndroid Build Coastguard Worker     rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8097*062a843bSAndroid Build Coastguard Worker     rc.raf = rilRadioCapability->rat;
8098*062a843bSAndroid Build Coastguard Worker     rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8099*062a843bSAndroid Build Coastguard Worker     rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8100*062a843bSAndroid Build Coastguard Worker }
8101*062a843bSAndroid Build Coastguard Worker 
radioCapabilityIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8102*062a843bSAndroid Build Coastguard Worker int radio::radioCapabilityIndicationInd(int slotId,
8103*062a843bSAndroid Build Coastguard Worker                                         int indicationType, int token, RIL_Errno e, void *response,
8104*062a843bSAndroid Build Coastguard Worker                                         size_t responseLen) {
8105*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8106*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8107*062a843bSAndroid Build Coastguard Worker             RLOGE("radioCapabilityIndicationInd: invalid response");
8108*062a843bSAndroid Build Coastguard Worker             return 0;
8109*062a843bSAndroid Build Coastguard Worker         }
8110*062a843bSAndroid Build Coastguard Worker 
8111*062a843bSAndroid Build Coastguard Worker         RadioCapability rc = {};
8112*062a843bSAndroid Build Coastguard Worker         convertRilRadioCapabilityToHal(response, responseLen, rc);
8113*062a843bSAndroid Build Coastguard Worker 
8114*062a843bSAndroid Build Coastguard Worker #if VDBG
8115*062a843bSAndroid Build Coastguard Worker         RLOGD("radioCapabilityIndicationInd");
8116*062a843bSAndroid Build Coastguard Worker #endif
8117*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8118*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), rc);
8119*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8120*062a843bSAndroid Build Coastguard Worker     } else {
8121*062a843bSAndroid Build Coastguard Worker         RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8122*062a843bSAndroid Build Coastguard Worker                 slotId);
8123*062a843bSAndroid Build Coastguard Worker     }
8124*062a843bSAndroid Build Coastguard Worker 
8125*062a843bSAndroid Build Coastguard Worker     return 0;
8126*062a843bSAndroid Build Coastguard Worker }
8127*062a843bSAndroid Build Coastguard Worker 
isServiceTypeCfQuery(RIL_SsServiceType serType,RIL_SsRequestType reqType)8128*062a843bSAndroid Build Coastguard Worker bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8129*062a843bSAndroid Build Coastguard Worker     if ((reqType == SS_INTERROGATION) &&
8130*062a843bSAndroid Build Coastguard Worker         (serType == SS_CFU ||
8131*062a843bSAndroid Build Coastguard Worker          serType == SS_CF_BUSY ||
8132*062a843bSAndroid Build Coastguard Worker          serType == SS_CF_NO_REPLY ||
8133*062a843bSAndroid Build Coastguard Worker          serType == SS_CF_NOT_REACHABLE ||
8134*062a843bSAndroid Build Coastguard Worker          serType == SS_CF_ALL ||
8135*062a843bSAndroid Build Coastguard Worker          serType == SS_CF_ALL_CONDITIONAL)) {
8136*062a843bSAndroid Build Coastguard Worker         return true;
8137*062a843bSAndroid Build Coastguard Worker     }
8138*062a843bSAndroid Build Coastguard Worker     return false;
8139*062a843bSAndroid Build Coastguard Worker }
8140*062a843bSAndroid Build Coastguard Worker 
onSupplementaryServiceIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8141*062a843bSAndroid Build Coastguard Worker int radio::onSupplementaryServiceIndicationInd(int slotId,
8142*062a843bSAndroid Build Coastguard Worker                                                int indicationType, int token, RIL_Errno e,
8143*062a843bSAndroid Build Coastguard Worker                                                void *response, size_t responseLen) {
8144*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8145*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8146*062a843bSAndroid Build Coastguard Worker             RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8147*062a843bSAndroid Build Coastguard Worker             return 0;
8148*062a843bSAndroid Build Coastguard Worker         }
8149*062a843bSAndroid Build Coastguard Worker 
8150*062a843bSAndroid Build Coastguard Worker         RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8151*062a843bSAndroid Build Coastguard Worker         StkCcUnsolSsResult ss = {};
8152*062a843bSAndroid Build Coastguard Worker         ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8153*062a843bSAndroid Build Coastguard Worker         ss.requestType = (SsRequestType) rilSsResponse->requestType;
8154*062a843bSAndroid Build Coastguard Worker         ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8155*062a843bSAndroid Build Coastguard Worker         ss.serviceClass = rilSsResponse->serviceClass;
8156*062a843bSAndroid Build Coastguard Worker         ss.result = (RadioError) rilSsResponse->result;
8157*062a843bSAndroid Build Coastguard Worker 
8158*062a843bSAndroid Build Coastguard Worker         if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8159*062a843bSAndroid Build Coastguard Worker #if VDBG
8160*062a843bSAndroid Build Coastguard Worker             RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8161*062a843bSAndroid Build Coastguard Worker                     rilSsResponse->cfData.numValidIndexes);
8162*062a843bSAndroid Build Coastguard Worker #endif
8163*062a843bSAndroid Build Coastguard Worker             if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8164*062a843bSAndroid Build Coastguard Worker                 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8165*062a843bSAndroid Build Coastguard Worker                         "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8166*062a843bSAndroid Build Coastguard Worker                 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8167*062a843bSAndroid Build Coastguard Worker             }
8168*062a843bSAndroid Build Coastguard Worker 
8169*062a843bSAndroid Build Coastguard Worker             ss.cfData.resize(1);
8170*062a843bSAndroid Build Coastguard Worker             ss.ssInfo.resize(0);
8171*062a843bSAndroid Build Coastguard Worker 
8172*062a843bSAndroid Build Coastguard Worker             /* number of call info's */
8173*062a843bSAndroid Build Coastguard Worker             ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8174*062a843bSAndroid Build Coastguard Worker 
8175*062a843bSAndroid Build Coastguard Worker             for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8176*062a843bSAndroid Build Coastguard Worker                  RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8177*062a843bSAndroid Build Coastguard Worker                  CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8178*062a843bSAndroid Build Coastguard Worker 
8179*062a843bSAndroid Build Coastguard Worker                  cfInfo->status = (CallForwardInfoStatus) cf.status;
8180*062a843bSAndroid Build Coastguard Worker                  cfInfo->reason = cf.reason;
8181*062a843bSAndroid Build Coastguard Worker                  cfInfo->serviceClass = cf.serviceClass;
8182*062a843bSAndroid Build Coastguard Worker                  cfInfo->toa = cf.toa;
8183*062a843bSAndroid Build Coastguard Worker                  cfInfo->number = convertCharPtrToHidlString(cf.number);
8184*062a843bSAndroid Build Coastguard Worker                  cfInfo->timeSeconds = cf.timeSeconds;
8185*062a843bSAndroid Build Coastguard Worker #if VDBG
8186*062a843bSAndroid Build Coastguard Worker                  RLOGD("onSupplementaryServiceIndicationInd: "
8187*062a843bSAndroid Build Coastguard Worker                         "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8188*062a843bSAndroid Build Coastguard Worker                         cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8189*062a843bSAndroid Build Coastguard Worker #endif
8190*062a843bSAndroid Build Coastguard Worker             }
8191*062a843bSAndroid Build Coastguard Worker         } else {
8192*062a843bSAndroid Build Coastguard Worker             ss.ssInfo.resize(1);
8193*062a843bSAndroid Build Coastguard Worker             ss.cfData.resize(0);
8194*062a843bSAndroid Build Coastguard Worker 
8195*062a843bSAndroid Build Coastguard Worker             /* each int */
8196*062a843bSAndroid Build Coastguard Worker             ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8197*062a843bSAndroid Build Coastguard Worker             for (int i = 0; i < SS_INFO_MAX; i++) {
8198*062a843bSAndroid Build Coastguard Worker #if VDBG
8199*062a843bSAndroid Build Coastguard Worker                  RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8200*062a843bSAndroid Build Coastguard Worker                         rilSsResponse->ssInfo[i]);
8201*062a843bSAndroid Build Coastguard Worker #endif
8202*062a843bSAndroid Build Coastguard Worker                  ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8203*062a843bSAndroid Build Coastguard Worker             }
8204*062a843bSAndroid Build Coastguard Worker         }
8205*062a843bSAndroid Build Coastguard Worker 
8206*062a843bSAndroid Build Coastguard Worker #if VDBG
8207*062a843bSAndroid Build Coastguard Worker         RLOGD("onSupplementaryServiceIndicationInd");
8208*062a843bSAndroid Build Coastguard Worker #endif
8209*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->
8210*062a843bSAndroid Build Coastguard Worker                 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8211*062a843bSAndroid Build Coastguard Worker                 ss);
8212*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8213*062a843bSAndroid Build Coastguard Worker     } else {
8214*062a843bSAndroid Build Coastguard Worker         RLOGE("onSupplementaryServiceIndicationInd: "
8215*062a843bSAndroid Build Coastguard Worker                 "radioService[%d]->mRadioIndication == NULL", slotId);
8216*062a843bSAndroid Build Coastguard Worker     }
8217*062a843bSAndroid Build Coastguard Worker 
8218*062a843bSAndroid Build Coastguard Worker     return 0;
8219*062a843bSAndroid Build Coastguard Worker }
8220*062a843bSAndroid Build Coastguard Worker 
stkCallControlAlphaNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8221*062a843bSAndroid Build Coastguard Worker int radio::stkCallControlAlphaNotifyInd(int slotId,
8222*062a843bSAndroid Build Coastguard Worker                                         int indicationType, int token, RIL_Errno e, void *response,
8223*062a843bSAndroid Build Coastguard Worker                                         size_t responseLen) {
8224*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8225*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
8226*062a843bSAndroid Build Coastguard Worker             RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8227*062a843bSAndroid Build Coastguard Worker             return 0;
8228*062a843bSAndroid Build Coastguard Worker         }
8229*062a843bSAndroid Build Coastguard Worker #if VDBG
8230*062a843bSAndroid Build Coastguard Worker         RLOGD("stkCallControlAlphaNotifyInd");
8231*062a843bSAndroid Build Coastguard Worker #endif
8232*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8233*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType),
8234*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
8235*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8236*062a843bSAndroid Build Coastguard Worker     } else {
8237*062a843bSAndroid Build Coastguard Worker         RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8238*062a843bSAndroid Build Coastguard Worker                 slotId);
8239*062a843bSAndroid Build Coastguard Worker     }
8240*062a843bSAndroid Build Coastguard Worker 
8241*062a843bSAndroid Build Coastguard Worker     return 0;
8242*062a843bSAndroid Build Coastguard Worker }
8243*062a843bSAndroid Build Coastguard Worker 
convertRilLceDataInfoToHal(void * response,size_t responseLen,LceDataInfo & lce)8244*062a843bSAndroid Build Coastguard Worker void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8245*062a843bSAndroid Build Coastguard Worker     RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8246*062a843bSAndroid Build Coastguard Worker     lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8247*062a843bSAndroid Build Coastguard Worker     lce.confidenceLevel = rilLceDataInfo->confidence_level;
8248*062a843bSAndroid Build Coastguard Worker     lce.lceSuspended = rilLceDataInfo->lce_suspended;
8249*062a843bSAndroid Build Coastguard Worker }
8250*062a843bSAndroid Build Coastguard Worker 
lceDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8251*062a843bSAndroid Build Coastguard Worker int radio::lceDataInd(int slotId,
8252*062a843bSAndroid Build Coastguard Worker                       int indicationType, int token, RIL_Errno e, void *response,
8253*062a843bSAndroid Build Coastguard Worker                       size_t responseLen) {
8254*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8255*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8256*062a843bSAndroid Build Coastguard Worker             RLOGE("lceDataInd: invalid response");
8257*062a843bSAndroid Build Coastguard Worker             return 0;
8258*062a843bSAndroid Build Coastguard Worker         }
8259*062a843bSAndroid Build Coastguard Worker 
8260*062a843bSAndroid Build Coastguard Worker         LceDataInfo lce = {};
8261*062a843bSAndroid Build Coastguard Worker         convertRilLceDataInfoToHal(response, responseLen, lce);
8262*062a843bSAndroid Build Coastguard Worker #if VDBG
8263*062a843bSAndroid Build Coastguard Worker         RLOGD("lceDataInd");
8264*062a843bSAndroid Build Coastguard Worker #endif
8265*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8266*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), lce);
8267*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8268*062a843bSAndroid Build Coastguard Worker     } else {
8269*062a843bSAndroid Build Coastguard Worker         RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8270*062a843bSAndroid Build Coastguard Worker     }
8271*062a843bSAndroid Build Coastguard Worker 
8272*062a843bSAndroid Build Coastguard Worker     return 0;
8273*062a843bSAndroid Build Coastguard Worker }
8274*062a843bSAndroid Build Coastguard Worker 
pcoDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8275*062a843bSAndroid Build Coastguard Worker int radio::pcoDataInd(int slotId,
8276*062a843bSAndroid Build Coastguard Worker                       int indicationType, int token, RIL_Errno e, void *response,
8277*062a843bSAndroid Build Coastguard Worker                       size_t responseLen) {
8278*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8279*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8280*062a843bSAndroid Build Coastguard Worker             RLOGE("pcoDataInd: invalid response");
8281*062a843bSAndroid Build Coastguard Worker             return 0;
8282*062a843bSAndroid Build Coastguard Worker         }
8283*062a843bSAndroid Build Coastguard Worker 
8284*062a843bSAndroid Build Coastguard Worker         PcoDataInfo pco = {};
8285*062a843bSAndroid Build Coastguard Worker         RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8286*062a843bSAndroid Build Coastguard Worker         pco.cid = rilPcoData->cid;
8287*062a843bSAndroid Build Coastguard Worker         pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8288*062a843bSAndroid Build Coastguard Worker         pco.pcoId = rilPcoData->pco_id;
8289*062a843bSAndroid Build Coastguard Worker         pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8290*062a843bSAndroid Build Coastguard Worker 
8291*062a843bSAndroid Build Coastguard Worker #if VDBG
8292*062a843bSAndroid Build Coastguard Worker         RLOGD("pcoDataInd");
8293*062a843bSAndroid Build Coastguard Worker #endif
8294*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8295*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), pco);
8296*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8297*062a843bSAndroid Build Coastguard Worker     } else {
8298*062a843bSAndroid Build Coastguard Worker         RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8299*062a843bSAndroid Build Coastguard Worker     }
8300*062a843bSAndroid Build Coastguard Worker 
8301*062a843bSAndroid Build Coastguard Worker     return 0;
8302*062a843bSAndroid Build Coastguard Worker }
8303*062a843bSAndroid Build Coastguard Worker 
modemResetInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8304*062a843bSAndroid Build Coastguard Worker int radio::modemResetInd(int slotId,
8305*062a843bSAndroid Build Coastguard Worker                          int indicationType, int token, RIL_Errno e, void *response,
8306*062a843bSAndroid Build Coastguard Worker                          size_t responseLen) {
8307*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8308*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
8309*062a843bSAndroid Build Coastguard Worker             RLOGE("modemResetInd: invalid response");
8310*062a843bSAndroid Build Coastguard Worker             return 0;
8311*062a843bSAndroid Build Coastguard Worker         }
8312*062a843bSAndroid Build Coastguard Worker #if VDBG
8313*062a843bSAndroid Build Coastguard Worker         RLOGD("modemResetInd");
8314*062a843bSAndroid Build Coastguard Worker #endif
8315*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8316*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType),
8317*062a843bSAndroid Build Coastguard Worker                 convertCharPtrToHidlString((char *) response));
8318*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8319*062a843bSAndroid Build Coastguard Worker     } else {
8320*062a843bSAndroid Build Coastguard Worker         RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8321*062a843bSAndroid Build Coastguard Worker     }
8322*062a843bSAndroid Build Coastguard Worker 
8323*062a843bSAndroid Build Coastguard Worker     return 0;
8324*062a843bSAndroid Build Coastguard Worker }
8325*062a843bSAndroid Build Coastguard Worker 
networkScanResultInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8326*062a843bSAndroid Build Coastguard Worker int radio::networkScanResultInd(int slotId,
8327*062a843bSAndroid Build Coastguard Worker                                 int indicationType, int token, RIL_Errno e, void *response,
8328*062a843bSAndroid Build Coastguard Worker                                 size_t responseLen) {
8329*062a843bSAndroid Build Coastguard Worker #if VDBG
8330*062a843bSAndroid Build Coastguard Worker     RLOGD("networkScanResultInd");
8331*062a843bSAndroid Build Coastguard Worker #endif
8332*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8333*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
8334*062a843bSAndroid Build Coastguard Worker             RLOGE("networkScanResultInd: invalid response");
8335*062a843bSAndroid Build Coastguard Worker             return 0;
8336*062a843bSAndroid Build Coastguard Worker         }
8337*062a843bSAndroid Build Coastguard Worker         RLOGD("networkScanResultInd");
8338*062a843bSAndroid Build Coastguard Worker 
8339*062a843bSAndroid Build Coastguard Worker #if VDBG
8340*062a843bSAndroid Build Coastguard Worker         RLOGD("networkScanResultInd");
8341*062a843bSAndroid Build Coastguard Worker #endif
8342*062a843bSAndroid Build Coastguard Worker 
8343*062a843bSAndroid Build Coastguard Worker         RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8344*062a843bSAndroid Build Coastguard Worker 
8345*062a843bSAndroid Build Coastguard Worker         V1_1::NetworkScanResult result;
8346*062a843bSAndroid Build Coastguard Worker         result.status = (V1_1::ScanStatus) networkScanResult->status;
8347*062a843bSAndroid Build Coastguard Worker         result.error = (RadioError) networkScanResult->error;
8348*062a843bSAndroid Build Coastguard Worker         convertRilCellInfoListToHal(
8349*062a843bSAndroid Build Coastguard Worker                 networkScanResult->network_infos,
8350*062a843bSAndroid Build Coastguard Worker                 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8351*062a843bSAndroid Build Coastguard Worker                 result.networkInfos);
8352*062a843bSAndroid Build Coastguard Worker 
8353*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
8354*062a843bSAndroid Build Coastguard Worker                 convertIntToRadioIndicationType(indicationType), result);
8355*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8356*062a843bSAndroid Build Coastguard Worker     } else {
8357*062a843bSAndroid Build Coastguard Worker         RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_1 == NULL", slotId);
8358*062a843bSAndroid Build Coastguard Worker     }
8359*062a843bSAndroid Build Coastguard Worker     return 0;
8360*062a843bSAndroid Build Coastguard Worker }
8361*062a843bSAndroid Build Coastguard Worker 
carrierInfoForImsiEncryption(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8362*062a843bSAndroid Build Coastguard Worker int radio::carrierInfoForImsiEncryption(int slotId,
8363*062a843bSAndroid Build Coastguard Worker                                   int indicationType, int token, RIL_Errno e, void *response,
8364*062a843bSAndroid Build Coastguard Worker                                   size_t responseLen) {
8365*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8366*062a843bSAndroid Build Coastguard Worker         if (response == NULL || responseLen == 0) {
8367*062a843bSAndroid Build Coastguard Worker             RLOGE("carrierInfoForImsiEncryption: invalid response");
8368*062a843bSAndroid Build Coastguard Worker             return 0;
8369*062a843bSAndroid Build Coastguard Worker         }
8370*062a843bSAndroid Build Coastguard Worker         RLOGD("carrierInfoForImsiEncryption");
8371*062a843bSAndroid Build Coastguard Worker         Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->
8372*062a843bSAndroid Build Coastguard Worker                 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
8373*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->checkReturnStatus(retStatus);
8374*062a843bSAndroid Build Coastguard Worker     } else {
8375*062a843bSAndroid Build Coastguard Worker         RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_1 == NULL",
8376*062a843bSAndroid Build Coastguard Worker                 slotId);
8377*062a843bSAndroid Build Coastguard Worker     }
8378*062a843bSAndroid Build Coastguard Worker 
8379*062a843bSAndroid Build Coastguard Worker     return 0;
8380*062a843bSAndroid Build Coastguard Worker }
8381*062a843bSAndroid Build Coastguard Worker 
keepaliveStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)8382*062a843bSAndroid Build Coastguard Worker int radio::keepaliveStatusInd(int slotId,
8383*062a843bSAndroid Build Coastguard Worker                          int indicationType, int token, RIL_Errno e, void *response,
8384*062a843bSAndroid Build Coastguard Worker                          size_t responseLen) {
8385*062a843bSAndroid Build Coastguard Worker #if VDBG
8386*062a843bSAndroid Build Coastguard Worker     RLOGD("%s(): token=%d", __FUNCTION__, token);
8387*062a843bSAndroid Build Coastguard Worker #endif
8388*062a843bSAndroid Build Coastguard Worker     if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
8389*062a843bSAndroid Build Coastguard Worker         RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
8390*062a843bSAndroid Build Coastguard Worker         return 0;
8391*062a843bSAndroid Build Coastguard Worker     }
8392*062a843bSAndroid Build Coastguard Worker 
8393*062a843bSAndroid Build Coastguard Worker     auto ret = V1_1::IRadioIndication::castFrom(
8394*062a843bSAndroid Build Coastguard Worker         radioService[slotId]->mRadioIndication);
8395*062a843bSAndroid Build Coastguard Worker     if (!ret.isOk()) {
8396*062a843bSAndroid Build Coastguard Worker         RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
8397*062a843bSAndroid Build Coastguard Worker         return 0;
8398*062a843bSAndroid Build Coastguard Worker     }
8399*062a843bSAndroid Build Coastguard Worker     sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8400*062a843bSAndroid Build Coastguard Worker 
8401*062a843bSAndroid Build Coastguard Worker     if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
8402*062a843bSAndroid Build Coastguard Worker         RLOGE("%s: invalid response", __FUNCTION__);
8403*062a843bSAndroid Build Coastguard Worker         return 0;
8404*062a843bSAndroid Build Coastguard Worker     }
8405*062a843bSAndroid Build Coastguard Worker 
8406*062a843bSAndroid Build Coastguard Worker     V1_1::KeepaliveStatus ks;
8407*062a843bSAndroid Build Coastguard Worker     convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
8408*062a843bSAndroid Build Coastguard Worker 
8409*062a843bSAndroid Build Coastguard Worker     Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
8410*062a843bSAndroid Build Coastguard Worker             convertIntToRadioIndicationType(indicationType), ks);
8411*062a843bSAndroid Build Coastguard Worker     radioService[slotId]->checkReturnStatus(retStatus);
8412*062a843bSAndroid Build Coastguard Worker     return 0;
8413*062a843bSAndroid Build Coastguard Worker }
8414*062a843bSAndroid Build Coastguard Worker 
registerService(RIL_RadioFunctions * callbacks,CommandInfo * commands)8415*062a843bSAndroid Build Coastguard Worker void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8416*062a843bSAndroid Build Coastguard Worker     using namespace android::hardware;
8417*062a843bSAndroid Build Coastguard Worker     int simCount = 1;
8418*062a843bSAndroid Build Coastguard Worker     const char *serviceNames[] = {
8419*062a843bSAndroid Build Coastguard Worker             android::RIL_getServiceName()
8420*062a843bSAndroid Build Coastguard Worker             #if (SIM_COUNT >= 2)
8421*062a843bSAndroid Build Coastguard Worker             , RIL2_SERVICE_NAME
8422*062a843bSAndroid Build Coastguard Worker             #if (SIM_COUNT >= 3)
8423*062a843bSAndroid Build Coastguard Worker             , RIL3_SERVICE_NAME
8424*062a843bSAndroid Build Coastguard Worker             #if (SIM_COUNT >= 4)
8425*062a843bSAndroid Build Coastguard Worker             , RIL4_SERVICE_NAME
8426*062a843bSAndroid Build Coastguard Worker             #endif
8427*062a843bSAndroid Build Coastguard Worker             #endif
8428*062a843bSAndroid Build Coastguard Worker             #endif
8429*062a843bSAndroid Build Coastguard Worker             };
8430*062a843bSAndroid Build Coastguard Worker 
8431*062a843bSAndroid Build Coastguard Worker     #if (SIM_COUNT >= 2)
8432*062a843bSAndroid Build Coastguard Worker     simCount = SIM_COUNT;
8433*062a843bSAndroid Build Coastguard Worker     #endif
8434*062a843bSAndroid Build Coastguard Worker 
8435*062a843bSAndroid Build Coastguard Worker     s_vendorFunctions = callbacks;
8436*062a843bSAndroid Build Coastguard Worker     s_commands = commands;
8437*062a843bSAndroid Build Coastguard Worker 
8438*062a843bSAndroid Build Coastguard Worker     configureRpcThreadpool(1, true /* callerWillJoin */);
8439*062a843bSAndroid Build Coastguard Worker     for (int i = 0; i < simCount; i++) {
8440*062a843bSAndroid Build Coastguard Worker         pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8441*062a843bSAndroid Build Coastguard Worker         int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8442*062a843bSAndroid Build Coastguard Worker         assert(ret == 0);
8443*062a843bSAndroid Build Coastguard Worker 
8444*062a843bSAndroid Build Coastguard Worker         radioService[i] = new RadioImpl;
8445*062a843bSAndroid Build Coastguard Worker         radioService[i]->mSlotId = i;
8446*062a843bSAndroid Build Coastguard Worker         RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8447*062a843bSAndroid Build Coastguard Worker                 serviceNames[i]);
8448*062a843bSAndroid Build Coastguard Worker         (void) radioService[i]->registerAsService(serviceNames[i]);
8449*062a843bSAndroid Build Coastguard Worker 
8450*062a843bSAndroid Build Coastguard Worker         ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8451*062a843bSAndroid Build Coastguard Worker         assert(ret == 0);
8452*062a843bSAndroid Build Coastguard Worker     }
8453*062a843bSAndroid Build Coastguard Worker }
8454*062a843bSAndroid Build Coastguard Worker 
rilc_thread_pool()8455*062a843bSAndroid Build Coastguard Worker void rilc_thread_pool() {
8456*062a843bSAndroid Build Coastguard Worker     joinRpcThreadpool();
8457*062a843bSAndroid Build Coastguard Worker }
8458*062a843bSAndroid Build Coastguard Worker 
getRadioServiceRwlock(int slotId)8459*062a843bSAndroid Build Coastguard Worker pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8460*062a843bSAndroid Build Coastguard Worker     pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8461*062a843bSAndroid Build Coastguard Worker 
8462*062a843bSAndroid Build Coastguard Worker     #if (SIM_COUNT >= 2)
8463*062a843bSAndroid Build Coastguard Worker     if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8464*062a843bSAndroid Build Coastguard Worker     #if (SIM_COUNT >= 3)
8465*062a843bSAndroid Build Coastguard Worker     if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8466*062a843bSAndroid Build Coastguard Worker     #if (SIM_COUNT >= 4)
8467*062a843bSAndroid Build Coastguard Worker     if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8468*062a843bSAndroid Build Coastguard Worker     #endif
8469*062a843bSAndroid Build Coastguard Worker     #endif
8470*062a843bSAndroid Build Coastguard Worker     #endif
8471*062a843bSAndroid Build Coastguard Worker 
8472*062a843bSAndroid Build Coastguard Worker     return radioServiceRwlockPtr;
8473*062a843bSAndroid Build Coastguard Worker }
8474*062a843bSAndroid Build Coastguard Worker 
8475*062a843bSAndroid Build Coastguard Worker // should acquire write lock for the corresponding service before calling this
setNitzTimeReceived(int slotId,int64_t timeReceived)8476*062a843bSAndroid Build Coastguard Worker void radio::setNitzTimeReceived(int slotId, int64_t timeReceived) {
8477*062a843bSAndroid Build Coastguard Worker     nitzTimeReceived[slotId] = timeReceived;
8478*062a843bSAndroid Build Coastguard Worker }
8479