1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.telephony;
18 
19 import android.content.Context;
20 import android.hardware.radio.V1_0.ActivityStatsInfo;
21 import android.hardware.radio.V1_0.AppStatus;
22 import android.hardware.radio.V1_0.CardStatus;
23 import android.hardware.radio.V1_0.Carrier;
24 import android.hardware.radio.V1_0.CarrierRestrictions;
25 import android.hardware.radio.V1_0.CdmaBroadcastSmsConfigInfo;
26 import android.hardware.radio.V1_0.DataRegStateResult;
27 import android.hardware.radio.V1_0.GsmBroadcastSmsConfigInfo;
28 import android.hardware.radio.V1_0.LastCallFailCauseInfo;
29 import android.hardware.radio.V1_0.LceDataInfo;
30 import android.hardware.radio.V1_0.LceStatusInfo;
31 import android.hardware.radio.V1_0.NeighboringCell;
32 import android.hardware.radio.V1_0.RadioError;
33 import android.hardware.radio.V1_0.RadioResponseInfo;
34 import android.hardware.radio.V1_0.SendSmsResult;
35 import android.hardware.radio.V1_0.VoiceRegStateResult;
36 import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority;
37 import android.hardware.radio.V1_4.SimLockMultiSimPolicy;
38 import android.hardware.radio.V1_5.IRadioResponse;
39 import android.os.AsyncResult;
40 import android.os.Message;
41 import android.os.SystemClock;
42 import android.service.carrier.CarrierIdentifier;
43 import android.telephony.BarringInfo;
44 import android.telephony.CarrierRestrictionRules;
45 import android.telephony.CellInfo;
46 import android.telephony.ModemActivityInfo;
47 import android.telephony.NeighboringCellInfo;
48 import android.telephony.NetworkScanRequest;
49 import android.telephony.PhoneNumberUtils;
50 import android.telephony.RadioAccessFamily;
51 import android.telephony.SignalStrength;
52 import android.telephony.SubscriptionManager;
53 import android.telephony.TelephonyManager;
54 import android.telephony.data.DataCallResponse;
55 import android.text.TextUtils;
56 
57 import com.android.internal.telephony.dataconnection.KeepaliveStatus;
58 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
59 import com.android.internal.telephony.uicc.IccCardApplicationStatus;
60 import com.android.internal.telephony.uicc.IccCardStatus;
61 import com.android.internal.telephony.uicc.IccIoResult;
62 import com.android.internal.telephony.uicc.IccUtils;
63 
64 import java.util.ArrayList;
65 import java.util.Collections;
66 import java.util.List;
67 
68 public class RadioResponse extends IRadioResponse.Stub {
69     // The number of the required config values for broadcast SMS stored in the C struct
70     // RIL_CDMA_BroadcastServiceInfo
71     private static final int CDMA_BSI_NO_OF_INTS_STRUCT = 3;
72 
73     private static final int CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES = 31;
74 
75     RIL mRil;
76 
RadioResponse(RIL ril)77     public RadioResponse(RIL ril) {
78         mRil = ril;
79     }
80 
81     /**
82      * Helper function to send response msg
83      * @param msg Response message to be sent
84      * @param ret Return object to be included in the response message
85      */
sendMessageResponse(Message msg, Object ret)86     static void sendMessageResponse(Message msg, Object ret) {
87         if (msg != null) {
88             AsyncResult.forMessage(msg, ret, null);
89             msg.sendToTarget();
90         }
91     }
92 
93     /**
94      * Acknowledge the receipt of radio request sent to the vendor. This must be sent only for
95      * radio request which take long time to respond.
96      * For more details, refer https://source.android.com/devices/tech/connect/ril.html
97      *
98      * @param serial Serial no. of the request whose acknowledgement is sent.
99      */
acknowledgeRequest(int serial)100     public void acknowledgeRequest(int serial) {
101         mRil.processRequestAck(serial);
102     }
103 
104     /**
105      * @param responseInfo Response info struct containing response type, serial no. and error
106      * @param cardStatus ICC card status as defined by CardStatus in types.hal
107      */
getIccCardStatusResponse(RadioResponseInfo responseInfo, CardStatus cardStatus)108     public void getIccCardStatusResponse(RadioResponseInfo responseInfo, CardStatus cardStatus) {
109         responseIccCardStatus(responseInfo, cardStatus);
110     }
111 
112     /**
113      * @param responseInfo Response info struct containing response type, serial no. and error
114      * @param cardStatus ICC card status as defined by CardStatus in 1.2/types.hal
115      */
getIccCardStatusResponse_1_2(RadioResponseInfo responseInfo, android.hardware.radio.V1_2.CardStatus cardStatus)116     public void getIccCardStatusResponse_1_2(RadioResponseInfo responseInfo,
117                                              android.hardware.radio.V1_2.CardStatus cardStatus) {
118         responseIccCardStatus_1_2(responseInfo, cardStatus);
119     }
120 
121     /**
122      * @param responseInfo Response info struct containing response type, serial no. and error
123      * @param cardStatus ICC card status as defined by CardStatus in 1.4/types.hal
124      */
getIccCardStatusResponse_1_4(RadioResponseInfo responseInfo, android.hardware.radio.V1_4.CardStatus cardStatus)125     public void getIccCardStatusResponse_1_4(RadioResponseInfo responseInfo,
126                                              android.hardware.radio.V1_4.CardStatus cardStatus) {
127         responseIccCardStatus_1_4(responseInfo, cardStatus);
128     }
129 
130     /**
131      * @param responseInfo Response info struct containing response type, serial no. and error
132      * @param cardStatus ICC card status as defined by CardStatus in 1.5/types.hal
133      */
getIccCardStatusResponse_1_5(RadioResponseInfo responseInfo, android.hardware.radio.V1_5.CardStatus cardStatus)134     public void getIccCardStatusResponse_1_5(RadioResponseInfo responseInfo,
135             android.hardware.radio.V1_5.CardStatus cardStatus) {
136         responseIccCardStatus_1_5(responseInfo, cardStatus);
137     }
138 
139     /**
140      * @param responseInfo Response info struct containing response type, serial no. and error
141      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
142      */
supplyIccPinForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts)143     public void supplyIccPinForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
144         responseInts(responseInfo, remainingAttempts);
145     }
146 
147     /**
148      * @param responseInfo Response info struct containing response type, serial no. and error
149      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
150      */
supplyIccPukForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts)151     public void supplyIccPukForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
152         responseInts(responseInfo, remainingAttempts);
153     }
154 
155     /**
156      * @param responseInfo Response info struct containing response type, serial no. and error
157      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
158      */
supplyIccPin2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts)159     public void supplyIccPin2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
160         responseInts(responseInfo, remainingAttempts);
161     }
162 
163     /**
164      * @param responseInfo Response info struct containing response type, serial no. and error
165      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
166      */
supplyIccPuk2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts)167     public void supplyIccPuk2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
168         responseInts(responseInfo, remainingAttempts);
169     }
170 
171     /**
172      * @param responseInfo Response info struct containing response type, serial no. and error
173      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
174      */
changeIccPinForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts)175     public void changeIccPinForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
176         responseInts(responseInfo, remainingAttempts);
177     }
178 
179     /**
180      * @param responseInfo Response info struct containing response type, serial no. and error
181      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
182      */
changeIccPin2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts)183     public void changeIccPin2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
184         responseInts(responseInfo, remainingAttempts);
185     }
186 
187     /**
188      * @param responseInfo Response info struct containing response type, serial no. and error
189      * @param retriesRemaining Number of retries remaining, must be equal to -1 if unknown.
190      */
supplyNetworkDepersonalizationResponse(RadioResponseInfo responseInfo, int retriesRemaining)191     public void supplyNetworkDepersonalizationResponse(RadioResponseInfo responseInfo,
192                                                        int retriesRemaining) {
193         responseInts(responseInfo, retriesRemaining);
194     }
195 
196 
197     /**
198      * @param info Response info struct containing response type, serial no. and error
199      * @param persoType SIM Personalisation type
200      * @param remainingRetries postiive values indicates number of retries remaining,
201      * must be equal to -1 if number of retries is infinite.
202      */
supplySimDepersonalizationResponse(RadioResponseInfo info, int persoType, int remainingRetries)203     public void supplySimDepersonalizationResponse(RadioResponseInfo info,
204             int persoType, int remainingRetries) {
205         responseInts(info, persoType, remainingRetries);
206     }
207 
208     /**
209      * @param responseInfo Response info struct containing response type, serial no. and error
210      * @param calls Current call list
211      */
getCurrentCallsResponse(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.Call> calls)212     public void getCurrentCallsResponse(RadioResponseInfo responseInfo,
213                                         ArrayList<android.hardware.radio.V1_0.Call> calls) {
214         responseCurrentCalls(responseInfo, calls);
215     }
216 
217     /**
218      * @param responseInfo Response info struct containing response type, serial no. and error
219      * @param calls Current call list
220      */
getCurrentCallsResponse_1_2(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_2.Call> calls)221     public void getCurrentCallsResponse_1_2(RadioResponseInfo responseInfo,
222                                         ArrayList<android.hardware.radio.V1_2.Call> calls) {
223         responseCurrentCalls_1_2(responseInfo, calls);
224     }
225 
226     /**
227      * @param responseInfo Response info struct containing response type, serial no. and error
228      */
dialResponse(RadioResponseInfo responseInfo)229     public void dialResponse(RadioResponseInfo responseInfo) {
230         responseVoid(responseInfo);
231     }
232 
233     /**
234      * @param responseInfo Response info struct containing response type, serial no. and error
235      * @param imsi String containing the IMSI
236      */
getIMSIForAppResponse(RadioResponseInfo responseInfo, String imsi)237     public void getIMSIForAppResponse(RadioResponseInfo responseInfo, String imsi) {
238         responseString(responseInfo, imsi);
239     }
240 
241     /**
242      * @param responseInfo Response info struct containing response type, serial no. and error
243      */
hangupConnectionResponse(RadioResponseInfo responseInfo)244     public void hangupConnectionResponse(RadioResponseInfo responseInfo) {
245         responseVoid(responseInfo);
246     }
247 
248     /**
249      * @param responseInfo Response info struct containing response type, serial no. and error
250      */
hangupWaitingOrBackgroundResponse(RadioResponseInfo responseInfo)251     public void hangupWaitingOrBackgroundResponse(RadioResponseInfo responseInfo) {
252         responseVoid(responseInfo);
253     }
254 
255     /**
256      * @param responseInfo Response info struct containing response type, serial no. and error
257      */
hangupForegroundResumeBackgroundResponse(RadioResponseInfo responseInfo)258     public void hangupForegroundResumeBackgroundResponse(RadioResponseInfo responseInfo) {
259         responseVoid(responseInfo);
260     }
261 
262     /**
263      * @param responseInfo Response info struct containing response type, serial no. and error
264      */
switchWaitingOrHoldingAndActiveResponse(RadioResponseInfo responseInfo)265     public void switchWaitingOrHoldingAndActiveResponse(RadioResponseInfo responseInfo) {
266         responseVoid(responseInfo);
267     }
268 
269     /**
270      * @param responseInfo Response info struct containing response type, serial no. and error
271      */
conferenceResponse(RadioResponseInfo responseInfo)272     public void conferenceResponse(RadioResponseInfo responseInfo) {
273         responseVoid(responseInfo);
274     }
275 
276     /**
277      * @param responseInfo Response info struct containing response type, serial no. and error
278      */
rejectCallResponse(RadioResponseInfo responseInfo)279     public void rejectCallResponse(RadioResponseInfo responseInfo) {
280         responseVoid(responseInfo);
281     }
282 
283     /**
284      * @param responseInfo Response info struct containing response type, serial no. and error
285      * @param fcInfo Contains LastCallFailCause and vendor cause code. GSM failure reasons
286      *        are mapped to cause codes defined in TS 24.008 Annex H where possible. CDMA
287      *        failure reasons are derived from the possible call failure scenarios
288      *        described in the "CDMA IS-2000 Release A (C.S0005-A v6.0)" standard.
289      */
getLastCallFailCauseResponse(RadioResponseInfo responseInfo, LastCallFailCauseInfo fcInfo)290     public void getLastCallFailCauseResponse(RadioResponseInfo responseInfo,
291                                              LastCallFailCauseInfo fcInfo) {
292         responseLastCallFailCauseInfo(responseInfo, fcInfo);
293     }
294 
getSignalStrengthResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.SignalStrength sigStrength)295     public void getSignalStrengthResponse(RadioResponseInfo responseInfo,
296                                           android.hardware.radio.V1_0.SignalStrength sigStrength) {
297         responseSignalStrength(responseInfo, sigStrength);
298     }
299 
300     /**
301      * @param responseInfo Response info struct containing response type, serial no. and error
302      * @param signalStrength Current signal strength of camped/connected cells
303      */
getSignalStrengthResponse_1_2( RadioResponseInfo responseInfo, android.hardware.radio.V1_2.SignalStrength signalStrength)304     public void getSignalStrengthResponse_1_2(
305             RadioResponseInfo responseInfo,
306             android.hardware.radio.V1_2.SignalStrength signalStrength) {
307         responseSignalStrength_1_2(responseInfo, signalStrength);
308     }
309      /**
310      * @param responseInfo Response info struct containing response type, serial no. and error
311      * @param signalStrength Current signal strength of camped/connected cells
312      */
getSignalStrengthResponse_1_4( RadioResponseInfo responseInfo, android.hardware.radio.V1_4.SignalStrength signalStrength)313     public void getSignalStrengthResponse_1_4(
314             RadioResponseInfo responseInfo,
315             android.hardware.radio.V1_4.SignalStrength signalStrength) {
316         responseSignalStrength_1_4(responseInfo, signalStrength);
317     }
318 
319     /**
320      * @param responseInfo Response info struct containing response type, serial no. and error
321      * @param voiceRegResponse Current Voice registration response as defined by VoiceRegStateResult
322      *        in types.hal
323      */
getVoiceRegistrationStateResponse(RadioResponseInfo responseInfo, VoiceRegStateResult voiceRegResponse)324     public void getVoiceRegistrationStateResponse(RadioResponseInfo responseInfo,
325                                                   VoiceRegStateResult voiceRegResponse) {
326         RILRequest rr = mRil.processResponse(responseInfo);
327 
328         if (rr != null) {
329             if (responseInfo.error == RadioError.NONE) {
330                 sendMessageResponse(rr.mResult, voiceRegResponse);
331             }
332             mRil.processResponseDone(rr, responseInfo, voiceRegResponse);
333         }
334     }
335 
336     /**
337      * @param responseInfo Response info struct containing response type, serial no. and error
338      * @param voiceRegResponse Current Voice registration response as defined by VoiceRegStateResult
339      *        in 1.2/types.hal
340      */
getVoiceRegistrationStateResponse_1_2(RadioResponseInfo responseInfo, android.hardware.radio.V1_2.VoiceRegStateResult voiceRegResponse)341     public void getVoiceRegistrationStateResponse_1_2(RadioResponseInfo responseInfo,
342             android.hardware.radio.V1_2.VoiceRegStateResult voiceRegResponse) {
343         RILRequest rr = mRil.processResponse(responseInfo);
344 
345         if (rr != null) {
346             if (responseInfo.error == RadioError.NONE) {
347                 sendMessageResponse(rr.mResult, voiceRegResponse);
348             }
349             mRil.processResponseDone(rr, responseInfo, voiceRegResponse);
350         }
351     }
352 
353     /**
354      * @param responseInfo Response info struct containing response type, serial no. and error
355      * @param voiceRegResponse Current Voice registration response as defined by VoiceRegStateResult
356      *        in 1.5/types.hal
357      */
getVoiceRegistrationStateResponse_1_5(RadioResponseInfo responseInfo, android.hardware.radio.V1_5.RegStateResult voiceRegResponse)358     public void getVoiceRegistrationStateResponse_1_5(RadioResponseInfo responseInfo,
359             android.hardware.radio.V1_5.RegStateResult voiceRegResponse) {
360         RILRequest rr = mRil.processResponse(responseInfo);
361         if (rr == null) {
362             return;
363         }
364 
365         if (responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED) {
366             // Move the data needed for fallback call from rr which will be released soon
367             final int request = rr.getRequest();
368             final Message result = rr.getResult();
369 
370             mRil.mRilHandler.post(() -> {
371                 mRil.setCompatVersion(request, RIL.RADIO_HAL_VERSION_1_4);
372                 mRil.getVoiceRegistrationState(result);
373             });
374 
375             mRil.processResponseFallback(rr, responseInfo, voiceRegResponse);
376             return;
377         } else if (responseInfo.error == RadioError.NONE) {
378             sendMessageResponse(rr.mResult, voiceRegResponse);
379         }
380         mRil.processResponseDone(rr, responseInfo, voiceRegResponse);
381     }
382 
383     /**
384      * @param responseInfo Response info struct containing response type, serial no. and error
385      * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
386      *        types.hal
387      */
getDataRegistrationStateResponse(RadioResponseInfo responseInfo, DataRegStateResult dataRegResponse)388     public void getDataRegistrationStateResponse(RadioResponseInfo responseInfo,
389                                                  DataRegStateResult dataRegResponse) {
390         RILRequest rr = mRil.processResponse(responseInfo);
391 
392         if (rr != null) {
393             if (responseInfo.error == RadioError.NONE) {
394                 sendMessageResponse(rr.mResult, dataRegResponse);
395             }
396             mRil.processResponseDone(rr, responseInfo, dataRegResponse);
397         }
398     }
399 
400     /**
401      * @param responseInfo Response info struct containing response type, serial no. and error
402      * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
403      *        1.2/types.hal
404      */
getDataRegistrationStateResponse_1_2(RadioResponseInfo responseInfo, android.hardware.radio.V1_2.DataRegStateResult dataRegResponse)405     public void getDataRegistrationStateResponse_1_2(RadioResponseInfo responseInfo,
406             android.hardware.radio.V1_2.DataRegStateResult dataRegResponse) {
407         RILRequest rr = mRil.processResponse(responseInfo);
408 
409         if (rr != null) {
410             if (responseInfo.error == RadioError.NONE) {
411                 sendMessageResponse(rr.mResult, dataRegResponse);
412             }
413             mRil.processResponseDone(rr, responseInfo, dataRegResponse);
414         }
415     }
416 
417     /**
418      * @param responseInfo Response info struct containing response type, serial no. and error
419      * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
420      *        1.4/types.hal
421      */
getDataRegistrationStateResponse_1_4(RadioResponseInfo responseInfo, android.hardware.radio.V1_4.DataRegStateResult dataRegResponse)422     public void getDataRegistrationStateResponse_1_4(RadioResponseInfo responseInfo,
423             android.hardware.radio.V1_4.DataRegStateResult dataRegResponse) {
424         RILRequest rr = mRil.processResponse(responseInfo);
425 
426         if (rr != null) {
427             if (responseInfo.error == RadioError.NONE) {
428                 sendMessageResponse(rr.mResult, dataRegResponse);
429             }
430             mRil.processResponseDone(rr, responseInfo, dataRegResponse);
431         }
432     }
433 
434     /**
435      * @param responseInfo Response info struct containing response type, serial no. and error
436      * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
437      *        1.5/types.hal
438      */
getDataRegistrationStateResponse_1_5(RadioResponseInfo responseInfo, android.hardware.radio.V1_5.RegStateResult dataRegResponse)439     public void getDataRegistrationStateResponse_1_5(RadioResponseInfo responseInfo,
440             android.hardware.radio.V1_5.RegStateResult dataRegResponse) {
441         RILRequest rr = mRil.processResponse(responseInfo);
442         if (rr == null) {
443             return;
444         }
445 
446         if (responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED) {
447             // Move the data needed for fallback call from rr which will be released soon
448             final int request = rr.getRequest();
449             final Message result = rr.getResult();
450 
451             mRil.mRilHandler.post(() -> {
452                 mRil.setCompatVersion(request, RIL.RADIO_HAL_VERSION_1_4);
453                 mRil.getDataRegistrationState(result);
454             });
455 
456             mRil.processResponseFallback(rr, responseInfo, dataRegResponse);
457             return;
458         } else if (responseInfo.error == RadioError.NONE) {
459             sendMessageResponse(rr.mResult, dataRegResponse);
460         }
461         mRil.processResponseDone(rr, responseInfo, dataRegResponse);
462     }
463 
464     /**
465      * @param responseInfo Response info struct containing response type, serial no. and error
466      * @param longName is long alpha ONS or EONS or empty string if unregistered
467      * @param shortName is short alpha ONS or EONS or empty string if unregistered
468      * @param numeric is 5 or 6 digit numeric code (MCC + MNC) or empty string if unregistered
469      */
getOperatorResponse(RadioResponseInfo responseInfo, String longName, String shortName, String numeric)470     public void getOperatorResponse(RadioResponseInfo responseInfo,
471                                     String longName,
472                                     String shortName,
473                                     String numeric) {
474         responseStrings(responseInfo, longName, shortName, numeric);
475     }
476 
477     /**
478      * @param responseInfo Response info struct containing response type, serial no. and error
479      */
setRadioPowerResponse(RadioResponseInfo responseInfo)480     public void setRadioPowerResponse(RadioResponseInfo responseInfo) {
481         responseVoid(responseInfo);
482     }
483 
484     /**
485      * @param responseInfo Response info struct containing response type, serial no. and error
486      */
sendDtmfResponse(RadioResponseInfo responseInfo)487     public void sendDtmfResponse(RadioResponseInfo responseInfo) {
488         responseVoid(responseInfo);
489     }
490 
491     /**
492      * @param responseInfo Response info struct containing response type, serial no. and error
493      * @param sms Response to sms sent as defined by SendSmsResult in types.hal
494      */
sendSmsResponse(RadioResponseInfo responseInfo, SendSmsResult sms)495     public void sendSmsResponse(RadioResponseInfo responseInfo,
496                                 SendSmsResult sms) {
497         responseSms(responseInfo, sms);
498     }
499 
500     /**
501      * @param responseInfo Response info struct containing response type, serial no. and error
502      * @param sms Response to sms sent as defined by SendSmsResult in types.hal
503      */
sendSMSExpectMoreResponse(RadioResponseInfo responseInfo, SendSmsResult sms)504     public void sendSMSExpectMoreResponse(RadioResponseInfo responseInfo,
505                                           SendSmsResult sms) {
506         responseSms(responseInfo, sms);
507     }
508 
509     /**
510      * @param responseInfo Response info struct containing response type, serial no. and error
511      * @param setupDataCallResult Response to data call setup as defined by setupDataCallResult in
512      *                            types.hal
513      */
setupDataCallResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.SetupDataCallResult setupDataCallResult)514     public void setupDataCallResponse(RadioResponseInfo responseInfo,
515             android.hardware.radio.V1_0.SetupDataCallResult setupDataCallResult) {
516         responseSetupDataCall(responseInfo, setupDataCallResult);
517     }
518 
519     /**
520      * @param responseInfo Response info struct containing response type, serial no. and error
521      * @param setupDataCallResult Response to data call setup as defined by setupDataCallResult in
522      *                            1.4/types.hal
523      */
setupDataCallResponse_1_4(RadioResponseInfo responseInfo, android.hardware.radio.V1_4.SetupDataCallResult setupDataCallResult)524     public void setupDataCallResponse_1_4(RadioResponseInfo responseInfo,
525             android.hardware.radio.V1_4.SetupDataCallResult setupDataCallResult) {
526         responseSetupDataCall(responseInfo, setupDataCallResult);
527     }
528 
529     /**
530      * @param responseInfo Response info struct containing response type, serial no. and error
531      * @param setupDataCallResult Response to data call setup as defined by setupDataCallResult in
532      *                            1.5/types.hal
533      */
setupDataCallResponse_1_5(RadioResponseInfo responseInfo, android.hardware.radio.V1_5.SetupDataCallResult setupDataCallResult)534     public void setupDataCallResponse_1_5(RadioResponseInfo responseInfo,
535             android.hardware.radio.V1_5.SetupDataCallResult setupDataCallResult) {
536         responseSetupDataCall(responseInfo, setupDataCallResult);
537     }
538 
539     /**
540      * @param responseInfo Response info struct containing response type, serial no. and error
541      * @param iccIo ICC io operation response as defined by IccIoResult in types.hal
542      */
iccIOForAppResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.IccIoResult iccIo)543     public void iccIOForAppResponse(RadioResponseInfo responseInfo,
544                             android.hardware.radio.V1_0.IccIoResult iccIo) {
545         responseIccIo(responseInfo, iccIo);
546     }
547 
548     /**
549      * @param responseInfo Response info struct containing response type, serial no. and error
550      */
sendUssdResponse(RadioResponseInfo responseInfo)551     public void sendUssdResponse(RadioResponseInfo responseInfo) {
552         responseVoid(responseInfo);
553     }
554 
555     /**
556      * @param responseInfo Response info struct containing response type, serial no. and error
557      */
cancelPendingUssdResponse(RadioResponseInfo responseInfo)558     public void cancelPendingUssdResponse(RadioResponseInfo responseInfo) {
559         responseVoid(responseInfo);
560     }
561 
562     /**
563      * @param responseInfo Response info struct containing response type, serial no. and error
564      * @param n is "n" parameter from TS 27.007 7.7
565      * @param m is "m" parameter from TS 27.007 7.7
566      */
getClirResponse(RadioResponseInfo responseInfo, int n, int m)567     public void getClirResponse(RadioResponseInfo responseInfo, int n, int m) {
568         responseInts(responseInfo, n, m);
569     }
570 
571     /**
572      * @param responseInfo Response info struct containing response type, serial no. and error
573      */
setClirResponse(RadioResponseInfo responseInfo)574     public void setClirResponse(RadioResponseInfo responseInfo) {
575         responseVoid(responseInfo);
576     }
577 
578     /**
579      * @param responseInfo Response info struct containing response type, serial no. and error
580      * @param callForwardInfos points to a vector of CallForwardInfo, one for
581      *        each distinct registered phone number.
582      */
getCallForwardStatusResponse(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.CallForwardInfo> callForwardInfos)583     public void getCallForwardStatusResponse(RadioResponseInfo responseInfo,
584                                              ArrayList<android.hardware.radio.V1_0.CallForwardInfo>
585                                                      callForwardInfos) {
586         responseCallForwardInfo(responseInfo, callForwardInfos);
587     }
588 
589     /**
590      * @param responseInfo Response info struct containing response type, serial no. and error
591      */
setCallForwardResponse(RadioResponseInfo responseInfo)592     public void setCallForwardResponse(RadioResponseInfo responseInfo) {
593         responseVoid(responseInfo);
594     }
595 
596     /**
597      * @param responseInfo Response info struct containing response type, serial no. and error
598      * @param enable If current call waiting state is disabled, enable = false else true
599      * @param serviceClass If enable, then callWaitingResp[1]
600      *        must follow, with the TS 27.007 service class bit vector of services
601      *        for which call waiting is enabled.
602      *        For example, if callWaitingResp[0] is 1 and
603      *        callWaitingResp[1] is 3, then call waiting is enabled for data
604      *        and voice and disabled for everything else.
605      */
getCallWaitingResponse(RadioResponseInfo responseInfo, boolean enable, int serviceClass)606     public void getCallWaitingResponse(RadioResponseInfo responseInfo,
607                                    boolean enable,
608                                    int serviceClass) {
609         responseInts(responseInfo, enable ? 1 : 0, serviceClass);
610     }
611 
612     /**
613      * @param responseInfo Response info struct containing response type, serial no. and error
614      */
setCallWaitingResponse(RadioResponseInfo responseInfo)615     public void setCallWaitingResponse(RadioResponseInfo responseInfo) {
616         responseVoid(responseInfo);
617     }
618 
619     /**
620      * @param responseInfo Response info struct containing response type, serial no. and error
621      */
acknowledgeLastIncomingGsmSmsResponse(RadioResponseInfo responseInfo)622     public void acknowledgeLastIncomingGsmSmsResponse(RadioResponseInfo responseInfo) {
623         responseVoid(responseInfo);
624     }
625 
626     /**
627      * @param responseInfo Response info struct containing response type, serial no. and error
628      */
acceptCallResponse(RadioResponseInfo responseInfo)629     public void acceptCallResponse(RadioResponseInfo responseInfo) {
630         responseVoid(responseInfo);
631     }
632 
633     /**
634      * @param responseInfo Response info struct containing response type, serial no. and error
635      */
deactivateDataCallResponse(RadioResponseInfo responseInfo)636     public void deactivateDataCallResponse(RadioResponseInfo responseInfo) {
637         responseVoid(responseInfo);
638     }
639 
640     /**
641      *
642      * @param responseInfo Response info struct containing response type, serial no. and error
643      * @param response 0 is the TS 27.007 service class bit vector of
644      *        services for which the specified barring facility
645      *        is active. "0" means "disabled for all"
646      */
getFacilityLockForAppResponse(RadioResponseInfo responseInfo, int response)647     public void getFacilityLockForAppResponse(RadioResponseInfo responseInfo, int response) {
648         responseInts(responseInfo, response);
649     }
650 
651     /**
652      *
653      * @param responseInfo Response info struct containing response type, serial no. and error
654      * @param retry 0 is the number of retries remaining, or -1 if unknown
655      */
setFacilityLockForAppResponse(RadioResponseInfo responseInfo, int retry)656     public void setFacilityLockForAppResponse(RadioResponseInfo responseInfo, int retry) {
657         responseInts(responseInfo, retry);
658     }
659 
660     /**
661      * @param responseInfo Response info struct containing response type, serial no. and error
662      */
setBarringPasswordResponse(RadioResponseInfo responseInfo)663     public void setBarringPasswordResponse(RadioResponseInfo responseInfo) {
664         responseVoid(responseInfo);
665     }
666 
667     /**
668      *
669      * @param responseInfo Response info struct containing response type, serial no. and error
670      * @param selection false for automatic selection, true for manual selection
671      */
getNetworkSelectionModeResponse(RadioResponseInfo responseInfo, boolean selection)672     public void getNetworkSelectionModeResponse(RadioResponseInfo responseInfo, boolean selection) {
673         responseInts(responseInfo, selection ? 1 : 0);
674     }
675 
676     /**
677      * @param responseInfo Response info struct containing response type, serial no. and error
678      */
setNetworkSelectionModeAutomaticResponse(RadioResponseInfo responseInfo)679     public void setNetworkSelectionModeAutomaticResponse(RadioResponseInfo responseInfo) {
680         responseVoid(responseInfo);
681     }
682 
683     /**
684      * @param responseInfo Response info struct containing response type, serial no. and error
685      */
setNetworkSelectionModeManualResponse(RadioResponseInfo responseInfo)686     public void setNetworkSelectionModeManualResponse(RadioResponseInfo responseInfo) {
687         responseVoid(responseInfo);
688     }
689 
690     /**
691      * @param responseInfo Response info struct containing response type, serial no. and error
692      */
setNetworkSelectionModeManualResponse_1_5(RadioResponseInfo responseInfo)693     public void setNetworkSelectionModeManualResponse_1_5(RadioResponseInfo responseInfo) {
694         responseVoid(responseInfo);
695     }
696 
697     /**
698      *
699      * @param responseInfo Response info struct containing response type, serial no. and error
700      * @param networkInfos List of network operator information as OperatorInfos defined in
701      *                     types.hal
702      */
getAvailableNetworksResponse(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.OperatorInfo> networkInfos)703     public void getAvailableNetworksResponse(RadioResponseInfo responseInfo,
704                                              ArrayList<android.hardware.radio.V1_0.OperatorInfo>
705                                                      networkInfos) {
706         responseOperatorInfos(responseInfo, networkInfos);
707     }
708 
709     /**
710      *
711      * @param responseInfo Response info struct containing response type, serial no. and error
712      */
startNetworkScanResponse(RadioResponseInfo responseInfo)713     public void startNetworkScanResponse(RadioResponseInfo responseInfo) {
714         responseScanStatus(responseInfo, null /*fallbackHalVersion*/);
715     }
716 
717     /**
718      * The same method as startNetworkScanResponse, except disallowing error codes
719      * OPERATION_NOT_ALLOWED.
720      *
721      * @param responseInfo Response info struct containing response type, serial no. and error
722      */
startNetworkScanResponse_1_4(RadioResponseInfo responseInfo)723     public void startNetworkScanResponse_1_4(RadioResponseInfo responseInfo) {
724         responseScanStatus(responseInfo, null /*fallbackHalVersion*/);
725     }
726 
727     /**
728      * The same method as startNetworkScanResponse_1_4.
729      *
730      * @param responseInfo Response info struct containing response type, serial no. and error
731      */
startNetworkScanResponse_1_5(RadioResponseInfo responseInfo)732     public void startNetworkScanResponse_1_5(RadioResponseInfo responseInfo) {
733         responseScanStatus(responseInfo, RIL.RADIO_HAL_VERSION_1_4);
734     }
735 
736     /**
737      *
738      * @param responseInfo Response info struct containing response type, serial no. and error
739      */
stopNetworkScanResponse(RadioResponseInfo responseInfo)740     public void stopNetworkScanResponse(RadioResponseInfo responseInfo) {
741         responseScanStatus(responseInfo, null /*fallbackHalVersion*/);
742     }
743 
744     /**
745      * @param responseInfo Response info struct containing response type, serial no. and error
746      */
startDtmfResponse(RadioResponseInfo responseInfo)747     public void startDtmfResponse(RadioResponseInfo responseInfo) {
748         responseVoid(responseInfo);
749     }
750 
751     /**
752      * @param responseInfo Response info struct containing response type, serial no. and error
753      */
stopDtmfResponse(RadioResponseInfo responseInfo)754     public void stopDtmfResponse(RadioResponseInfo responseInfo) {
755         responseVoid(responseInfo);
756     }
757 
758     /**
759      *
760      * @param responseInfo Response info struct containing response type, serial no. and error
761      * @param version string containing version string for log reporting
762      */
getBasebandVersionResponse(RadioResponseInfo responseInfo, String version)763     public void getBasebandVersionResponse(RadioResponseInfo responseInfo, String version) {
764         responseString(responseInfo, version);
765     }
766 
767     /**
768      * @param responseInfo Response info struct containing response type, serial no. and error
769      */
separateConnectionResponse(RadioResponseInfo responseInfo)770     public void separateConnectionResponse(RadioResponseInfo responseInfo) {
771         responseVoid(responseInfo);
772     }
773 
774     /**
775      * @param responseInfo Response info struct containing response type, serial no. and error
776      */
setMuteResponse(RadioResponseInfo responseInfo)777     public void setMuteResponse(RadioResponseInfo responseInfo) {
778         responseVoid(responseInfo);
779     }
780 
781     /**
782      *
783      * @param responseInfo Response info struct containing response type, serial no. and error
784      * @param enable true for "mute enabled" and false for "mute disabled"
785      */
getMuteResponse(RadioResponseInfo responseInfo, boolean enable)786     public void getMuteResponse(RadioResponseInfo responseInfo, boolean enable) {
787         responseInts(responseInfo, enable ? 1 : 0);
788     }
789 
790     /**
791      *
792      * @param responseInfo Response info struct containing response type, serial no. and error
793      * @param status indicates CLIP status
794      */
getClipResponse(RadioResponseInfo responseInfo, int status)795     public void getClipResponse(RadioResponseInfo responseInfo, int status) {
796         responseInts(responseInfo, status);
797     }
798 
799     /**
800      * @param responseInfo Response info struct containing response type, serial no. and error
801      * @param dataCallResultList Response to get data call list as defined by setupDataCallResult in
802      *                           types.hal
803      */
getDataCallListResponse(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.SetupDataCallResult> dataCallResultList)804     public void getDataCallListResponse(RadioResponseInfo responseInfo,
805             ArrayList<android.hardware.radio.V1_0.SetupDataCallResult> dataCallResultList) {
806         responseDataCallList(responseInfo, dataCallResultList);
807     }
808 
809     /**
810      * @param responseInfo Response info struct containing response type, serial no. and error
811      * @param dataCallResultList Response to get data call list as defined by setupDataCallResult in
812      *                           1.4/types.hal
813      */
getDataCallListResponse_1_4(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_4.SetupDataCallResult> dataCallResultList)814     public void getDataCallListResponse_1_4(RadioResponseInfo responseInfo,
815             ArrayList<android.hardware.radio.V1_4.SetupDataCallResult> dataCallResultList) {
816         responseDataCallList(responseInfo, dataCallResultList);
817     }
818 
819     /**
820      * @param responseInfo Response info struct containing response type, serial no. and error
821      * @param dataCallResultList Response to get data call list as defined by setupDataCallResult in
822      *                           1.5/types.hal
823      */
getDataCallListResponse_1_5(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_5.SetupDataCallResult> dataCallResultList)824     public void getDataCallListResponse_1_5(RadioResponseInfo responseInfo,
825             ArrayList<android.hardware.radio.V1_5.SetupDataCallResult> dataCallResultList) {
826         responseDataCallList(responseInfo, dataCallResultList);
827     }
828 
sendOemRilRequestRawResponse(RadioResponseInfo responseInfo, ArrayList<Byte> var2)829     public void sendOemRilRequestRawResponse(RadioResponseInfo responseInfo,
830                                              ArrayList<Byte> var2) {}
831 
832     /**
833      * @param responseInfo Response info struct containing response type, serial no. and error
834      */
setSuppServiceNotificationsResponse(RadioResponseInfo responseInfo)835     public void setSuppServiceNotificationsResponse(RadioResponseInfo responseInfo) {
836         responseVoid(responseInfo);
837     }
838 
839     /**
840      * @param responseInfo Response info struct containing response type, serial no. and error
841      * @param index record index where the message is stored
842      */
writeSmsToSimResponse(RadioResponseInfo responseInfo, int index)843     public void writeSmsToSimResponse(RadioResponseInfo responseInfo, int index) {
844         responseInts(responseInfo, index);
845     }
846 
847     /**
848      * @param responseInfo Response info struct containing response type, serial no. and error
849      */
deleteSmsOnSimResponse(RadioResponseInfo responseInfo)850     public void deleteSmsOnSimResponse(RadioResponseInfo responseInfo) {
851         responseVoid(responseInfo);
852     }
853 
854     /**
855      * @param responseInfo Response info struct containing response type, serial no. and error
856      */
setBandModeResponse(RadioResponseInfo responseInfo)857     public void setBandModeResponse(RadioResponseInfo responseInfo) {
858         responseVoid(responseInfo);
859     }
860 
861     /**
862      *
863      * @param responseInfo Response info struct containing response type, serial no. and error
864      * @param bandModes List of RadioBandMode listing supported modes
865      */
getAvailableBandModesResponse(RadioResponseInfo responseInfo, ArrayList<Integer> bandModes)866     public void getAvailableBandModesResponse(RadioResponseInfo responseInfo,
867                                               ArrayList<Integer> bandModes) {
868         responseIntArrayList(responseInfo, bandModes);
869     }
870 
871     /**
872      *
873      * @param responseInfo Response info struct containing response type, serial no. and error
874      * @param commandResponse SAT/USAT response in hexadecimal format
875      *        string starting with first byte of response
876      */
sendEnvelopeResponse(RadioResponseInfo responseInfo, String commandResponse)877     public void sendEnvelopeResponse(RadioResponseInfo responseInfo, String commandResponse) {
878         responseString(responseInfo, commandResponse);
879     }
880 
881     /**
882      * @param responseInfo Response info struct containing response type, serial no. and error
883      */
sendTerminalResponseToSimResponse(RadioResponseInfo responseInfo)884     public void sendTerminalResponseToSimResponse(RadioResponseInfo responseInfo) {
885         responseVoid(responseInfo);
886     }
887 
888     /**
889      * @param responseInfo Response info struct containing response type, serial no. and error
890      */
handleStkCallSetupRequestFromSimResponse(RadioResponseInfo responseInfo)891     public void handleStkCallSetupRequestFromSimResponse(RadioResponseInfo responseInfo) {
892         responseVoid(responseInfo);
893     }
894 
895     /**
896      * @param responseInfo Response info struct containing response type, serial no. and error
897      */
explicitCallTransferResponse(RadioResponseInfo responseInfo)898     public void explicitCallTransferResponse(RadioResponseInfo responseInfo) {
899         responseVoid(responseInfo);
900     }
901 
902     /**
903      * @param responseInfo Response info struct containing response type, serial no. and error
904      */
setPreferredNetworkTypeResponse(RadioResponseInfo responseInfo)905     public void setPreferredNetworkTypeResponse(RadioResponseInfo responseInfo) {
906         responseVoid(responseInfo);
907     }
908 
909     /**
910      * Callback of setPreferredNetworkTypeBitmap defined in IRadio.hal.
911      * @param responseInfo Response info struct containing response type, serial no. and error
912      */
setPreferredNetworkTypeBitmapResponse(RadioResponseInfo responseInfo)913     public void setPreferredNetworkTypeBitmapResponse(RadioResponseInfo responseInfo) {
914         responseVoid(responseInfo);
915     }
916 
917     /**
918      *
919      * @param responseInfo Response info struct containing response type, serial no. and error
920      * @param nwType RadioPreferredNetworkType defined in types.hal
921      */
getPreferredNetworkTypeResponse(RadioResponseInfo responseInfo, int nwType)922     public void getPreferredNetworkTypeResponse(RadioResponseInfo responseInfo, int nwType) {
923         mRil.mPreferredNetworkType = nwType;
924         responseInts(responseInfo, nwType);
925     }
926 
927     /**
928      * Callback of the getPreferredNetworkTypeBitmap defined in the IRadio.hal.
929      * @param responseInfo Response info struct containing response type, serial no. and error
930      * @param halRadioAccessFamilyBitmap a 32-bit bitmap of
931      * {@link android.hardware.radio.V1_0.RadioAccessFamily}.
932      */
getPreferredNetworkTypeBitmapResponse( RadioResponseInfo responseInfo, int halRadioAccessFamilyBitmap)933     public void getPreferredNetworkTypeBitmapResponse(
934             RadioResponseInfo responseInfo, int halRadioAccessFamilyBitmap) {
935 
936         int networkType = RadioAccessFamily.getNetworkTypeFromRaf(
937                 RIL.convertToNetworkTypeBitMask(halRadioAccessFamilyBitmap));
938         mRil.mPreferredNetworkType = networkType;
939         responseInts(responseInfo, networkType);
940     }
941 
942     /**
943      *
944      * @param responseInfo Response info struct containing response type, serial no. and error
945      * @param cells Vector of neighboring radio cell information
946      */
getNeighboringCidsResponse(RadioResponseInfo responseInfo, ArrayList<NeighboringCell> cells)947     public void getNeighboringCidsResponse(RadioResponseInfo responseInfo,
948                                            ArrayList<NeighboringCell> cells) {
949         responseCellList(responseInfo, cells);
950     }
951 
952     /**
953      * @param responseInfo Response info struct containing response type, serial no. and error
954      */
setLocationUpdatesResponse(RadioResponseInfo responseInfo)955     public void setLocationUpdatesResponse(RadioResponseInfo responseInfo) {
956         responseVoid(responseInfo);
957     }
958 
959     /**
960      * @param responseInfo Response info struct containing response type, serial no. and error
961      */
setCdmaSubscriptionSourceResponse(RadioResponseInfo responseInfo)962     public void setCdmaSubscriptionSourceResponse(RadioResponseInfo responseInfo) {
963         responseVoid(responseInfo);
964     }
965 
966     /**
967      * @param responseInfo Response info struct containing response type, serial no. and error
968      */
setCdmaRoamingPreferenceResponse(RadioResponseInfo responseInfo)969     public void setCdmaRoamingPreferenceResponse(RadioResponseInfo responseInfo) {
970         responseVoid(responseInfo);
971     }
972 
973     /**
974      *
975      * @param responseInfo Response info struct containing response type, serial no. and error
976      * @param type CdmaRoamingType defined in types.hal
977      */
getCdmaRoamingPreferenceResponse(RadioResponseInfo responseInfo, int type)978     public void getCdmaRoamingPreferenceResponse(RadioResponseInfo responseInfo, int type) {
979         responseInts(responseInfo, type);
980     }
981 
982     /**
983      * @param responseInfo Response info struct containing response type, serial no. and error
984      */
setTTYModeResponse(RadioResponseInfo responseInfo)985     public void setTTYModeResponse(RadioResponseInfo responseInfo) {
986         responseVoid(responseInfo);
987     }
988 
989     /**
990      *
991      * @param responseInfo Response info struct containing response type, serial no. and error
992      * @param mode TTY mode
993      */
getTTYModeResponse(RadioResponseInfo responseInfo, int mode)994     public void getTTYModeResponse(RadioResponseInfo responseInfo, int mode) {
995         responseInts(responseInfo, mode);
996     }
997 
998     /**
999      * @param responseInfo Response info struct containing response type, serial no. and error
1000      */
setPreferredVoicePrivacyResponse(RadioResponseInfo responseInfo)1001     public void setPreferredVoicePrivacyResponse(RadioResponseInfo responseInfo) {
1002         responseVoid(responseInfo);
1003     }
1004 
1005     /**
1006      *
1007      * @param responseInfo Response info struct containing response type, serial no. and error
1008      * @param enable false for Standard Privacy Mode (Public Long Code Mask)
1009      *        true for Enhanced Privacy Mode (Private Long Code Mask)
1010      */
getPreferredVoicePrivacyResponse(RadioResponseInfo responseInfo, boolean enable)1011     public void getPreferredVoicePrivacyResponse(RadioResponseInfo responseInfo,
1012                                                  boolean enable) {
1013         responseInts(responseInfo, enable ? 1 : 0);
1014     }
1015 
1016     /**
1017      * @param responseInfo Response info struct containing response type, serial no. and error
1018      */
sendCDMAFeatureCodeResponse(RadioResponseInfo responseInfo)1019     public void sendCDMAFeatureCodeResponse(RadioResponseInfo responseInfo) {
1020         responseVoid(responseInfo);
1021     }
1022 
1023     /**
1024      * @param responseInfo Response info struct containing response type, serial no. and error
1025      */
sendBurstDtmfResponse(RadioResponseInfo responseInfo)1026     public void sendBurstDtmfResponse(RadioResponseInfo responseInfo) {
1027         responseVoid(responseInfo);
1028     }
1029 
1030     /**
1031      *
1032      * @param responseInfo Response info struct containing response type, serial no. and error
1033      * @param sms Sms result struct as defined by SendSmsResult in types.hal
1034      */
sendCdmaSmsResponse(RadioResponseInfo responseInfo, SendSmsResult sms)1035     public void sendCdmaSmsResponse(RadioResponseInfo responseInfo, SendSmsResult sms) {
1036         responseSms(responseInfo, sms);
1037     }
1038 
1039     /**
1040      *
1041      * @param responseInfo Response info struct containing response type, serial no. and error
1042      * @param sms Sms result struct as defined by SendSmsResult in types.hal
1043      */
sendCdmaSMSExpectMoreResponse(RadioResponseInfo responseInfo, SendSmsResult sms)1044     public void sendCdmaSMSExpectMoreResponse(RadioResponseInfo responseInfo, SendSmsResult sms) {
1045         responseSms(responseInfo, sms);
1046     }
1047 
1048     /**
1049      * @param responseInfo Response info struct containing response type, serial no. and error
1050      */
acknowledgeLastIncomingCdmaSmsResponse(RadioResponseInfo responseInfo)1051     public void acknowledgeLastIncomingCdmaSmsResponse(RadioResponseInfo responseInfo) {
1052         responseVoid(responseInfo);
1053     }
1054 
1055     /**
1056      *
1057      * @param responseInfo Response info struct containing response type, serial no. and error
1058      * @param configs Vector of GSM/WCDMA Cell broadcast configs
1059      */
getGsmBroadcastConfigResponse(RadioResponseInfo responseInfo, ArrayList<GsmBroadcastSmsConfigInfo> configs)1060     public void getGsmBroadcastConfigResponse(RadioResponseInfo responseInfo,
1061                                               ArrayList<GsmBroadcastSmsConfigInfo> configs) {
1062         responseGmsBroadcastConfig(responseInfo, configs);
1063     }
1064 
1065     /**
1066      * @param responseInfo Response info struct containing response type, serial no. and error
1067      */
setGsmBroadcastConfigResponse(RadioResponseInfo responseInfo)1068     public void setGsmBroadcastConfigResponse(RadioResponseInfo responseInfo) {
1069         responseVoid(responseInfo);
1070     }
1071 
1072     /**
1073      * @param responseInfo Response info struct containing response type, serial no. and error
1074      */
setGsmBroadcastActivationResponse(RadioResponseInfo responseInfo)1075     public void setGsmBroadcastActivationResponse(RadioResponseInfo responseInfo) {
1076         responseVoid(responseInfo);
1077     }
1078 
1079     /**
1080      *
1081      * @param responseInfo Response info struct containing response type, serial no. and error
1082      * @param configs Vector of CDMA Broadcast SMS configs.
1083      */
getCdmaBroadcastConfigResponse(RadioResponseInfo responseInfo, ArrayList<CdmaBroadcastSmsConfigInfo> configs)1084     public void getCdmaBroadcastConfigResponse(RadioResponseInfo responseInfo,
1085                                                ArrayList<CdmaBroadcastSmsConfigInfo> configs) {
1086         responseCdmaBroadcastConfig(responseInfo, configs);
1087     }
1088 
1089     /**
1090      * @param responseInfo Response info struct containing response type, serial no. and error
1091      */
setCdmaBroadcastConfigResponse(RadioResponseInfo responseInfo)1092     public void setCdmaBroadcastConfigResponse(RadioResponseInfo responseInfo) {
1093         responseVoid(responseInfo);
1094     }
1095 
1096     /**
1097      * @param responseInfo Response info struct containing response type, serial no. and error
1098      */
setCdmaBroadcastActivationResponse(RadioResponseInfo responseInfo)1099     public void setCdmaBroadcastActivationResponse(RadioResponseInfo responseInfo) {
1100         responseVoid(responseInfo);
1101     }
1102 
1103     /**
1104      *
1105      * @param responseInfo Response info struct containing response type, serial no. and error
1106      * @param mdn MDN if CDMA subscription is available
1107      * @param hSid is a comma separated list of H_SID (Home SID) if
1108      *        CDMA subscription is available, in decimal format
1109      * @param hNid is a comma separated list of H_NID (Home NID) if
1110      *        CDMA subscription is available, in decimal format
1111      * @param min MIN (10 digits, MIN2+MIN1) if CDMA subscription is available
1112      * @param prl PRL version if CDMA subscription is available
1113      */
getCDMASubscriptionResponse(RadioResponseInfo responseInfo, String mdn, String hSid, String hNid, String min, String prl)1114     public void getCDMASubscriptionResponse(RadioResponseInfo responseInfo, String mdn,
1115                                             String hSid, String hNid, String min, String prl) {
1116         responseStrings(responseInfo, mdn, hSid, hNid, min, prl);
1117     }
1118 
1119     /**
1120      *
1121      * @param responseInfo Response info struct containing response type, serial no. and error
1122      * @param index record index where the cmda sms message is stored
1123      */
writeSmsToRuimResponse(RadioResponseInfo responseInfo, int index)1124     public void writeSmsToRuimResponse(RadioResponseInfo responseInfo, int index) {
1125         responseInts(responseInfo, index);
1126     }
1127 
1128     /**
1129      * @param responseInfo Response info struct containing response type, serial no. and error
1130      */
deleteSmsOnRuimResponse(RadioResponseInfo responseInfo)1131     public void deleteSmsOnRuimResponse(RadioResponseInfo responseInfo) {
1132         responseVoid(responseInfo);
1133     }
1134 
1135     /**
1136      * @param responseInfo Response info struct containing response type, serial no. and error
1137      * @param imei IMEI if GSM subscription is available
1138      * @param imeisv IMEISV if GSM subscription is available
1139      * @param esn ESN if CDMA subscription is available
1140      * @param meid MEID if CDMA subscription is available
1141      */
getDeviceIdentityResponse(RadioResponseInfo responseInfo, String imei, String imeisv, String esn, String meid)1142     public void getDeviceIdentityResponse(RadioResponseInfo responseInfo, String imei,
1143                                           String imeisv, String esn, String meid) {
1144         responseStrings(responseInfo, imei, imeisv, esn, meid);
1145     }
1146 
1147     /**
1148      * @param responseInfo Response info struct containing response type, serial no. and error
1149      */
exitEmergencyCallbackModeResponse(RadioResponseInfo responseInfo)1150     public void exitEmergencyCallbackModeResponse(RadioResponseInfo responseInfo) {
1151         responseVoid(responseInfo);
1152     }
1153 
1154     /**
1155      * @param responseInfo Response info struct containing response type, serial no. and error
1156      * @param smsc Short Message Service Center address on the device
1157      */
getSmscAddressResponse(RadioResponseInfo responseInfo, String smsc)1158     public void getSmscAddressResponse(RadioResponseInfo responseInfo, String smsc) {
1159         responseString(responseInfo, smsc);
1160     }
1161 
1162     /**
1163      * @param responseInfo Response info struct containing response type, serial no. and error
1164      */
setSmscAddressResponse(RadioResponseInfo responseInfo)1165     public void setSmscAddressResponse(RadioResponseInfo responseInfo) {
1166         responseVoid(responseInfo);
1167     }
1168 
1169     /**
1170      * @param responseInfo Response info struct containing response type, serial no. and error
1171      */
reportSmsMemoryStatusResponse(RadioResponseInfo responseInfo)1172     public void reportSmsMemoryStatusResponse(RadioResponseInfo responseInfo) {
1173         responseVoid(responseInfo);
1174     }
1175 
1176     /**
1177      * @param responseInfo Response info struct containing response type, serial no. and error
1178      */
reportStkServiceIsRunningResponse(RadioResponseInfo responseInfo)1179     public void reportStkServiceIsRunningResponse(RadioResponseInfo responseInfo) {
1180         responseVoid(responseInfo);
1181     }
1182 
1183     /**
1184      *
1185      * @param responseInfo Response info struct containing response type, serial no. and error
1186      * @param source CDMA subscription source
1187      */
getCdmaSubscriptionSourceResponse(RadioResponseInfo responseInfo, int source)1188     public void getCdmaSubscriptionSourceResponse(RadioResponseInfo responseInfo, int source) {
1189         responseInts(responseInfo, source);
1190     }
1191 
1192     /**
1193      * This method is deprecated and should not be used.
1194      *
1195      * @param responseInfo Response info struct containing response type, serial no. and error
1196      * @param response response string of the challenge/response algo for ISIM auth in base64 format
1197      */
requestIsimAuthenticationResponse(RadioResponseInfo responseInfo, String response)1198     public void requestIsimAuthenticationResponse(RadioResponseInfo responseInfo, String response) {
1199         throw new RuntimeException("Inexplicable response received for requestIsimAuthentication");
1200     }
1201 
1202     /**
1203      * @param responseInfo Response info struct containing response type, serial no. and error
1204      */
acknowledgeIncomingGsmSmsWithPduResponse(RadioResponseInfo responseInfo)1205     public void acknowledgeIncomingGsmSmsWithPduResponse(RadioResponseInfo responseInfo) {
1206         responseVoid(responseInfo);
1207     }
1208 
1209     /**
1210      *
1211      * @param responseInfo Response info struct containing response type, serial no. and error
1212      * @param iccIo IccIoResult as defined in types.hal corresponding to ICC IO response
1213      */
sendEnvelopeWithStatusResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.IccIoResult iccIo)1214     public void sendEnvelopeWithStatusResponse(RadioResponseInfo responseInfo,
1215                                                android.hardware.radio.V1_0.IccIoResult iccIo) {
1216         responseIccIo(responseInfo, iccIo);
1217     }
1218 
1219     /**
1220      *
1221      * @param responseInfo Response info struct containing response type, serial no. and error
1222      * @param rat Current voice RAT
1223      */
getVoiceRadioTechnologyResponse(RadioResponseInfo responseInfo, int rat)1224     public void getVoiceRadioTechnologyResponse(RadioResponseInfo responseInfo, int rat) {
1225         responseInts(responseInfo, rat);
1226     }
1227 
getCellInfoListResponse(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.CellInfo> cellInfo)1228     public void getCellInfoListResponse(RadioResponseInfo responseInfo,
1229                                         ArrayList<android.hardware.radio.V1_0.CellInfo> cellInfo) {
1230         responseCellInfoList(responseInfo, cellInfo);
1231     }
1232 
1233     /**
1234      * @param responseInfo Response info struct containing response type, serial no. and error
1235      * @param cellInfo List of current cell information known to radio
1236      */
getCellInfoListResponse_1_2( RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_2.CellInfo> cellInfo)1237     public void getCellInfoListResponse_1_2(
1238             RadioResponseInfo responseInfo,
1239             ArrayList<android.hardware.radio.V1_2.CellInfo> cellInfo) {
1240         responseCellInfoList_1_2(responseInfo, cellInfo);
1241     }
1242 
1243     /**
1244      * @param responseInfo Response info struct containing response type, serial no. and error.
1245      * @param cellInfo List of current cell information known to radio.
1246      */
getCellInfoListResponse_1_4( RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_4.CellInfo> cellInfo)1247     public void getCellInfoListResponse_1_4(
1248             RadioResponseInfo responseInfo,
1249             ArrayList<android.hardware.radio.V1_4.CellInfo> cellInfo) {
1250         responseCellInfoList_1_4(responseInfo, cellInfo);
1251     }
1252 
1253     /**
1254      * @param responseInfo Response info struct containing response type, serial no. and error.
1255      * @param cellInfo List of current cell information known to radio.
1256      */
getCellInfoListResponse_1_5( RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_5.CellInfo> cellInfo)1257     public void getCellInfoListResponse_1_5(
1258             RadioResponseInfo responseInfo,
1259             ArrayList<android.hardware.radio.V1_5.CellInfo> cellInfo) {
1260         responseCellInfoList_1_5(responseInfo, cellInfo);
1261     }
1262 
1263     /**
1264      * @param responseInfo Response info struct containing response type, serial no. and error
1265      */
setCellInfoListRateResponse(RadioResponseInfo responseInfo)1266     public void setCellInfoListRateResponse(RadioResponseInfo responseInfo) {
1267         responseVoid(responseInfo);
1268     }
1269 
1270     /**
1271      * @param responseInfo Response info struct containing response type, serial no. and error
1272      */
setInitialAttachApnResponse(RadioResponseInfo responseInfo)1273     public void setInitialAttachApnResponse(RadioResponseInfo responseInfo) {
1274         responseVoid(responseInfo);
1275     }
1276 
1277     /**
1278      * @param responseInfo Response info struct containing response type, serial no. and error
1279      */
setInitialAttachApnResponse_1_5(RadioResponseInfo responseInfo)1280     public void setInitialAttachApnResponse_1_5(RadioResponseInfo responseInfo) {
1281         responseVoid(responseInfo);
1282     }
1283 
1284     /**
1285      *
1286      * @param responseInfo Response info struct containing response type, serial no. and error
1287      * @param isRegistered false = not registered, true = registered
1288      * @param ratFamily RadioTechnologyFamily as defined in types.hal. This value is valid only if
1289      *        isRegistered is true.
1290      */
getImsRegistrationStateResponse(RadioResponseInfo responseInfo, boolean isRegistered, int ratFamily)1291     public void getImsRegistrationStateResponse(RadioResponseInfo responseInfo,
1292                                                 boolean isRegistered, int ratFamily) {
1293         responseInts(responseInfo, isRegistered ? 1 : 0, ratFamily);
1294     }
1295 
1296     /**
1297      *
1298      * @param responseInfo Response info struct containing response type, serial no. and error
1299      * @param sms Response to sms sent as defined by SendSmsResult in types.hal
1300      */
sendImsSmsResponse(RadioResponseInfo responseInfo, SendSmsResult sms)1301     public void sendImsSmsResponse(RadioResponseInfo responseInfo, SendSmsResult sms) {
1302         responseSms(responseInfo, sms);
1303     }
1304 
1305     /**
1306      *
1307      * @param responseInfo Response info struct containing response type, serial no. and error
1308      * @param result IccIoResult as defined in types.hal
1309      */
iccTransmitApduBasicChannelResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.IccIoResult result)1310     public void iccTransmitApduBasicChannelResponse(RadioResponseInfo responseInfo,
1311                                                     android.hardware.radio.V1_0.IccIoResult
1312                                                             result) {
1313         responseIccIo(responseInfo, result);
1314     }
1315 
1316     /**
1317      *
1318      * @param responseInfo Response info struct containing response type, serial no. and error
1319      * @param channelId session id of the logical channel.
1320      * @param selectResponse Contains the select response for the open channel command with one
1321      *        byte per integer
1322      */
iccOpenLogicalChannelResponse(RadioResponseInfo responseInfo, int channelId, ArrayList<Byte> selectResponse)1323     public void iccOpenLogicalChannelResponse(RadioResponseInfo responseInfo, int channelId,
1324                                               ArrayList<Byte> selectResponse) {
1325         ArrayList<Integer> arr = new ArrayList<>();
1326         arr.add(channelId);
1327         for (int i = 0; i < selectResponse.size(); i++) {
1328             arr.add((int) selectResponse.get(i));
1329         }
1330         responseIntArrayList(responseInfo, arr);
1331     }
1332 
1333     /**
1334      * @param responseInfo Response info struct containing response type, serial no. and error
1335      */
iccCloseLogicalChannelResponse(RadioResponseInfo responseInfo)1336     public void iccCloseLogicalChannelResponse(RadioResponseInfo responseInfo) {
1337         responseVoid(responseInfo);
1338     }
1339 
1340     /**
1341      *
1342      * @param responseInfo Response info struct containing response type, serial no. and error
1343      * @param result IccIoResult as defined in types.hal
1344      */
iccTransmitApduLogicalChannelResponse( RadioResponseInfo responseInfo, android.hardware.radio.V1_0.IccIoResult result)1345     public void iccTransmitApduLogicalChannelResponse(
1346             RadioResponseInfo responseInfo,
1347             android.hardware.radio.V1_0.IccIoResult result) {
1348         responseIccIo(responseInfo, result);
1349     }
1350 
1351     /**
1352      *
1353      * @param responseInfo Response info struct containing response type, serial no. and error
1354      * @param result string containing the contents of the NV item
1355      */
nvReadItemResponse(RadioResponseInfo responseInfo, String result)1356     public void nvReadItemResponse(RadioResponseInfo responseInfo, String result) {
1357         responseString(responseInfo, result);
1358     }
1359 
1360     /**
1361      * @param responseInfo Response info struct containing response type, serial no. and error
1362      */
nvWriteItemResponse(RadioResponseInfo responseInfo)1363     public void nvWriteItemResponse(RadioResponseInfo responseInfo) {
1364         responseVoid(responseInfo);
1365     }
1366 
1367     /**
1368      * @param responseInfo Response info struct containing response type, serial no. and error
1369      */
nvWriteCdmaPrlResponse(RadioResponseInfo responseInfo)1370     public void nvWriteCdmaPrlResponse(RadioResponseInfo responseInfo) {
1371         responseVoid(responseInfo);
1372     }
1373 
1374     /**
1375      * @param responseInfo Response info struct containing response type, serial no. and error
1376      */
nvResetConfigResponse(RadioResponseInfo responseInfo)1377     public void nvResetConfigResponse(RadioResponseInfo responseInfo) {
1378         responseVoid(responseInfo);
1379     }
1380 
1381     /**
1382      * @param responseInfo Response info struct containing response type, serial no. and error
1383      */
setUiccSubscriptionResponse(RadioResponseInfo responseInfo)1384     public void setUiccSubscriptionResponse(RadioResponseInfo responseInfo) {
1385         responseVoid(responseInfo);
1386     }
1387 
1388     /**
1389      * @param responseInfo Response info struct containing response type, serial no. and error
1390      */
setDataAllowedResponse(RadioResponseInfo responseInfo)1391     public void setDataAllowedResponse(RadioResponseInfo responseInfo) {
1392         responseVoid(responseInfo);
1393     }
1394 
getHardwareConfigResponse( RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.HardwareConfig> config)1395     public void getHardwareConfigResponse(
1396             RadioResponseInfo responseInfo,
1397             ArrayList<android.hardware.radio.V1_0.HardwareConfig> config) {
1398         responseHardwareConfig(responseInfo, config);
1399     }
1400 
1401     /**
1402      *
1403      * @param responseInfo Response info struct containing response type, serial no. and error
1404      * @param result IccIoResult as defined in types.hal
1405      */
requestIccSimAuthenticationResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.IccIoResult result)1406     public void requestIccSimAuthenticationResponse(RadioResponseInfo responseInfo,
1407                                                     android.hardware.radio.V1_0.IccIoResult
1408                                                             result) {
1409         RILRequest rr = mRil.processResponse(responseInfo);
1410 
1411         if (rr != null) {
1412             IccIoResult ret = new IccIoResult(
1413                     result.sw1,
1414                     result.sw2,
1415                     TextUtils.isEmpty(result.simResponse)
1416                             ? null : result.simResponse.getBytes());
1417             if (responseInfo.error == RadioError.NONE) {
1418                 sendMessageResponse(rr.mResult, ret);
1419             }
1420             mRil.processResponseDone(rr, responseInfo, ret);
1421         }
1422     }
1423 
1424     /**
1425      * @param responseInfo Response info struct containing response type, serial no. and error
1426      */
setDataProfileResponse(RadioResponseInfo responseInfo)1427     public void setDataProfileResponse(RadioResponseInfo responseInfo) {
1428         responseVoid(responseInfo);
1429     }
1430 
1431     /**
1432      * @param responseInfo Response info struct containing response type, serial no. and error
1433      */
setDataProfileResponse_1_5(RadioResponseInfo responseInfo)1434     public void setDataProfileResponse_1_5(RadioResponseInfo responseInfo) {
1435         responseVoid(responseInfo);
1436     }
1437 
1438     /**
1439      * @param responseInfo Response info struct containing response type, serial no. and error
1440      */
requestShutdownResponse(RadioResponseInfo responseInfo)1441     public void requestShutdownResponse(RadioResponseInfo responseInfo) {
1442         responseVoid(responseInfo);
1443     }
1444 
getRadioCapabilityResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.RadioCapability rc)1445     public void getRadioCapabilityResponse(RadioResponseInfo responseInfo,
1446                                            android.hardware.radio.V1_0.RadioCapability rc) {
1447         RILRequest rr = mRil.processResponse(responseInfo);
1448 
1449         if (rr != null) {
1450             RadioCapability ret = RIL.convertHalRadioCapability(rc, mRil);
1451             if (responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED
1452                     || responseInfo.error == RadioError.GENERIC_FAILURE) {
1453                 // we should construct the RAF bitmask the radio
1454                 // supports based on preferred network bitmasks
1455                 ret = mRil.makeStaticRadioCapability();
1456                 responseInfo.error = RadioError.NONE;
1457             }
1458             if (responseInfo.error == RadioError.NONE) {
1459                 sendMessageResponse(rr.mResult, ret);
1460             }
1461             mRil.processResponseDone(rr, responseInfo, ret);
1462         }
1463     }
1464 
setRadioCapabilityResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.RadioCapability rc)1465     public void setRadioCapabilityResponse(RadioResponseInfo responseInfo,
1466                                            android.hardware.radio.V1_0.RadioCapability rc) {
1467         responseRadioCapability(responseInfo, rc);
1468     }
1469 
1470     /**
1471      *
1472      * @param responseInfo Response info struct containing response type, serial no. and error
1473      * @param statusInfo LceStatusInfo indicating LCE status
1474      */
startLceServiceResponse(RadioResponseInfo responseInfo, LceStatusInfo statusInfo)1475     public void startLceServiceResponse(RadioResponseInfo responseInfo, LceStatusInfo statusInfo) {
1476         responseLceStatus(responseInfo, statusInfo);
1477     }
1478 
1479     /**
1480      *
1481      * @param responseInfo Response info struct containing response type, serial no. and error
1482      * @param statusInfo LceStatusInfo indicating LCE status
1483      */
stopLceServiceResponse(RadioResponseInfo responseInfo, LceStatusInfo statusInfo)1484     public void stopLceServiceResponse(RadioResponseInfo responseInfo, LceStatusInfo statusInfo) {
1485         responseLceStatus(responseInfo, statusInfo);
1486     }
1487 
pullLceDataResponse(RadioResponseInfo responseInfo, LceDataInfo lceInfo)1488     public void pullLceDataResponse(RadioResponseInfo responseInfo, LceDataInfo lceInfo) {
1489         responseLceData(responseInfo, lceInfo);
1490     }
1491 
1492     /**
1493      *
1494      * @param responseInfo Response info struct containing response type, serial no. and error
1495      * @param activityInfo modem activity information
1496      */
getModemActivityInfoResponse(RadioResponseInfo responseInfo, ActivityStatsInfo activityInfo)1497     public void getModemActivityInfoResponse(RadioResponseInfo responseInfo,
1498                                              ActivityStatsInfo activityInfo) {
1499         responseActivityData(responseInfo, activityInfo);
1500     }
1501 
1502     /**
1503      *
1504      * @param responseInfo Response info struct containing response type, serial no. and error
1505      * @param numAllowed number of allowed carriers which have been set correctly.
1506      *        On success, it must match the length of list Carriers->allowedCarriers.
1507      *        if Length of allowed carriers list is 0, numAllowed = 0.
1508      */
setAllowedCarriersResponse(RadioResponseInfo responseInfo, int numAllowed)1509     public void setAllowedCarriersResponse(RadioResponseInfo responseInfo, int numAllowed) {
1510         // The number of allowed carriers set correctly is not really useful. Even if one is
1511         // missing, the operation has failed, as the list should be treated as a single
1512         // configuration item. So, ignoring the value of numAllowed and considering only the
1513         // value of the responseInfo.error.
1514         int ret = TelephonyManager.SET_CARRIER_RESTRICTION_ERROR;
1515         RILRequest rr = mRil.processResponse(responseInfo);
1516         if (rr != null) {
1517             mRil.riljLog("setAllowedCarriersResponse - error = " + responseInfo.error);
1518 
1519             if (responseInfo.error == RadioError.NONE) {
1520                 ret = TelephonyManager.SET_CARRIER_RESTRICTION_SUCCESS;
1521                 sendMessageResponse(rr.mResult, ret);
1522             } else if (responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED) {
1523                 // Handle the case REQUEST_NOT_SUPPORTED as a valid response
1524                 responseInfo.error = RadioError.NONE;
1525                 ret = TelephonyManager.SET_CARRIER_RESTRICTION_NOT_SUPPORTED;
1526                 sendMessageResponse(rr.mResult, ret);
1527             }
1528             mRil.processResponseDone(rr, responseInfo, ret);
1529         }
1530     }
1531 
1532     /**
1533      *
1534      * @param responseInfo Response info struct containing response type, serial no. and error
1535      */
setAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo)1536     public void setAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo) {
1537         int ret = TelephonyManager.SET_CARRIER_RESTRICTION_ERROR;
1538         RILRequest rr = mRil.processResponse(responseInfo);
1539         if (rr != null) {
1540             mRil.riljLog("setAllowedCarriersResponse_1_4 - error = " + responseInfo.error);
1541 
1542             if (responseInfo.error == RadioError.NONE) {
1543                 ret = TelephonyManager.SET_CARRIER_RESTRICTION_SUCCESS;
1544                 sendMessageResponse(rr.mResult, ret);
1545             }
1546             mRil.processResponseDone(rr, responseInfo, ret);
1547         }
1548     }
1549 
1550     /**
1551      * @param responseInfo Response info struct containing response type, serial no. and error
1552      * @param allAllowed true only when all carriers are allowed. Ignore "carriers" struct.
1553      *                   If false, consider "carriers" struct
1554      * @param carriers Carrier restriction information.
1555      */
getAllowedCarriersResponse(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictions carriers)1556     public void getAllowedCarriersResponse(RadioResponseInfo responseInfo, boolean allAllowed,
1557             CarrierRestrictions carriers) {
1558         CarrierRestrictionsWithPriority carrierRestrictions = new CarrierRestrictionsWithPriority();
1559         carrierRestrictions.allowedCarriers = carriers.allowedCarriers;
1560         carrierRestrictions.excludedCarriers = carriers.excludedCarriers;
1561         carrierRestrictions.allowedCarriersPrioritized = true;
1562 
1563         responseCarrierRestrictions(responseInfo, allAllowed, carrierRestrictions,
1564                 SimLockMultiSimPolicy.NO_MULTISIM_POLICY);
1565     }
1566 
1567     /**
1568      * @param responseInfo Response info struct containing response type, serial no. and error
1569      * @param carrierRestrictions Carrier restriction information.
1570      * @param multiSimPolicy Policy for multi-sim devices.
1571      */
getAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo, CarrierRestrictionsWithPriority carrierRestrictions, int multiSimPolicy)1572     public void getAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo,
1573             CarrierRestrictionsWithPriority carrierRestrictions,
1574             int multiSimPolicy) {
1575         // The API in IRadio 1.4 does not support the flag allAllowed, so setting it to false, so
1576         // that values in carrierRestrictions are used.
1577         responseCarrierRestrictions(responseInfo, false, carrierRestrictions, multiSimPolicy);
1578     }
1579 
1580     /**
1581      * @param responseInfo Response info struct containing response type, serial no. and error
1582      */
sendDeviceStateResponse(RadioResponseInfo responseInfo)1583     public void sendDeviceStateResponse(RadioResponseInfo responseInfo) {
1584         responseVoid(responseInfo);
1585     }
1586 
1587     /**
1588      * @param responseInfo Response info struct containing response type, serial no. and error
1589      */
setCarrierInfoForImsiEncryptionResponse(RadioResponseInfo responseInfo)1590     public void setCarrierInfoForImsiEncryptionResponse(RadioResponseInfo responseInfo) {
1591         responseVoid(responseInfo);
1592     }
1593 
1594     /**
1595      * @param responseInfo Response info struct containing response type, serial no. and error
1596      */
setIndicationFilterResponse(RadioResponseInfo responseInfo)1597     public void setIndicationFilterResponse(RadioResponseInfo responseInfo) {
1598         responseVoid(responseInfo);
1599     }
1600 
1601     /**
1602      * @param responseInfo Response info struct containing response type, serial no. and error
1603      */
setIndicationFilterResponse_1_5(RadioResponseInfo responseInfo)1604     public void setIndicationFilterResponse_1_5(RadioResponseInfo responseInfo) {
1605         responseVoid(responseInfo);
1606     }
1607 
1608     /**
1609      * @param responseInfo Response info struct containing response type, serial no. and error
1610      */
setSimCardPowerResponse(RadioResponseInfo responseInfo)1611     public void setSimCardPowerResponse(RadioResponseInfo responseInfo) {
1612         responseVoid(responseInfo);
1613     }
1614 
1615     /**
1616      * @param responseInfo Response info struct containing response type, serial no. and error
1617      */
setSignalStrengthReportingCriteriaResponse(RadioResponseInfo responseInfo)1618     public void setSignalStrengthReportingCriteriaResponse(RadioResponseInfo responseInfo) {
1619         responseVoid(responseInfo);
1620     }
1621 
1622     /**
1623      * @param responseInfo Response info struct containing response type, serial no. and error
1624      */
setSignalStrengthReportingCriteriaResponse_1_5(RadioResponseInfo responseInfo)1625     public void setSignalStrengthReportingCriteriaResponse_1_5(RadioResponseInfo responseInfo) {
1626         responseVoid(responseInfo);
1627     }
1628 
1629     /**
1630      * @param responseInfo Response info struct containing response type, serial no. and error
1631      */
setLinkCapacityReportingCriteriaResponse(RadioResponseInfo responseInfo)1632     public void setLinkCapacityReportingCriteriaResponse(RadioResponseInfo responseInfo) {
1633         responseVoid(responseInfo);
1634     }
1635 
1636     /**
1637      * @param responseInfo Response info struct containing response type, serial no. and error
1638      */
setLinkCapacityReportingCriteriaResponse_1_5(RadioResponseInfo responseInfo)1639     public void setLinkCapacityReportingCriteriaResponse_1_5(RadioResponseInfo responseInfo) {
1640         responseVoid(responseInfo);
1641     }
1642 
1643     /**
1644      * @param responseInfo Response info struct containing response type, serial no. and error
1645      */
setSimCardPowerResponse_1_1(RadioResponseInfo responseInfo)1646     public void setSimCardPowerResponse_1_1(RadioResponseInfo responseInfo) {
1647         responseVoid(responseInfo);
1648     }
1649 
1650 
1651     /**
1652      * @param responseInfo Response info struct containing response type, serial no. and error
1653      * @param keepaliveStatus status of the keepalive with a handle for the session
1654      */
startKeepaliveResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_1.KeepaliveStatus keepaliveStatus)1655     public void startKeepaliveResponse(RadioResponseInfo responseInfo,
1656             android.hardware.radio.V1_1.KeepaliveStatus keepaliveStatus) {
1657 
1658         RILRequest rr = mRil.processResponse(responseInfo);
1659         if (rr == null) return;
1660 
1661         KeepaliveStatus ret = null;
1662         try {
1663             switch(responseInfo.error) {
1664                 case RadioError.NONE:
1665                     int convertedStatus = convertHalKeepaliveStatusCode(keepaliveStatus.code);
1666                     if (convertedStatus < 0) {
1667                         ret = new KeepaliveStatus(KeepaliveStatus.ERROR_UNSUPPORTED);
1668                     } else {
1669                         ret = new KeepaliveStatus(keepaliveStatus.sessionHandle, convertedStatus);
1670                     }
1671                     // If responseInfo.error is NONE, response function sends the response message
1672                     // even if result is actually an error.
1673                     sendMessageResponse(rr.mResult, ret);
1674                     break;
1675                 case RadioError.REQUEST_NOT_SUPPORTED:
1676                     ret = new KeepaliveStatus(KeepaliveStatus.ERROR_UNSUPPORTED);
1677                     break;
1678                 case RadioError.NO_RESOURCES:
1679                     ret = new KeepaliveStatus(KeepaliveStatus.ERROR_NO_RESOURCES);
1680                     break;
1681                 default:
1682                     ret = new KeepaliveStatus(KeepaliveStatus.ERROR_UNKNOWN);
1683                     break;
1684             }
1685         } finally {
1686             // If responseInfo.error != NONE, the processResponseDone sends the response message.
1687             mRil.processResponseDone(rr, responseInfo, ret);
1688         }
1689     }
1690 
1691     /**
1692      * @param responseInfo Response info struct containing response type, serial no. and error
1693      */
stopKeepaliveResponse(RadioResponseInfo responseInfo)1694     public void stopKeepaliveResponse(RadioResponseInfo responseInfo) {
1695         RILRequest rr = mRil.processResponse(responseInfo);
1696         if (rr == null) return;
1697 
1698         try {
1699             if (responseInfo.error == RadioError.NONE) {
1700                 sendMessageResponse(rr.mResult, null);
1701             } else {
1702                 //TODO: Error code translation
1703             }
1704         } finally {
1705             mRil.processResponseDone(rr, responseInfo, null);
1706         }
1707     }
1708 
convertHalKeepaliveStatusCode(int halCode)1709     private int convertHalKeepaliveStatusCode(int halCode) {
1710         switch (halCode) {
1711             case android.hardware.radio.V1_1.KeepaliveStatusCode.ACTIVE:
1712                 return KeepaliveStatus.STATUS_ACTIVE;
1713             case android.hardware.radio.V1_1.KeepaliveStatusCode.INACTIVE:
1714                 return KeepaliveStatus.STATUS_INACTIVE;
1715             case android.hardware.radio.V1_1.KeepaliveStatusCode.PENDING:
1716                 return KeepaliveStatus.STATUS_PENDING;
1717             default:
1718                 mRil.riljLog("Invalid Keepalive Status" + halCode);
1719                 return -1;
1720         }
1721     }
1722 
convertHalCardStatus(CardStatus cardStatus)1723     private IccCardStatus convertHalCardStatus(CardStatus cardStatus) {
1724         IccCardStatus iccCardStatus = new IccCardStatus();
1725         iccCardStatus.setCardState(cardStatus.cardState);
1726         iccCardStatus.setUniversalPinState(cardStatus.universalPinState);
1727         iccCardStatus.mGsmUmtsSubscriptionAppIndex = cardStatus.gsmUmtsSubscriptionAppIndex;
1728         iccCardStatus.mCdmaSubscriptionAppIndex = cardStatus.cdmaSubscriptionAppIndex;
1729         iccCardStatus.mImsSubscriptionAppIndex = cardStatus.imsSubscriptionAppIndex;
1730         int numApplications = cardStatus.applications.size();
1731 
1732         // limit to maximum allowed applications
1733         if (numApplications
1734                 > com.android.internal.telephony.uicc.IccCardStatus.CARD_MAX_APPS) {
1735             numApplications =
1736                 com.android.internal.telephony.uicc.IccCardStatus.CARD_MAX_APPS;
1737         }
1738         iccCardStatus.mApplications = new IccCardApplicationStatus[numApplications];
1739         for (int i = 0; i < numApplications; i++) {
1740             AppStatus rilAppStatus = cardStatus.applications.get(i);
1741             IccCardApplicationStatus appStatus = new IccCardApplicationStatus();
1742             appStatus.app_type       = appStatus.AppTypeFromRILInt(rilAppStatus.appType);
1743             appStatus.app_state      = appStatus.AppStateFromRILInt(rilAppStatus.appState);
1744             appStatus.perso_substate = appStatus.PersoSubstateFromRILInt(
1745                 rilAppStatus.persoSubstate);
1746             appStatus.aid            = rilAppStatus.aidPtr;
1747             appStatus.app_label      = rilAppStatus.appLabelPtr;
1748             appStatus.pin1_replaced  = rilAppStatus.pin1Replaced;
1749             appStatus.pin1           = appStatus.PinStateFromRILInt(rilAppStatus.pin1);
1750             appStatus.pin2           = appStatus.PinStateFromRILInt(rilAppStatus.pin2);
1751             iccCardStatus.mApplications[i] = appStatus;
1752             mRil.riljLog("IccCardApplicationStatus " + i + ":" + appStatus.toString());
1753         }
1754         return iccCardStatus;
1755     }
1756 
convertHalCardStatus_1_5( android.hardware.radio.V1_5.CardStatus cardStatus)1757     private IccCardStatus convertHalCardStatus_1_5(
1758             android.hardware.radio.V1_5.CardStatus cardStatus) {
1759         IccCardStatus iccCardStatus = new IccCardStatus();
1760         iccCardStatus.setCardState(cardStatus.base.base.base.cardState);
1761         iccCardStatus.setUniversalPinState(cardStatus.base.base.base.universalPinState);
1762         iccCardStatus.mGsmUmtsSubscriptionAppIndex =
1763                 cardStatus.base.base.base.gsmUmtsSubscriptionAppIndex;
1764         iccCardStatus.mCdmaSubscriptionAppIndex =
1765                 cardStatus.base.base.base.cdmaSubscriptionAppIndex;
1766         iccCardStatus.mImsSubscriptionAppIndex =
1767                 cardStatus.base.base.base.imsSubscriptionAppIndex;
1768         iccCardStatus.physicalSlotIndex = cardStatus.base.base.physicalSlotId;
1769         iccCardStatus.atr = cardStatus.base.base.atr;
1770         iccCardStatus.iccid = cardStatus.base.base.iccid;
1771         iccCardStatus.eid = cardStatus.base.eid;
1772         int numApplications = cardStatus.applications.size();
1773 
1774         // limit to maximum allowed applications
1775         if (numApplications
1776                 > com.android.internal.telephony.uicc.IccCardStatus.CARD_MAX_APPS) {
1777             numApplications =
1778                     com.android.internal.telephony.uicc.IccCardStatus.CARD_MAX_APPS;
1779         }
1780         iccCardStatus.mApplications = new IccCardApplicationStatus[numApplications];
1781         for (int i = 0; i < numApplications; i++) {
1782             android.hardware.radio.V1_5.AppStatus rilAppStatus = cardStatus.applications.get(i);
1783             IccCardApplicationStatus appStatus = new IccCardApplicationStatus();
1784             appStatus.app_type       = appStatus.AppTypeFromRILInt(rilAppStatus.base.appType);
1785             appStatus.app_state      = appStatus.AppStateFromRILInt(rilAppStatus.base.appState);
1786             appStatus.perso_substate = appStatus.PersoSubstateFromRILInt(
1787                     rilAppStatus.persoSubstate);
1788             appStatus.aid            = rilAppStatus.base.aidPtr;
1789             appStatus.app_label      = rilAppStatus.base.appLabelPtr;
1790             appStatus.pin1_replaced  = rilAppStatus.base.pin1Replaced;
1791             appStatus.pin1           = appStatus.PinStateFromRILInt(rilAppStatus.base.pin1);
1792             appStatus.pin2           = appStatus.PinStateFromRILInt(rilAppStatus.base.pin2);
1793             iccCardStatus.mApplications[i] = appStatus;
1794             mRil.riljLog("IccCardApplicationStatus " + i + ":" + appStatus.toString());
1795         }
1796         return iccCardStatus;
1797     }
1798 
responseIccCardStatus(RadioResponseInfo responseInfo, CardStatus cardStatus)1799     private void responseIccCardStatus(RadioResponseInfo responseInfo, CardStatus cardStatus) {
1800         RILRequest rr = mRil.processResponse(responseInfo);
1801 
1802         if (rr != null) {
1803             IccCardStatus iccCardStatus = convertHalCardStatus(cardStatus);
1804             mRil.riljLog("responseIccCardStatus: from HIDL: " + iccCardStatus);
1805             if (responseInfo.error == RadioError.NONE) {
1806                 sendMessageResponse(rr.mResult, iccCardStatus);
1807             }
1808             mRil.processResponseDone(rr, responseInfo, iccCardStatus);
1809         }
1810     }
1811 
responseIccCardStatus_1_2(RadioResponseInfo responseInfo, android.hardware.radio.V1_2.CardStatus cardStatus)1812     private void responseIccCardStatus_1_2(RadioResponseInfo responseInfo,
1813                                            android.hardware.radio.V1_2.CardStatus cardStatus) {
1814         RILRequest rr = mRil.processResponse(responseInfo);
1815 
1816         if (rr != null) {
1817             IccCardStatus iccCardStatus = convertHalCardStatus(cardStatus.base);
1818             iccCardStatus.physicalSlotIndex = cardStatus.physicalSlotId;
1819             iccCardStatus.atr = cardStatus.atr;
1820             iccCardStatus.iccid = cardStatus.iccid;
1821             mRil.riljLog("responseIccCardStatus: from HIDL: " + iccCardStatus);
1822             if (responseInfo.error == RadioError.NONE) {
1823                 sendMessageResponse(rr.mResult, iccCardStatus);
1824             }
1825             mRil.processResponseDone(rr, responseInfo, iccCardStatus);
1826         }
1827     }
1828 
responseIccCardStatus_1_4(RadioResponseInfo responseInfo, android.hardware.radio.V1_4.CardStatus cardStatus)1829     private void responseIccCardStatus_1_4(RadioResponseInfo responseInfo,
1830                                            android.hardware.radio.V1_4.CardStatus cardStatus) {
1831         RILRequest rr = mRil.processResponse(responseInfo);
1832 
1833         if (rr != null) {
1834             IccCardStatus iccCardStatus = convertHalCardStatus(cardStatus.base.base);
1835             iccCardStatus.physicalSlotIndex = cardStatus.base.physicalSlotId;
1836             iccCardStatus.atr = cardStatus.base.atr;
1837             iccCardStatus.iccid = cardStatus.base.iccid;
1838             iccCardStatus.eid = cardStatus.eid;
1839             mRil.riljLog("responseIccCardStatus: from HIDL: " + iccCardStatus);
1840             if (responseInfo.error == RadioError.NONE) {
1841                 sendMessageResponse(rr.mResult, iccCardStatus);
1842             }
1843             mRil.processResponseDone(rr, responseInfo, iccCardStatus);
1844         }
1845     }
1846 
responseIccCardStatus_1_5(RadioResponseInfo responseInfo, android.hardware.radio.V1_5.CardStatus cardStatus)1847     private void responseIccCardStatus_1_5(RadioResponseInfo responseInfo,
1848             android.hardware.radio.V1_5.CardStatus cardStatus) {
1849         RILRequest rr = mRil.processResponse(responseInfo);
1850 
1851         if (rr != null) {
1852             IccCardStatus iccCardStatus = convertHalCardStatus_1_5(cardStatus);
1853             mRil.riljLog("responseIccCardStatus: from HIDL: " + iccCardStatus);
1854             if (responseInfo.error == RadioError.NONE) {
1855                 sendMessageResponse(rr.mResult, iccCardStatus);
1856             }
1857             mRil.processResponseDone(rr, responseInfo, iccCardStatus);
1858         }
1859     }
1860 
1861     /**
1862      * @param responseInfo Response info struct containing response type, serial no. and error
1863      */
emergencyDialResponse(RadioResponseInfo responseInfo)1864     public void emergencyDialResponse(RadioResponseInfo responseInfo) {
1865         responseVoid(responseInfo);
1866     }
1867 
responseInts(RadioResponseInfo responseInfo, int ...var)1868     private void responseInts(RadioResponseInfo responseInfo, int ...var) {
1869         final ArrayList<Integer> ints = new ArrayList<>();
1870         for (int i = 0; i < var.length; i++) {
1871             ints.add(var[i]);
1872         }
1873         responseIntArrayList(responseInfo, ints);
1874     }
1875 
responseIntArrayList(RadioResponseInfo responseInfo, ArrayList<Integer> var)1876     private void responseIntArrayList(RadioResponseInfo responseInfo, ArrayList<Integer> var) {
1877         RILRequest rr = mRil.processResponse(responseInfo);
1878 
1879         if (rr != null) {
1880             int[] ret = new int[var.size()];
1881             for (int i = 0; i < var.size(); i++) {
1882                 ret[i] = var.get(i);
1883             }
1884             if (responseInfo.error == RadioError.NONE) {
1885                 sendMessageResponse(rr.mResult, ret);
1886             }
1887             mRil.processResponseDone(rr, responseInfo, ret);
1888         }
1889     }
1890 
responseCurrentCalls(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.Call> calls)1891     private void responseCurrentCalls(RadioResponseInfo responseInfo,
1892                                       ArrayList<android.hardware.radio.V1_0.Call> calls) {
1893         RILRequest rr = mRil.processResponse(responseInfo);
1894 
1895         if (rr != null) {
1896             int num = calls.size();
1897             ArrayList<DriverCall> dcCalls = new ArrayList<DriverCall>(num);
1898             DriverCall dc;
1899 
1900             for (int i = 0; i < num; i++) {
1901                 dc = new DriverCall();
1902                 // TODO: change name of function stateFromCLCC() in DriverCall.java to name
1903                 // clarifying what is CLCC
1904                 dc.state = DriverCall.stateFromCLCC((int) (calls.get(i).state));
1905                 dc.index = calls.get(i).index;
1906                 dc.TOA = calls.get(i).toa;
1907                 dc.isMpty = calls.get(i).isMpty;
1908                 dc.isMT = calls.get(i).isMT;
1909                 dc.als = calls.get(i).als;
1910                 dc.isVoice = calls.get(i).isVoice;
1911                 dc.isVoicePrivacy = calls.get(i).isVoicePrivacy;
1912                 dc.number = calls.get(i).number;
1913                 dc.numberPresentation =
1914                         DriverCall.presentationFromCLIP(
1915                                 (int) (calls.get(i).numberPresentation));
1916                 dc.name = calls.get(i).name;
1917                 dc.namePresentation =
1918                         DriverCall.presentationFromCLIP((int) (calls.get(i).namePresentation));
1919                 if (calls.get(i).uusInfo.size() == 1) {
1920                     dc.uusInfo = new UUSInfo();
1921                     dc.uusInfo.setType(calls.get(i).uusInfo.get(0).uusType);
1922                     dc.uusInfo.setDcs(calls.get(i).uusInfo.get(0).uusDcs);
1923                     if (!TextUtils.isEmpty(calls.get(i).uusInfo.get(0).uusData)) {
1924                         byte[] userData = calls.get(i).uusInfo.get(0).uusData.getBytes();
1925                         dc.uusInfo.setUserData(userData);
1926                     } else {
1927                         mRil.riljLog("responseCurrentCalls: uusInfo data is null or empty");
1928                     }
1929 
1930                     mRil.riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
1931                             dc.uusInfo.getType(), dc.uusInfo.getDcs(),
1932                             dc.uusInfo.getUserData().length));
1933                     mRil.riljLogv("Incoming UUS : data (hex): "
1934                             + IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
1935                 } else {
1936                     mRil.riljLogv("Incoming UUS : NOT present!");
1937                 }
1938 
1939                 // Make sure there's a leading + on addresses with a TOA of 145
1940                 dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
1941 
1942                 dcCalls.add(dc);
1943 
1944                 if (dc.isVoicePrivacy) {
1945                     mRil.mVoicePrivacyOnRegistrants.notifyRegistrants();
1946                     mRil.riljLog("InCall VoicePrivacy is enabled");
1947                 } else {
1948                     mRil.mVoicePrivacyOffRegistrants.notifyRegistrants();
1949                     mRil.riljLog("InCall VoicePrivacy is disabled");
1950                 }
1951             }
1952 
1953             Collections.sort(dcCalls);
1954 
1955             if ((num == 0) && mRil.mTestingEmergencyCall.getAndSet(false)) {
1956                 if (mRil.mEmergencyCallbackModeRegistrant != null) {
1957                     mRil.riljLog("responseCurrentCalls: call ended, testing emergency call,"
1958                             + " notify ECM Registrants");
1959                     mRil.mEmergencyCallbackModeRegistrant.notifyRegistrant();
1960                 }
1961             }
1962 
1963             if (responseInfo.error == RadioError.NONE) {
1964                 sendMessageResponse(rr.mResult, dcCalls);
1965             }
1966             mRil.processResponseDone(rr, responseInfo, dcCalls);
1967         }
1968     }
1969 
responseCurrentCalls_1_2(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_2.Call> calls)1970     private void responseCurrentCalls_1_2(RadioResponseInfo responseInfo,
1971                                       ArrayList<android.hardware.radio.V1_2.Call> calls) {
1972         RILRequest rr = mRil.processResponse(responseInfo);
1973 
1974         if (rr != null) {
1975             int num = calls.size();
1976             ArrayList<DriverCall> dcCalls = new ArrayList<DriverCall>(num);
1977             DriverCall dc;
1978 
1979             for (int i = 0; i < num; i++) {
1980                 dc = new DriverCall();
1981                 // TODO: change name of function stateFromCLCC() in DriverCall.java to name
1982                 // clarifying what is CLCC
1983                 dc.state = DriverCall.stateFromCLCC((int) (calls.get(i).base.state));
1984                 dc.index = calls.get(i).base.index;
1985                 dc.TOA = calls.get(i).base.toa;
1986                 dc.isMpty = calls.get(i).base.isMpty;
1987                 dc.isMT = calls.get(i).base.isMT;
1988                 dc.als = calls.get(i).base.als;
1989                 dc.isVoice = calls.get(i).base.isVoice;
1990                 dc.isVoicePrivacy = calls.get(i).base.isVoicePrivacy;
1991                 dc.number = calls.get(i).base.number;
1992                 dc.numberPresentation =
1993                         DriverCall.presentationFromCLIP(
1994                                 (int) (calls.get(i).base.numberPresentation));
1995                 dc.name = calls.get(i).base.name;
1996                 dc.namePresentation =
1997                         DriverCall.presentationFromCLIP((int) (calls.get(i).base.namePresentation));
1998                 if (calls.get(i).base.uusInfo.size() == 1) {
1999                     dc.uusInfo = new UUSInfo();
2000                     dc.uusInfo.setType(calls.get(i).base.uusInfo.get(0).uusType);
2001                     dc.uusInfo.setDcs(calls.get(i).base.uusInfo.get(0).uusDcs);
2002                     if (!TextUtils.isEmpty(calls.get(i).base.uusInfo.get(0).uusData)) {
2003                         byte[] userData = calls.get(i).base.uusInfo.get(0).uusData.getBytes();
2004                         dc.uusInfo.setUserData(userData);
2005                     } else {
2006                         mRil.riljLog("responseCurrentCalls: uusInfo data is null or empty");
2007                     }
2008 
2009                     mRil.riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
2010                             dc.uusInfo.getType(), dc.uusInfo.getDcs(),
2011                             dc.uusInfo.getUserData().length));
2012                     mRil.riljLogv("Incoming UUS : data (hex): "
2013                             + IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
2014                 } else {
2015                     mRil.riljLogv("Incoming UUS : NOT present!");
2016                 }
2017 
2018                 // Make sure there's a leading + on addresses with a TOA of 145
2019                 dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
2020 
2021                 dc.audioQuality = (int) (calls.get(i).audioQuality);
2022 
2023                 dcCalls.add(dc);
2024 
2025                 if (dc.isVoicePrivacy) {
2026                     mRil.mVoicePrivacyOnRegistrants.notifyRegistrants();
2027                     mRil.riljLog("InCall VoicePrivacy is enabled");
2028                 } else {
2029                     mRil.mVoicePrivacyOffRegistrants.notifyRegistrants();
2030                     mRil.riljLog("InCall VoicePrivacy is disabled");
2031                 }
2032             }
2033 
2034             Collections.sort(dcCalls);
2035 
2036             if ((num == 0) && mRil.mTestingEmergencyCall.getAndSet(false)) {
2037                 if (mRil.mEmergencyCallbackModeRegistrant != null) {
2038                     mRil.riljLog("responseCurrentCalls: call ended, testing emergency call,"
2039                             + " notify ECM Registrants");
2040                     mRil.mEmergencyCallbackModeRegistrant.notifyRegistrant();
2041                 }
2042             }
2043 
2044             if (responseInfo.error == RadioError.NONE) {
2045                 sendMessageResponse(rr.mResult, dcCalls);
2046             }
2047             mRil.processResponseDone(rr, responseInfo, dcCalls);
2048         }
2049     }
2050 
2051 
responseVoid(RadioResponseInfo responseInfo)2052     private void responseVoid(RadioResponseInfo responseInfo) {
2053         RILRequest rr = mRil.processResponse(responseInfo);
2054 
2055         if (rr != null) {
2056             Object ret = null;
2057             if (responseInfo.error == RadioError.NONE) {
2058                 sendMessageResponse(rr.mResult, ret);
2059             }
2060             mRil.processResponseDone(rr, responseInfo, ret);
2061         }
2062     }
2063 
responseString(RadioResponseInfo responseInfo, String str)2064     private void responseString(RadioResponseInfo responseInfo, String str) {
2065         RILRequest rr = mRil.processResponse(responseInfo);
2066 
2067         if (rr != null) {
2068             if (responseInfo.error == RadioError.NONE) {
2069                 sendMessageResponse(rr.mResult, str);
2070             }
2071             mRil.processResponseDone(rr, responseInfo, str);
2072         }
2073     }
2074 
responseStrings(RadioResponseInfo responseInfo, String ...str)2075     private void responseStrings(RadioResponseInfo responseInfo, String ...str) {
2076         ArrayList<String> strings = new ArrayList<>();
2077         for (int i = 0; i < str.length; i++) {
2078             strings.add(str[i]);
2079         }
2080         responseStringArrayList(mRil, responseInfo, strings);
2081     }
2082 
responseStringArrayList(RIL ril, RadioResponseInfo responseInfo, ArrayList<String> strings)2083     static void responseStringArrayList(RIL ril, RadioResponseInfo responseInfo,
2084                                         ArrayList<String> strings) {
2085         RILRequest rr = ril.processResponse(responseInfo);
2086 
2087         if (rr != null) {
2088             String[] ret = new String[strings.size()];
2089             for (int i = 0; i < strings.size(); i++) {
2090                 ret[i] = strings.get(i);
2091             }
2092             if (responseInfo.error == RadioError.NONE) {
2093                 sendMessageResponse(rr.mResult, ret);
2094             }
2095             ril.processResponseDone(rr, responseInfo, ret);
2096         }
2097     }
2098 
responseLastCallFailCauseInfo(RadioResponseInfo responseInfo, LastCallFailCauseInfo fcInfo)2099     private void responseLastCallFailCauseInfo(RadioResponseInfo responseInfo,
2100                                                LastCallFailCauseInfo fcInfo) {
2101         RILRequest rr = mRil.processResponse(responseInfo);
2102 
2103         if (rr != null) {
2104             LastCallFailCause ret = new LastCallFailCause();
2105             ret.causeCode = fcInfo.causeCode;
2106             ret.vendorCause = fcInfo.vendorCause;
2107             if (responseInfo.error == RadioError.NONE) {
2108                 sendMessageResponse(rr.mResult, ret);
2109             }
2110             mRil.processResponseDone(rr, responseInfo, ret);
2111         }
2112     }
2113 
responseSignalStrength( RadioResponseInfo responseInfo, android.hardware.radio.V1_0.SignalStrength signalStrength)2114     private void responseSignalStrength(
2115             RadioResponseInfo responseInfo,
2116             android.hardware.radio.V1_0.SignalStrength signalStrength) {
2117         RILRequest rr = mRil.processResponse(responseInfo);
2118 
2119         if (rr != null) {
2120             SignalStrength ret = new SignalStrength(signalStrength);
2121             if (responseInfo.error == RadioError.NONE) {
2122                 sendMessageResponse(rr.mResult, ret);
2123             }
2124             mRil.processResponseDone(rr, responseInfo, ret);
2125         }
2126     }
2127 
responseSignalStrength_1_2( RadioResponseInfo responseInfo, android.hardware.radio.V1_2.SignalStrength signalStrength)2128     private void responseSignalStrength_1_2(
2129             RadioResponseInfo responseInfo,
2130             android.hardware.radio.V1_2.SignalStrength signalStrength) {
2131         RILRequest rr = mRil.processResponse(responseInfo);
2132 
2133         if (rr != null) {
2134             SignalStrength ret = new SignalStrength(signalStrength);
2135             if (responseInfo.error == RadioError.NONE) {
2136                 sendMessageResponse(rr.mResult, ret);
2137             }
2138             mRil.processResponseDone(rr, responseInfo, ret);
2139         }
2140     }
2141 
responseSignalStrength_1_4( RadioResponseInfo responseInfo, android.hardware.radio.V1_4.SignalStrength signalStrength)2142     private void responseSignalStrength_1_4(
2143             RadioResponseInfo responseInfo,
2144             android.hardware.radio.V1_4.SignalStrength signalStrength) {
2145         RILRequest rr = mRil.processResponse(responseInfo);
2146 
2147         if (rr != null) {
2148             SignalStrength ret = new SignalStrength(signalStrength);
2149             if (responseInfo.error == RadioError.NONE) {
2150                 sendMessageResponse(rr.mResult, ret);
2151             }
2152             mRil.processResponseDone(rr, responseInfo, ret);
2153         }
2154     }
2155 
responseSms(RadioResponseInfo responseInfo, SendSmsResult sms)2156     private void responseSms(RadioResponseInfo responseInfo, SendSmsResult sms) {
2157         RILRequest rr = mRil.processResponse(responseInfo);
2158 
2159         if (rr != null) {
2160             SmsResponse ret = new SmsResponse(sms.messageRef, sms.ackPDU, sms.errorCode);
2161             if (responseInfo.error == RadioError.NONE) {
2162                 sendMessageResponse(rr.mResult, ret);
2163             }
2164             mRil.processResponseDone(rr, responseInfo, ret);
2165         }
2166     }
2167 
responseSetupDataCall(RadioResponseInfo responseInfo, Object setupDataCallResult)2168     private void responseSetupDataCall(RadioResponseInfo responseInfo,
2169                                        Object setupDataCallResult) {
2170         RILRequest rr = mRil.processResponse(responseInfo);
2171 
2172         if (rr != null) {
2173             DataCallResponse response = RIL.convertDataCallResult(setupDataCallResult);
2174             if (responseInfo.error == RadioError.NONE) {
2175                 sendMessageResponse(rr.mResult, response);
2176             }
2177             mRil.processResponseDone(rr, responseInfo, response);
2178         }
2179     }
2180 
responseIccIo(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.IccIoResult result)2181     private void responseIccIo(RadioResponseInfo responseInfo,
2182                                android.hardware.radio.V1_0.IccIoResult result) {
2183         RILRequest rr = mRil.processResponse(responseInfo);
2184 
2185         if (rr != null) {
2186             IccIoResult ret = new IccIoResult(result.sw1, result.sw2, result.simResponse);
2187             if (responseInfo.error == RadioError.NONE) {
2188                 sendMessageResponse(rr.mResult, ret);
2189             }
2190             mRil.processResponseDone(rr, responseInfo, ret);
2191         }
2192     }
2193 
responseCallForwardInfo(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.CallForwardInfo> callForwardInfos)2194     private void responseCallForwardInfo(RadioResponseInfo responseInfo,
2195                                          ArrayList<android.hardware.radio.V1_0.CallForwardInfo>
2196                                                  callForwardInfos) {
2197         RILRequest rr = mRil.processResponse(responseInfo);
2198         if (rr != null) {
2199             CallForwardInfo[] ret = new CallForwardInfo[callForwardInfos.size()];
2200             for (int i = 0; i < callForwardInfos.size(); i++) {
2201                 ret[i] = new CallForwardInfo();
2202                 ret[i].status = callForwardInfos.get(i).status;
2203                 ret[i].reason = callForwardInfos.get(i).reason;
2204                 ret[i].serviceClass = callForwardInfos.get(i).serviceClass;
2205                 ret[i].toa = callForwardInfos.get(i).toa;
2206                 ret[i].number = callForwardInfos.get(i).number;
2207                 ret[i].timeSeconds = callForwardInfos.get(i).timeSeconds;
2208             }
2209             if (responseInfo.error == RadioError.NONE) {
2210                 sendMessageResponse(rr.mResult, ret);
2211             }
2212             mRil.processResponseDone(rr, responseInfo, ret);
2213         }
2214     }
2215 
convertOpertatorInfoToString(int status)2216     private static String convertOpertatorInfoToString(int status) {
2217         if (status == android.hardware.radio.V1_0.OperatorStatus.UNKNOWN) {
2218             return "unknown";
2219         } else if (status == android.hardware.radio.V1_0.OperatorStatus.AVAILABLE) {
2220             return "available";
2221         } else if (status == android.hardware.radio.V1_0.OperatorStatus.CURRENT) {
2222             return "current";
2223         } else if (status == android.hardware.radio.V1_0.OperatorStatus.FORBIDDEN) {
2224             return "forbidden";
2225         } else {
2226             return "";
2227         }
2228     }
2229 
responseOperatorInfos(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.OperatorInfo> networkInfos)2230     private void responseOperatorInfos(RadioResponseInfo responseInfo,
2231                                        ArrayList<android.hardware.radio.V1_0.OperatorInfo>
2232                                                networkInfos) {
2233         RILRequest rr = mRil.processResponse(responseInfo);
2234 
2235         if (rr != null) {
2236             ArrayList<OperatorInfo> ret = new ArrayList<OperatorInfo>();
2237             for (int i = 0; i < networkInfos.size(); i++) {
2238                 ret.add(new OperatorInfo(networkInfos.get(i).alphaLong,
2239                         networkInfos.get(i).alphaShort, networkInfos.get(i).operatorNumeric,
2240                         convertOpertatorInfoToString(networkInfos.get(i).status)));
2241             }
2242             if (responseInfo.error == RadioError.NONE) {
2243                 sendMessageResponse(rr.mResult, ret);
2244             }
2245             mRil.processResponseDone(rr, responseInfo, ret);
2246         }
2247     }
2248 
responseScanStatus(RadioResponseInfo responseInfo, HalVersion fallbackHalVersion)2249     private void responseScanStatus(RadioResponseInfo responseInfo, HalVersion fallbackHalVersion) {
2250         RILRequest rr = mRil.processResponse(responseInfo);
2251         if (rr == null) {
2252             return;
2253         }
2254 
2255         final boolean needFallback = responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED
2256                 && fallbackHalVersion != null && rr.mArguments != null && rr.mArguments.length > 0
2257                 && rr.mArguments[0] instanceof NetworkScanRequest;
2258         if (needFallback) {
2259             // Move the data needed for fallback call from rr which will be released soon
2260             final int request = rr.getRequest();
2261             final Message result = rr.getResult();
2262             final NetworkScanRequest scanRequest = (NetworkScanRequest) rr.mArguments[0];
2263 
2264             mRil.mRilHandler.post(() -> {
2265                 mRil.setCompatVersion(request, RIL.RADIO_HAL_VERSION_1_4);
2266                 mRil.startNetworkScan(scanRequest, result);
2267             });
2268 
2269             mRil.processResponseFallback(rr, responseInfo, null);
2270             return;
2271         }
2272 
2273         NetworkScanResult nsr = null;
2274         if (responseInfo.error == RadioError.NONE) {
2275             nsr = new NetworkScanResult(
2276                     NetworkScanResult.SCAN_STATUS_PARTIAL, RadioError.NONE, null);
2277             sendMessageResponse(rr.mResult, nsr);
2278         }
2279         mRil.processResponseDone(rr, responseInfo, nsr);
2280     }
2281 
responseDataCallList(RadioResponseInfo responseInfo, List<? extends Object> dataCallResultList)2282     private void responseDataCallList(RadioResponseInfo responseInfo,
2283                                       List<? extends Object> dataCallResultList) {
2284         RILRequest rr = mRil.processResponse(responseInfo);
2285 
2286         if (rr != null) {
2287             ArrayList<DataCallResponse> response =
2288                     RIL.convertDataCallResultList(dataCallResultList);
2289             if (responseInfo.error == RadioError.NONE) {
2290                 sendMessageResponse(rr.mResult, response);
2291             }
2292             mRil.processResponseDone(rr, responseInfo, response);
2293         }
2294     }
2295 
responseCellList(RadioResponseInfo responseInfo, ArrayList<NeighboringCell> cells)2296     private void responseCellList(RadioResponseInfo responseInfo,
2297                                   ArrayList<NeighboringCell> cells) {
2298         RILRequest rr = mRil.processResponse(responseInfo);
2299 
2300         if (rr != null) {
2301             int rssi;
2302             String location;
2303             ArrayList<NeighboringCellInfo> ret = new ArrayList<NeighboringCellInfo>();
2304             NeighboringCellInfo cell;
2305 
2306             int[] subId = SubscriptionManager.getSubId(mRil.mPhoneId);
2307             int radioType =
2308                     ((TelephonyManager) mRil.mContext.getSystemService(
2309                             Context.TELEPHONY_SERVICE)).getDataNetworkType(subId[0]);
2310 
2311             if (radioType != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
2312                 for (int i = 0; i < cells.size(); i++) {
2313                     rssi = cells.get(i).rssi;
2314                     location = cells.get(i).cid;
2315                     cell = new NeighboringCellInfo(rssi, location, radioType);
2316                     ret.add(cell);
2317                 }
2318             }
2319             if (responseInfo.error == RadioError.NONE) {
2320                 sendMessageResponse(rr.mResult, ret);
2321             }
2322             mRil.processResponseDone(rr, responseInfo, ret);
2323         }
2324     }
2325 
responseGmsBroadcastConfig(RadioResponseInfo responseInfo, ArrayList<GsmBroadcastSmsConfigInfo> configs)2326     private void responseGmsBroadcastConfig(RadioResponseInfo responseInfo,
2327                                             ArrayList<GsmBroadcastSmsConfigInfo> configs) {
2328         RILRequest rr = mRil.processResponse(responseInfo);
2329 
2330         if (rr != null) {
2331             ArrayList<SmsBroadcastConfigInfo> ret = new ArrayList<SmsBroadcastConfigInfo>();
2332             for (int i = 0; i < configs.size(); i++) {
2333                 ret.add(new SmsBroadcastConfigInfo(configs.get(i).fromServiceId,
2334                         configs.get(i).toServiceId, configs.get(i).fromCodeScheme,
2335                         configs.get(i).toCodeScheme, configs.get(i).selected));
2336             }
2337             if (responseInfo.error == RadioError.NONE) {
2338                 sendMessageResponse(rr.mResult, ret);
2339             }
2340             mRil.processResponseDone(rr, responseInfo, ret);
2341         }
2342     }
2343 
responseCdmaBroadcastConfig(RadioResponseInfo responseInfo, ArrayList<CdmaBroadcastSmsConfigInfo> configs)2344     private void responseCdmaBroadcastConfig(RadioResponseInfo responseInfo,
2345                                             ArrayList<CdmaBroadcastSmsConfigInfo> configs) {
2346         RILRequest rr = mRil.processResponse(responseInfo);
2347 
2348         if (rr != null) {
2349             int[] ret = null;
2350 
2351             int numServiceCategories = configs.size();
2352 
2353             if (numServiceCategories == 0) {
2354                 // TODO: The logic of providing default values should
2355                 // not be done by this transport layer. And needs to
2356                 // be done by the vendor ril or application logic.
2357                 int numInts;
2358                 numInts = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES
2359                         * CDMA_BSI_NO_OF_INTS_STRUCT + 1;
2360                 ret = new int[numInts];
2361 
2362                 // Faking a default record for all possible records.
2363                 ret[0] = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES;
2364 
2365                 // Loop over CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES set 'english' as
2366                 // default language and selection status to false for all.
2367                 for (int i = 1; i < numInts; i += CDMA_BSI_NO_OF_INTS_STRUCT) {
2368                     ret[i + 0] = i / CDMA_BSI_NO_OF_INTS_STRUCT;
2369                     ret[i + 1] = 1;
2370                     ret[i + 2] = 0;
2371                 }
2372             } else {
2373                 int numInts;
2374                 numInts = (numServiceCategories * CDMA_BSI_NO_OF_INTS_STRUCT) + 1;
2375                 ret = new int[numInts];
2376 
2377                 ret[0] = numServiceCategories;
2378                 for (int i = 1, j = 0; j < configs.size();
2379                         j++, i = i + CDMA_BSI_NO_OF_INTS_STRUCT) {
2380                     ret[i] = configs.get(j).serviceCategory;
2381                     ret[i + 1] = configs.get(j).language;
2382                     ret[i + 2] = configs.get(j).selected ? 1 : 0;
2383                 }
2384             }
2385             if (responseInfo.error == RadioError.NONE) {
2386                 sendMessageResponse(rr.mResult, ret);
2387             }
2388             mRil.processResponseDone(rr, responseInfo, ret);
2389         }
2390     }
2391 
responseCellInfoList(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.CellInfo> cellInfo)2392     private void responseCellInfoList(RadioResponseInfo responseInfo,
2393                                       ArrayList<android.hardware.radio.V1_0.CellInfo> cellInfo) {
2394         RILRequest rr = mRil.processResponse(responseInfo);
2395 
2396         if (rr != null) {
2397             ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(cellInfo);
2398             if (responseInfo.error == RadioError.NONE) {
2399                 sendMessageResponse(rr.mResult, ret);
2400             }
2401             mRil.processResponseDone(rr, responseInfo, ret);
2402         }
2403     }
2404 
responseCellInfoList_1_2( RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_2.CellInfo> cellInfo)2405     private void responseCellInfoList_1_2(
2406             RadioResponseInfo responseInfo,
2407             ArrayList<android.hardware.radio.V1_2.CellInfo> cellInfo) {
2408         RILRequest rr = mRil.processResponse(responseInfo);
2409 
2410         if (rr != null) {
2411             ArrayList<CellInfo> ret = RIL.convertHalCellInfoList_1_2(cellInfo);
2412             if (responseInfo.error == RadioError.NONE) {
2413                 sendMessageResponse(rr.mResult, ret);
2414             }
2415             mRil.processResponseDone(rr, responseInfo, ret);
2416         }
2417     }
2418 
responseCellInfoList_1_4( RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_4.CellInfo> cellInfo)2419     private void responseCellInfoList_1_4(
2420             RadioResponseInfo responseInfo,
2421             ArrayList<android.hardware.radio.V1_4.CellInfo> cellInfo) {
2422         RILRequest rr = mRil.processResponse(responseInfo);
2423 
2424         if (rr != null) {
2425             ArrayList<CellInfo> ret = RIL.convertHalCellInfoList_1_4(cellInfo);
2426             if (responseInfo.error == RadioError.NONE) {
2427                 sendMessageResponse(rr.mResult, ret);
2428             }
2429             mRil.processResponseDone(rr, responseInfo, ret);
2430         }
2431     }
2432 
responseCellInfoList_1_5(RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_5.CellInfo> cellInfo)2433     private void responseCellInfoList_1_5(RadioResponseInfo responseInfo,
2434             ArrayList<android.hardware.radio.V1_5.CellInfo> cellInfo) {
2435         RILRequest rr = mRil.processResponse(responseInfo);
2436 
2437         if (rr != null) {
2438             ArrayList<CellInfo> ret = RIL.convertHalCellInfoList_1_5(cellInfo);
2439             if (responseInfo.error == RadioError.NONE) {
2440                 sendMessageResponse(rr.mResult, ret);
2441             }
2442             mRil.processResponseDone(rr, responseInfo, ret);
2443         }
2444     }
2445 
responseActivityData(RadioResponseInfo responseInfo, ActivityStatsInfo activityInfo)2446     private void responseActivityData(RadioResponseInfo responseInfo,
2447                                       ActivityStatsInfo activityInfo) {
2448         RILRequest rr = mRil.processResponse(responseInfo);
2449 
2450         if (rr != null) {
2451             ModemActivityInfo ret = null;
2452             if (responseInfo.error == RadioError.NONE) {
2453                 final int sleepModeTimeMs = activityInfo.sleepModeTimeMs;
2454                 final int idleModeTimeMs = activityInfo.idleModeTimeMs;
2455                 int [] txModeTimeMs = new int[ModemActivityInfo.TX_POWER_LEVELS];
2456                 for (int i = 0; i < ModemActivityInfo.TX_POWER_LEVELS; i++) {
2457                     txModeTimeMs[i] = activityInfo.txmModetimeMs[i];
2458                 }
2459                 final int rxModeTimeMs = activityInfo.rxModeTimeMs;
2460                 ret = new ModemActivityInfo(SystemClock.elapsedRealtime(), sleepModeTimeMs,
2461                         idleModeTimeMs, txModeTimeMs, rxModeTimeMs);
2462             } else {
2463                 ret = new ModemActivityInfo(0, 0, 0, new int [ModemActivityInfo.TX_POWER_LEVELS],
2464                         0);
2465                 responseInfo.error = RadioError.NONE;
2466             }
2467             sendMessageResponse(rr.mResult, ret);
2468             mRil.processResponseDone(rr, responseInfo, ret);
2469         }
2470     }
2471 
responseHardwareConfig( RadioResponseInfo responseInfo, ArrayList<android.hardware.radio.V1_0.HardwareConfig> config)2472     private void responseHardwareConfig(
2473             RadioResponseInfo responseInfo,
2474             ArrayList<android.hardware.radio.V1_0.HardwareConfig> config) {
2475         RILRequest rr = mRil.processResponse(responseInfo);
2476 
2477         if (rr != null) {
2478             ArrayList<HardwareConfig> ret = RIL.convertHalHwConfigList(config, mRil);
2479             if (responseInfo.error == RadioError.NONE) {
2480                 sendMessageResponse(rr.mResult, ret);
2481             }
2482             mRil.processResponseDone(rr, responseInfo, ret);
2483         }
2484     }
2485 
responseRadioCapability(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.RadioCapability rc)2486     private void responseRadioCapability(RadioResponseInfo responseInfo,
2487                                          android.hardware.radio.V1_0.RadioCapability rc) {
2488         RILRequest rr = mRil.processResponse(responseInfo);
2489 
2490         if (rr != null) {
2491             RadioCapability ret = RIL.convertHalRadioCapability(rc, mRil);
2492             if (responseInfo.error == RadioError.NONE) {
2493                 sendMessageResponse(rr.mResult, ret);
2494             }
2495             mRil.processResponseDone(rr, responseInfo, ret);
2496         }
2497     }
2498 
responseLceStatus(RadioResponseInfo responseInfo, LceStatusInfo statusInfo)2499     private void responseLceStatus(RadioResponseInfo responseInfo, LceStatusInfo statusInfo) {
2500         RILRequest rr = mRil.processResponse(responseInfo);
2501 
2502         if (rr != null) {
2503             ArrayList<Integer> ret = new ArrayList<Integer>();
2504             ret.add(statusInfo.lceStatus);
2505             ret.add(Byte.toUnsignedInt(statusInfo.actualIntervalMs));
2506             if (responseInfo.error == RadioError.NONE) {
2507                 sendMessageResponse(rr.mResult, ret);
2508             }
2509             mRil.processResponseDone(rr, responseInfo, ret);
2510         }
2511     }
2512 
responseLceData(RadioResponseInfo responseInfo, LceDataInfo lceInfo)2513     private void responseLceData(RadioResponseInfo responseInfo, LceDataInfo lceInfo) {
2514         RILRequest rr = mRil.processResponse(responseInfo);
2515 
2516         if (rr != null) {
2517             LinkCapacityEstimate ret = RIL.convertHalLceData(lceInfo, mRil);
2518             if (responseInfo.error == RadioError.NONE) {
2519                 sendMessageResponse(rr.mResult, ret);
2520             }
2521             mRil.processResponseDone(rr, responseInfo, ret);
2522         }
2523     }
2524 
convertCarrierList(List<Carrier> carrierList)2525     private static List<CarrierIdentifier> convertCarrierList(List<Carrier> carrierList) {
2526         List<CarrierIdentifier> ret = new ArrayList<>();
2527         for (int i = 0; i < carrierList.size(); i++) {
2528             String mcc = carrierList.get(i).mcc;
2529             String mnc = carrierList.get(i).mnc;
2530             String spn = null, imsi = null, gid1 = null, gid2 = null;
2531             int matchType = carrierList.get(i).matchType;
2532             String matchData = carrierList.get(i).matchData;
2533             if (matchType == CarrierIdentifier.MatchType.SPN) {
2534                 spn = matchData;
2535             } else if (matchType == CarrierIdentifier.MatchType.IMSI_PREFIX) {
2536                 imsi = matchData;
2537             } else if (matchType == CarrierIdentifier.MatchType.GID1) {
2538                 gid1 = matchData;
2539             } else if (matchType == CarrierIdentifier.MatchType.GID2) {
2540                 gid2 = matchData;
2541             }
2542             ret.add(new CarrierIdentifier(mcc, mnc, spn, imsi, gid1, gid2));
2543         }
2544         return ret;
2545     }
2546 
responseCarrierRestrictions(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictionsWithPriority carriers, int multiSimPolicy)2547     private void responseCarrierRestrictions(RadioResponseInfo responseInfo, boolean allAllowed,
2548                                             CarrierRestrictionsWithPriority carriers,
2549                                             int multiSimPolicy) {
2550         RILRequest rr = mRil.processResponse(responseInfo);
2551         if (rr == null) {
2552             return;
2553         }
2554         CarrierRestrictionRules ret;
2555 
2556         if (allAllowed) {
2557             ret = CarrierRestrictionRules.newBuilder().setAllCarriersAllowed().build();
2558         } else {
2559             int policy = CarrierRestrictionRules.MULTISIM_POLICY_NONE;
2560             if (multiSimPolicy == SimLockMultiSimPolicy.ONE_VALID_SIM_MUST_BE_PRESENT) {
2561                 policy = CarrierRestrictionRules.MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT;
2562             }
2563 
2564             int carrierRestrictionDefault =
2565                     CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED;
2566             if (!carriers.allowedCarriersPrioritized) {
2567                 carrierRestrictionDefault =
2568                         CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_ALLOWED;
2569             }
2570 
2571             ret = CarrierRestrictionRules.newBuilder()
2572                     .setAllowedCarriers(convertCarrierList(carriers.allowedCarriers))
2573                     .setExcludedCarriers(convertCarrierList(carriers.excludedCarriers))
2574                     .setDefaultCarrierRestriction(carrierRestrictionDefault)
2575                     .setMultiSimPolicy(policy)
2576                     .build();
2577         }
2578 
2579         if (responseInfo.error == RadioError.NONE) {
2580             sendMessageResponse(rr.mResult, ret);
2581         }
2582         mRil.processResponseDone(rr, responseInfo, ret);
2583     }
2584 
2585     /**
2586      * @param responseInfo Response info struct containing response type, serial number and error.
2587      */
enableModemResponse(RadioResponseInfo responseInfo)2588     public void enableModemResponse(RadioResponseInfo responseInfo) {
2589         responseVoid(responseInfo);
2590     }
2591 
2592     /**
2593      * @param responseInfo Response info struct containing response type, serial no. and error
2594      * @param isEnabled whether the modem stack is enabled.
2595      */
getModemStackStatusResponse(RadioResponseInfo responseInfo, boolean isEnabled)2596     public void getModemStackStatusResponse(RadioResponseInfo responseInfo, boolean isEnabled) {
2597         RILRequest rr = mRil.processResponse(responseInfo);
2598 
2599         if (rr != null) {
2600             if (responseInfo.error == RadioError.NONE) {
2601                 sendMessageResponse(rr.mResult, isEnabled);
2602             }
2603             mRil.processResponseDone(rr, responseInfo, isEnabled);
2604         }
2605     }
2606 
2607     /**
2608      * @param responseInfo Response info struct containing response type, serial number and error.
2609      */
setSystemSelectionChannelsResponse(RadioResponseInfo responseInfo)2610     public void setSystemSelectionChannelsResponse(RadioResponseInfo responseInfo) {
2611         responseVoid(responseInfo);
2612     }
2613 
2614     /**
2615      * @param responseInfo Response info struct containing response type, serial no. and error.
2616      */
enableUiccApplicationsResponse(RadioResponseInfo responseInfo)2617     public void enableUiccApplicationsResponse(RadioResponseInfo responseInfo) {
2618         responseVoid(responseInfo);
2619     }
2620 
2621     /**
2622      * @param responseInfo Response info struct containing response type, serial no. and error.
2623      * @param enabled whether Uicc applications are enabled.
2624      */
areUiccApplicationsEnabledResponse(RadioResponseInfo responseInfo, boolean enabled)2625     public void areUiccApplicationsEnabledResponse(RadioResponseInfo responseInfo,
2626             boolean enabled) {
2627         RILRequest rr = mRil.processResponse(responseInfo);
2628 
2629         if (rr != null) {
2630             if (responseInfo.error == RadioError.NONE) {
2631                 sendMessageResponse(rr.mResult, enabled);
2632             }
2633             mRil.processResponseDone(rr, responseInfo, enabled);
2634         }
2635     }
2636 
2637     /**
2638      * @param info Response info struct containing response type, serial no. and error.
2639      */
setRadioPowerResponse_1_5(RadioResponseInfo info)2640     public void setRadioPowerResponse_1_5(RadioResponseInfo info) {
2641         responseVoid(info);
2642     }
2643 
2644     /**
2645      * @param info Response info struct containing response type, serial no. and error.
2646      */
setSystemSelectionChannelsResponse_1_5(RadioResponseInfo info)2647     public void setSystemSelectionChannelsResponse_1_5(RadioResponseInfo info) {
2648         responseVoid(info);
2649     }
2650 
2651     /**
2652      * @param responseInfo Response info struct containing response type, serial no. and error.
2653      * @param cellIdentity CellIdentity for the barringInfos.
2654      * @param barringInfos List of BarringInfo for all the barring service types.
2655      */
getBarringInfoResponse(RadioResponseInfo responseInfo, android.hardware.radio.V1_5.CellIdentity cellIdentity, ArrayList<android.hardware.radio.V1_5.BarringInfo> barringInfos)2656     public void getBarringInfoResponse(RadioResponseInfo responseInfo,
2657             android.hardware.radio.V1_5.CellIdentity cellIdentity,
2658             ArrayList<android.hardware.radio.V1_5.BarringInfo> barringInfos) {
2659         RILRequest rr = mRil.processResponse(responseInfo);
2660 
2661         if (rr != null) {
2662             BarringInfo bi = BarringInfo.create(cellIdentity, barringInfos);
2663             if (responseInfo.error == RadioError.NONE) {
2664                 sendMessageResponse(rr.mResult, bi);
2665                 // notify all registrants for the possible barring info change
2666                 mRil.mBarringInfoChangedRegistrants.notifyRegistrants(
2667                         new AsyncResult(null, bi, null));
2668             }
2669             mRil.processResponseDone(rr, responseInfo, bi);
2670         }
2671     }
2672 
2673     /**
2674      * @param responseInfo Response info struct containing response type, serial no. and error
2675      * @param sms Response to sms sent as defined by SendSmsResult in types.hal
2676      */
sendCdmaSmsExpectMoreResponse(RadioResponseInfo responseInfo, SendSmsResult sms)2677     public void sendCdmaSmsExpectMoreResponse(RadioResponseInfo responseInfo,
2678             SendSmsResult sms) {
2679         responseSms(responseInfo, sms);
2680     }
2681 }
2682