Home | History | Annotate | Download | only in telephony
      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.CarrierRestrictions;
     24 import android.hardware.radio.V1_0.CdmaBroadcastSmsConfigInfo;
     25 import android.hardware.radio.V1_0.DataRegStateResult;
     26 import android.hardware.radio.V1_0.GsmBroadcastSmsConfigInfo;
     27 import android.hardware.radio.V1_0.LastCallFailCauseInfo;
     28 import android.hardware.radio.V1_0.LceDataInfo;
     29 import android.hardware.radio.V1_0.LceStatusInfo;
     30 import android.hardware.radio.V1_0.NeighboringCell;
     31 import android.hardware.radio.V1_0.RadioError;
     32 import android.hardware.radio.V1_0.RadioResponseInfo;
     33 import android.hardware.radio.V1_0.SendSmsResult;
     34 import android.hardware.radio.V1_0.SetupDataCallResult;
     35 import android.hardware.radio.V1_0.VoiceRegStateResult;
     36 import android.hardware.radio.V1_2.IRadioResponse;
     37 import android.os.AsyncResult;
     38 import android.os.Message;
     39 import android.os.SystemClock;
     40 import android.service.carrier.CarrierIdentifier;
     41 import android.telephony.CellInfo;
     42 import android.telephony.ModemActivityInfo;
     43 import android.telephony.NeighboringCellInfo;
     44 import android.telephony.PhoneNumberUtils;
     45 import android.telephony.SignalStrength;
     46 import android.telephony.SubscriptionManager;
     47 import android.telephony.TelephonyManager;
     48 import android.text.TextUtils;
     49 
     50 import com.android.internal.telephony.dataconnection.KeepaliveStatus;
     51 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
     52 import com.android.internal.telephony.uicc.IccCardApplicationStatus;
     53 import com.android.internal.telephony.uicc.IccCardStatus;
     54 import com.android.internal.telephony.uicc.IccIoResult;
     55 import com.android.internal.telephony.uicc.IccUtils;
     56 
     57 import java.util.ArrayList;
     58 import java.util.Collections;
     59 import java.util.List;
     60 
     61 public class RadioResponse extends IRadioResponse.Stub {
     62     // The number of the required config values for broadcast SMS stored in the C struct
     63     // RIL_CDMA_BroadcastServiceInfo
     64     private static final int CDMA_BSI_NO_OF_INTS_STRUCT = 3;
     65 
     66     private static final int CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES = 31;
     67 
     68     RIL mRil;
     69 
     70     public RadioResponse(RIL ril) {
     71         mRil = ril;
     72     }
     73 
     74     /**
     75      * Helper function to send response msg
     76      * @param msg Response message to be sent
     77      * @param ret Return object to be included in the response message
     78      */
     79     static void sendMessageResponse(Message msg, Object ret) {
     80         if (msg != null) {
     81             AsyncResult.forMessage(msg, ret, null);
     82             msg.sendToTarget();
     83         }
     84     }
     85 
     86     /**
     87      * Acknowledge the receipt of radio request sent to the vendor. This must be sent only for
     88      * radio request which take long time to respond.
     89      * For more details, refer https://source.android.com/devices/tech/connect/ril.html
     90      *
     91      * @param serial Serial no. of the request whose acknowledgement is sent.
     92      */
     93     public void acknowledgeRequest(int serial) {
     94         mRil.processRequestAck(serial);
     95     }
     96 
     97     /**
     98      * @param responseInfo Response info struct containing response type, serial no. and error
     99      * @param cardStatus ICC card status as defined by CardStatus in types.hal
    100      */
    101     public void getIccCardStatusResponse(RadioResponseInfo responseInfo, CardStatus cardStatus) {
    102         responseIccCardStatus(responseInfo, cardStatus);
    103     }
    104 
    105     /**
    106      * @param responseInfo Response info struct containing response type, serial no. and error
    107      * @param cardStatus ICC card status as defined by CardStatus in 1.2/types.hal
    108      */
    109     public void getIccCardStatusResponse_1_2(RadioResponseInfo responseInfo,
    110                                              android.hardware.radio.V1_2.CardStatus cardStatus) {
    111         responseIccCardStatus_1_2(responseInfo, cardStatus);
    112     }
    113 
    114     /**
    115      * @param responseInfo Response info struct containing response type, serial no. and error
    116      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
    117      */
    118     public void supplyIccPinForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
    119         responseInts(responseInfo, remainingAttempts);
    120     }
    121 
    122     /**
    123      * @param responseInfo Response info struct containing response type, serial no. and error
    124      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
    125      */
    126     public void supplyIccPukForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
    127         responseInts(responseInfo, remainingAttempts);
    128     }
    129 
    130     /**
    131      * @param responseInfo Response info struct containing response type, serial no. and error
    132      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
    133      */
    134     public void supplyIccPin2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
    135         responseInts(responseInfo, remainingAttempts);
    136     }
    137 
    138     /**
    139      * @param responseInfo Response info struct containing response type, serial no. and error
    140      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
    141      */
    142     public void supplyIccPuk2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
    143         responseInts(responseInfo, remainingAttempts);
    144     }
    145 
    146     /**
    147      * @param responseInfo Response info struct containing response type, serial no. and error
    148      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
    149      */
    150     public void changeIccPinForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
    151         responseInts(responseInfo, remainingAttempts);
    152     }
    153 
    154     /**
    155      * @param responseInfo Response info struct containing response type, serial no. and error
    156      * @param remainingAttempts Number of retries remaining, must be equal to -1 if unknown.
    157      */
    158     public void changeIccPin2ForAppResponse(RadioResponseInfo responseInfo, int remainingAttempts) {
    159         responseInts(responseInfo, remainingAttempts);
    160     }
    161 
    162     /**
    163      * @param responseInfo Response info struct containing response type, serial no. and error
    164      * @param retriesRemaining Number of retries remaining, must be equal to -1 if unknown.
    165      */
    166     public void supplyNetworkDepersonalizationResponse(RadioResponseInfo responseInfo,
    167                                                        int retriesRemaining) {
    168         responseInts(responseInfo, retriesRemaining);
    169     }
    170 
    171     /**
    172      * @param responseInfo Response info struct containing response type, serial no. and error
    173      * @param calls Current call list
    174      */
    175     public void getCurrentCallsResponse(RadioResponseInfo responseInfo,
    176                                         ArrayList<android.hardware.radio.V1_0.Call> calls) {
    177         responseCurrentCalls(responseInfo, calls);
    178     }
    179 
    180     /**
    181      * @param responseInfo Response info struct containing response type, serial no. and error
    182      * @param calls Current call list
    183      */
    184     public void getCurrentCallsResponse_1_2(RadioResponseInfo responseInfo,
    185                                         ArrayList<android.hardware.radio.V1_2.Call> calls) {
    186         responseCurrentCalls_1_2(responseInfo, calls);
    187     }
    188 
    189     /**
    190      * @param responseInfo Response info struct containing response type, serial no. and error
    191      */
    192     public void dialResponse(RadioResponseInfo responseInfo) {
    193         responseVoid(responseInfo);
    194     }
    195 
    196     /**
    197      * @param responseInfo Response info struct containing response type, serial no. and error
    198      * @param imsi String containing the IMSI
    199      */
    200     public void getIMSIForAppResponse(RadioResponseInfo responseInfo, String imsi) {
    201         responseString(responseInfo, imsi);
    202     }
    203 
    204     /**
    205      * @param responseInfo Response info struct containing response type, serial no. and error
    206      */
    207     public void hangupConnectionResponse(RadioResponseInfo responseInfo) {
    208         responseVoid(responseInfo);
    209     }
    210 
    211     /**
    212      * @param responseInfo Response info struct containing response type, serial no. and error
    213      */
    214     public void hangupWaitingOrBackgroundResponse(RadioResponseInfo responseInfo) {
    215         responseVoid(responseInfo);
    216     }
    217 
    218     /**
    219      * @param responseInfo Response info struct containing response type, serial no. and error
    220      */
    221     public void hangupForegroundResumeBackgroundResponse(RadioResponseInfo responseInfo) {
    222         responseVoid(responseInfo);
    223     }
    224 
    225     /**
    226      * @param responseInfo Response info struct containing response type, serial no. and error
    227      */
    228     public void switchWaitingOrHoldingAndActiveResponse(RadioResponseInfo responseInfo) {
    229         responseVoid(responseInfo);
    230     }
    231 
    232     /**
    233      * @param responseInfo Response info struct containing response type, serial no. and error
    234      */
    235     public void conferenceResponse(RadioResponseInfo responseInfo) {
    236         responseVoid(responseInfo);
    237     }
    238 
    239     /**
    240      * @param responseInfo Response info struct containing response type, serial no. and error
    241      */
    242     public void rejectCallResponse(RadioResponseInfo responseInfo) {
    243         responseVoid(responseInfo);
    244     }
    245 
    246     /**
    247      * @param responseInfo Response info struct containing response type, serial no. and error
    248      * @param fcInfo Contains LastCallFailCause and vendor cause code. GSM failure reasons
    249      *        are mapped to cause codes defined in TS 24.008 Annex H where possible. CDMA
    250      *        failure reasons are derived from the possible call failure scenarios
    251      *        described in the "CDMA IS-2000 Release A (C.S0005-A v6.0)" standard.
    252      */
    253     public void getLastCallFailCauseResponse(RadioResponseInfo responseInfo,
    254                                              LastCallFailCauseInfo fcInfo) {
    255         responseLastCallFailCauseInfo(responseInfo, fcInfo);
    256     }
    257 
    258     public void getSignalStrengthResponse(RadioResponseInfo responseInfo,
    259                                           android.hardware.radio.V1_0.SignalStrength sigStrength) {
    260         responseSignalStrength(responseInfo, sigStrength);
    261     }
    262 
    263     /**
    264      * @param responseInfo Response info struct containing response type, serial no. and error
    265      * @param signalStrength Current signal strength of camped/connected cells
    266      */
    267     public void getSignalStrengthResponse_1_2(
    268             RadioResponseInfo responseInfo,
    269             android.hardware.radio.V1_2.SignalStrength signalStrength) {
    270         responseSignalStrength_1_2(responseInfo, signalStrength);
    271     }
    272 
    273     /**
    274      * @param responseInfo Response info struct containing response type, serial no. and error
    275      * @param voiceRegResponse Current Voice registration response as defined by VoiceRegStateResult
    276      *        in types.hal
    277      */
    278     public void getVoiceRegistrationStateResponse(RadioResponseInfo responseInfo,
    279                                                   VoiceRegStateResult voiceRegResponse) {
    280         RILRequest rr = mRil.processResponse(responseInfo);
    281 
    282         if (rr != null) {
    283             if (responseInfo.error == RadioError.NONE) {
    284                 sendMessageResponse(rr.mResult, voiceRegResponse);
    285             }
    286             mRil.processResponseDone(rr, responseInfo, voiceRegResponse);
    287         }
    288     }
    289 
    290     /**
    291      * @param responseInfo Response info struct containing response type, serial no. and error
    292      * @param voiceRegResponse Current Voice registration response as defined by VoiceRegStateResult
    293      *        in 1.2/types.hal
    294      */
    295     public void getVoiceRegistrationStateResponse_1_2(RadioResponseInfo responseInfo,
    296             android.hardware.radio.V1_2.VoiceRegStateResult voiceRegResponse) {
    297         RILRequest rr = mRil.processResponse(responseInfo);
    298 
    299         if (rr != null) {
    300             if (responseInfo.error == RadioError.NONE) {
    301                 sendMessageResponse(rr.mResult, voiceRegResponse);
    302             }
    303             mRil.processResponseDone(rr, responseInfo, voiceRegResponse);
    304         }
    305     }
    306 
    307     /**
    308      * @param responseInfo Response info struct containing response type, serial no. and error
    309      * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
    310      *        types.hal
    311      */
    312     public void getDataRegistrationStateResponse(RadioResponseInfo responseInfo,
    313                                                  DataRegStateResult dataRegResponse) {
    314         RILRequest rr = mRil.processResponse(responseInfo);
    315 
    316         if (rr != null) {
    317             if (responseInfo.error == RadioError.NONE) {
    318                 sendMessageResponse(rr.mResult, dataRegResponse);
    319             }
    320             mRil.processResponseDone(rr, responseInfo, dataRegResponse);
    321         }
    322     }
    323 
    324     /**
    325      * @param responseInfo Response info struct containing response type, serial no. and error
    326      * @param dataRegResponse Current Data registration response as defined by DataRegStateResult in
    327      *        1.2/types.hal
    328      */
    329     public void getDataRegistrationStateResponse_1_2(RadioResponseInfo responseInfo,
    330             android.hardware.radio.V1_2.DataRegStateResult dataRegResponse) {
    331         RILRequest rr = mRil.processResponse(responseInfo);
    332 
    333         if (rr != null) {
    334             if (responseInfo.error == RadioError.NONE) {
    335                 sendMessageResponse(rr.mResult, dataRegResponse);
    336             }
    337             mRil.processResponseDone(rr, responseInfo, dataRegResponse);
    338         }
    339     }
    340 
    341     /**
    342      * @param responseInfo Response info struct containing response type, serial no. and error
    343      * @param longName is long alpha ONS or EONS or empty string if unregistered
    344      * @param shortName is short alpha ONS or EONS or empty string if unregistered
    345      * @param numeric is 5 or 6 digit numeric code (MCC + MNC) or empty string if unregistered
    346      */
    347     public void getOperatorResponse(RadioResponseInfo responseInfo,
    348                                     String longName,
    349                                     String shortName,
    350                                     String numeric) {
    351         responseStrings(responseInfo, longName, shortName, numeric);
    352     }
    353 
    354     /**
    355      * @param responseInfo Response info struct containing response type, serial no. and error
    356      */
    357     public void setRadioPowerResponse(RadioResponseInfo responseInfo) {
    358         responseVoid(responseInfo);
    359     }
    360 
    361     /**
    362      * @param responseInfo Response info struct containing response type, serial no. and error
    363      */
    364     public void sendDtmfResponse(RadioResponseInfo responseInfo) {
    365         responseVoid(responseInfo);
    366     }
    367 
    368     /**
    369      * @param responseInfo Response info struct containing response type, serial no. and error
    370      * @param sms Response to sms sent as defined by SendSmsResult in types.hal
    371      */
    372     public void sendSmsResponse(RadioResponseInfo responseInfo,
    373                                 SendSmsResult sms) {
    374         responseSms(responseInfo, sms);
    375     }
    376 
    377     /**
    378      * @param responseInfo Response info struct containing response type, serial no. and error
    379      * @param sms Response to sms sent as defined by SendSmsResult in types.hal
    380      */
    381     public void sendSMSExpectMoreResponse(RadioResponseInfo responseInfo,
    382                                           SendSmsResult sms) {
    383         responseSms(responseInfo, sms);
    384     }
    385 
    386     /**
    387      * @param responseInfo Response info struct containing response type, serial no. and error
    388      * @param setupDataCallResult Response to data call setup as defined by setupDataCallResult in
    389      *                            types.hal
    390      */
    391     public void setupDataCallResponse(RadioResponseInfo responseInfo,
    392                                       SetupDataCallResult setupDataCallResult) {
    393         responseSetupDataCall(responseInfo, setupDataCallResult);
    394     }
    395 
    396     /**
    397      * @param responseInfo Response info struct containing response type, serial no. and error
    398      * @param iccIo ICC io operation response as defined by IccIoResult in types.hal
    399      */
    400     public void iccIOForAppResponse(RadioResponseInfo responseInfo,
    401                             android.hardware.radio.V1_0.IccIoResult iccIo) {
    402         responseIccIo(responseInfo, iccIo);
    403     }
    404 
    405     /**
    406      * @param responseInfo Response info struct containing response type, serial no. and error
    407      */
    408     public void sendUssdResponse(RadioResponseInfo responseInfo) {
    409         responseVoid(responseInfo);
    410     }
    411 
    412     /**
    413      * @param responseInfo Response info struct containing response type, serial no. and error
    414      */
    415     public void cancelPendingUssdResponse(RadioResponseInfo responseInfo) {
    416         responseVoid(responseInfo);
    417     }
    418 
    419     /**
    420      * @param responseInfo Response info struct containing response type, serial no. and error
    421      * @param n is "n" parameter from TS 27.007 7.7
    422      * @param m is "m" parameter from TS 27.007 7.7
    423      */
    424     public void getClirResponse(RadioResponseInfo responseInfo, int n, int m) {
    425         responseInts(responseInfo, n, m);
    426     }
    427 
    428     /**
    429      * @param responseInfo Response info struct containing response type, serial no. and error
    430      */
    431     public void setClirResponse(RadioResponseInfo responseInfo) {
    432         responseVoid(responseInfo);
    433     }
    434 
    435     /**
    436      * @param responseInfo Response info struct containing response type, serial no. and error
    437      * @param callForwardInfos points to a vector of CallForwardInfo, one for
    438      *        each distinct registered phone number.
    439      */
    440     public void getCallForwardStatusResponse(RadioResponseInfo responseInfo,
    441                                              ArrayList<android.hardware.radio.V1_0.CallForwardInfo>
    442                                                      callForwardInfos) {
    443         responseCallForwardInfo(responseInfo, callForwardInfos);
    444     }
    445 
    446     /**
    447      * @param responseInfo Response info struct containing response type, serial no. and error
    448      */
    449     public void setCallForwardResponse(RadioResponseInfo responseInfo) {
    450         responseVoid(responseInfo);
    451     }
    452 
    453     /**
    454      * @param responseInfo Response info struct containing response type, serial no. and error
    455      * @param enable If current call waiting state is disabled, enable = false else true
    456      * @param serviceClass If enable, then callWaitingResp[1]
    457      *        must follow, with the TS 27.007 service class bit vector of services
    458      *        for which call waiting is enabled.
    459      *        For example, if callWaitingResp[0] is 1 and
    460      *        callWaitingResp[1] is 3, then call waiting is enabled for data
    461      *        and voice and disabled for everything else.
    462      */
    463     public void getCallWaitingResponse(RadioResponseInfo responseInfo,
    464                                    boolean enable,
    465                                    int serviceClass) {
    466         responseInts(responseInfo, enable ? 1 : 0, serviceClass);
    467     }
    468 
    469     /**
    470      * @param responseInfo Response info struct containing response type, serial no. and error
    471      */
    472     public void setCallWaitingResponse(RadioResponseInfo responseInfo) {
    473         responseVoid(responseInfo);
    474     }
    475 
    476     /**
    477      * @param responseInfo Response info struct containing response type, serial no. and error
    478      */
    479     public void acknowledgeLastIncomingGsmSmsResponse(RadioResponseInfo responseInfo) {
    480         responseVoid(responseInfo);
    481     }
    482 
    483     /**
    484      * @param responseInfo Response info struct containing response type, serial no. and error
    485      */
    486     public void acceptCallResponse(RadioResponseInfo responseInfo) {
    487         responseVoid(responseInfo);
    488     }
    489 
    490     /**
    491      * @param responseInfo Response info struct containing response type, serial no. and error
    492      */
    493     public void deactivateDataCallResponse(RadioResponseInfo responseInfo) {
    494         responseVoid(responseInfo);
    495     }
    496 
    497     /**
    498      *
    499      * @param responseInfo Response info struct containing response type, serial no. and error
    500      * @param response 0 is the TS 27.007 service class bit vector of
    501      *        services for which the specified barring facility
    502      *        is active. "0" means "disabled for all"
    503      */
    504     public void getFacilityLockForAppResponse(RadioResponseInfo responseInfo, int response) {
    505         responseInts(responseInfo, response);
    506     }
    507 
    508     /**
    509      *
    510      * @param responseInfo Response info struct containing response type, serial no. and error
    511      * @param retry 0 is the number of retries remaining, or -1 if unknown
    512      */
    513     public void setFacilityLockForAppResponse(RadioResponseInfo responseInfo, int retry) {
    514         responseInts(responseInfo, retry);
    515     }
    516 
    517     /**
    518      * @param responseInfo Response info struct containing response type, serial no. and error
    519      */
    520     public void setBarringPasswordResponse(RadioResponseInfo responseInfo) {
    521         responseVoid(responseInfo);
    522     }
    523 
    524     /**
    525      *
    526      * @param responseInfo Response info struct containing response type, serial no. and error
    527      * @param selection false for automatic selection, true for manual selection
    528      */
    529     public void getNetworkSelectionModeResponse(RadioResponseInfo responseInfo, boolean selection) {
    530         responseInts(responseInfo, selection ? 1 : 0);
    531     }
    532 
    533     /**
    534      * @param responseInfo Response info struct containing response type, serial no. and error
    535      */
    536     public void setNetworkSelectionModeAutomaticResponse(RadioResponseInfo responseInfo) {
    537         responseVoid(responseInfo);
    538     }
    539 
    540     /**
    541      * @param responseInfo Response info struct containing response type, serial no. and error
    542      */
    543     public void setNetworkSelectionModeManualResponse(RadioResponseInfo responseInfo) {
    544         responseVoid(responseInfo);
    545     }
    546 
    547     /**
    548      *
    549      * @param responseInfo Response info struct containing response type, serial no. and error
    550      * @param networkInfos List of network operator information as OperatorInfos defined in
    551      *                     types.hal
    552      */
    553     public void getAvailableNetworksResponse(RadioResponseInfo responseInfo,
    554                                              ArrayList<android.hardware.radio.V1_0.OperatorInfo>
    555                                                      networkInfos) {
    556         responseOperatorInfos(responseInfo, networkInfos);
    557     }
    558 
    559     /**
    560      *
    561      * @param responseInfo Response info struct containing response type, serial no. and error
    562      */
    563     public void startNetworkScanResponse(RadioResponseInfo responseInfo) {
    564         responseScanStatus(responseInfo);
    565     }
    566 
    567     /**
    568      *
    569      * @param responseInfo Response info struct containing response type, serial no. and error
    570      */
    571     public void stopNetworkScanResponse(RadioResponseInfo responseInfo) {
    572         responseScanStatus(responseInfo);
    573     }
    574 
    575     /**
    576      * @param responseInfo Response info struct containing response type, serial no. and error
    577      */
    578     public void startDtmfResponse(RadioResponseInfo responseInfo) {
    579         responseVoid(responseInfo);
    580     }
    581 
    582     /**
    583      * @param responseInfo Response info struct containing response type, serial no. and error
    584      */
    585     public void stopDtmfResponse(RadioResponseInfo responseInfo) {
    586         responseVoid(responseInfo);
    587     }
    588 
    589     /**
    590      *
    591      * @param responseInfo Response info struct containing response type, serial no. and error
    592      * @param version string containing version string for log reporting
    593      */
    594     public void getBasebandVersionResponse(RadioResponseInfo responseInfo, String version) {
    595         responseString(responseInfo, version);
    596     }
    597 
    598     /**
    599      * @param responseInfo Response info struct containing response type, serial no. and error
    600      */
    601     public void separateConnectionResponse(RadioResponseInfo responseInfo) {
    602         responseVoid(responseInfo);
    603     }
    604 
    605     /**
    606      * @param responseInfo Response info struct containing response type, serial no. and error
    607      */
    608     public void setMuteResponse(RadioResponseInfo responseInfo) {
    609         responseVoid(responseInfo);
    610     }
    611 
    612     /**
    613      *
    614      * @param responseInfo Response info struct containing response type, serial no. and error
    615      * @param enable true for "mute enabled" and false for "mute disabled"
    616      */
    617     public void getMuteResponse(RadioResponseInfo responseInfo, boolean enable) {
    618         responseInts(responseInfo, enable ? 1 : 0);
    619     }
    620 
    621     /**
    622      *
    623      * @param responseInfo Response info struct containing response type, serial no. and error
    624      * @param status indicates CLIP status
    625      */
    626     public void getClipResponse(RadioResponseInfo responseInfo, int status) {
    627         responseInts(responseInfo, status);
    628     }
    629 
    630     /**
    631      * @param responseInfo Response info struct containing response type, serial no. and error
    632      * @param dataCallResultList Response to get data call list as defined by setupDataCallResult in
    633      *                           types.hal
    634      */
    635     public void getDataCallListResponse(RadioResponseInfo responseInfo,
    636                                         ArrayList<SetupDataCallResult> dataCallResultList) {
    637         responseDataCallList(responseInfo, dataCallResultList);
    638     }
    639 
    640     public void sendOemRilRequestRawResponse(RadioResponseInfo responseInfo,
    641                                              ArrayList<Byte> var2) {}
    642 
    643     /**
    644      * @param responseInfo Response info struct containing response type, serial no. and error
    645      */
    646     public void setSuppServiceNotificationsResponse(RadioResponseInfo responseInfo) {
    647         responseVoid(responseInfo);
    648     }
    649 
    650     /**
    651      * @param responseInfo Response info struct containing response type, serial no. and error
    652      * @param index record index where the message is stored
    653      */
    654     public void writeSmsToSimResponse(RadioResponseInfo responseInfo, int index) {
    655         responseInts(responseInfo, index);
    656     }
    657 
    658     /**
    659      * @param responseInfo Response info struct containing response type, serial no. and error
    660      */
    661     public void deleteSmsOnSimResponse(RadioResponseInfo responseInfo) {
    662         responseVoid(responseInfo);
    663     }
    664 
    665     /**
    666      * @param responseInfo Response info struct containing response type, serial no. and error
    667      */
    668     public void setBandModeResponse(RadioResponseInfo responseInfo) {
    669         responseVoid(responseInfo);
    670     }
    671 
    672     /**
    673      *
    674      * @param responseInfo Response info struct containing response type, serial no. and error
    675      * @param bandModes List of RadioBandMode listing supported modes
    676      */
    677     public void getAvailableBandModesResponse(RadioResponseInfo responseInfo,
    678                                               ArrayList<Integer> bandModes) {
    679         responseIntArrayList(responseInfo, bandModes);
    680     }
    681 
    682     /**
    683      *
    684      * @param responseInfo Response info struct containing response type, serial no. and error
    685      * @param commandResponse SAT/USAT response in hexadecimal format
    686      *        string starting with first byte of response
    687      */
    688     public void sendEnvelopeResponse(RadioResponseInfo responseInfo, String commandResponse) {
    689         responseString(responseInfo, commandResponse);
    690     }
    691 
    692     /**
    693      * @param responseInfo Response info struct containing response type, serial no. and error
    694      */
    695     public void sendTerminalResponseToSimResponse(RadioResponseInfo responseInfo) {
    696         responseVoid(responseInfo);
    697     }
    698 
    699     /**
    700      * @param responseInfo Response info struct containing response type, serial no. and error
    701      */
    702     public void handleStkCallSetupRequestFromSimResponse(RadioResponseInfo responseInfo) {
    703         responseVoid(responseInfo);
    704     }
    705 
    706     /**
    707      * @param responseInfo Response info struct containing response type, serial no. and error
    708      */
    709     public void explicitCallTransferResponse(RadioResponseInfo responseInfo) {
    710         responseVoid(responseInfo);
    711     }
    712 
    713     /**
    714      * @param responseInfo Response info struct containing response type, serial no. and error
    715      */
    716     public void setPreferredNetworkTypeResponse(RadioResponseInfo responseInfo) {
    717         responseVoid(responseInfo);
    718     }
    719 
    720     /**
    721      *
    722      * @param responseInfo Response info struct containing response type, serial no. and error
    723      * @param nwType RadioPreferredNetworkType defined in types.hal
    724      */
    725     public void getPreferredNetworkTypeResponse(RadioResponseInfo responseInfo, int nwType) {
    726         mRil.mPreferredNetworkType = nwType;
    727         responseInts(responseInfo, nwType);
    728     }
    729 
    730     /**
    731      *
    732      * @param responseInfo Response info struct containing response type, serial no. and error
    733      * @param cells Vector of neighboring radio cell information
    734      */
    735     public void getNeighboringCidsResponse(RadioResponseInfo responseInfo,
    736                                            ArrayList<NeighboringCell> cells) {
    737         responseCellList(responseInfo, cells);
    738     }
    739 
    740     /**
    741      * @param responseInfo Response info struct containing response type, serial no. and error
    742      */
    743     public void setLocationUpdatesResponse(RadioResponseInfo responseInfo) {
    744         responseVoid(responseInfo);
    745     }
    746 
    747     /**
    748      * @param responseInfo Response info struct containing response type, serial no. and error
    749      */
    750     public void setCdmaSubscriptionSourceResponse(RadioResponseInfo responseInfo) {
    751         responseVoid(responseInfo);
    752     }
    753 
    754     /**
    755      * @param responseInfo Response info struct containing response type, serial no. and error
    756      */
    757     public void setCdmaRoamingPreferenceResponse(RadioResponseInfo responseInfo) {
    758         responseVoid(responseInfo);
    759     }
    760 
    761     /**
    762      *
    763      * @param responseInfo Response info struct containing response type, serial no. and error
    764      * @param type CdmaRoamingType defined in types.hal
    765      */
    766     public void getCdmaRoamingPreferenceResponse(RadioResponseInfo responseInfo, int type) {
    767         responseInts(responseInfo, type);
    768     }
    769 
    770     /**
    771      * @param responseInfo Response info struct containing response type, serial no. and error
    772      */
    773     public void setTTYModeResponse(RadioResponseInfo responseInfo) {
    774         responseVoid(responseInfo);
    775     }
    776 
    777     /**
    778      *
    779      * @param responseInfo Response info struct containing response type, serial no. and error
    780      * @param mode TTY mode
    781      */
    782     public void getTTYModeResponse(RadioResponseInfo responseInfo, int mode) {
    783         responseInts(responseInfo, mode);
    784     }
    785 
    786     /**
    787      * @param responseInfo Response info struct containing response type, serial no. and error
    788      */
    789     public void setPreferredVoicePrivacyResponse(RadioResponseInfo responseInfo) {
    790         responseVoid(responseInfo);
    791     }
    792 
    793     /**
    794      *
    795      * @param responseInfo Response info struct containing response type, serial no. and error
    796      * @param enable false for Standard Privacy Mode (Public Long Code Mask)
    797      *        true for Enhanced Privacy Mode (Private Long Code Mask)
    798      */
    799     public void getPreferredVoicePrivacyResponse(RadioResponseInfo responseInfo,
    800                                                  boolean enable) {
    801         responseInts(responseInfo, enable ? 1 : 0);
    802     }
    803 
    804     /**
    805      * @param responseInfo Response info struct containing response type, serial no. and error
    806      */
    807     public void sendCDMAFeatureCodeResponse(RadioResponseInfo responseInfo) {
    808         responseVoid(responseInfo);
    809     }
    810 
    811     /**
    812      * @param responseInfo Response info struct containing response type, serial no. and error
    813      */
    814     public void sendBurstDtmfResponse(RadioResponseInfo responseInfo) {
    815         responseVoid(responseInfo);
    816     }
    817 
    818     /**
    819      *
    820      * @param responseInfo Response info struct containing response type, serial no. and error
    821      * @param sms Sms result struct as defined by SendSmsResult in types.hal
    822      */
    823     public void sendCdmaSmsResponse(RadioResponseInfo responseInfo, SendSmsResult sms) {
    824         responseSms(responseInfo, sms);
    825     }
    826 
    827     /**
    828      * @param responseInfo Response info struct containing response type, serial no. and error
    829      */
    830     public void acknowledgeLastIncomingCdmaSmsResponse(RadioResponseInfo responseInfo) {
    831         responseVoid(responseInfo);
    832     }
    833 
    834     /**
    835      *
    836      * @param responseInfo Response info struct containing response type, serial no. and error
    837      * @param configs Vector of GSM/WCDMA Cell broadcast configs
    838      */
    839     public void getGsmBroadcastConfigResponse(RadioResponseInfo responseInfo,
    840                                               ArrayList<GsmBroadcastSmsConfigInfo> configs) {
    841         responseGmsBroadcastConfig(responseInfo, configs);
    842     }
    843 
    844     /**
    845      * @param responseInfo Response info struct containing response type, serial no. and error
    846      */
    847     public void setGsmBroadcastConfigResponse(RadioResponseInfo responseInfo) {
    848         responseVoid(responseInfo);
    849     }
    850 
    851     /**
    852      * @param responseInfo Response info struct containing response type, serial no. and error
    853      */
    854     public void setGsmBroadcastActivationResponse(RadioResponseInfo responseInfo) {
    855         responseVoid(responseInfo);
    856     }
    857 
    858     /**
    859      *
    860      * @param responseInfo Response info struct containing response type, serial no. and error
    861      * @param configs Vector of CDMA Broadcast SMS configs.
    862      */
    863     public void getCdmaBroadcastConfigResponse(RadioResponseInfo responseInfo,
    864                                                ArrayList<CdmaBroadcastSmsConfigInfo> configs) {
    865         responseCdmaBroadcastConfig(responseInfo, configs);
    866     }
    867 
    868     /**
    869      * @param responseInfo Response info struct containing response type, serial no. and error
    870      */
    871     public void setCdmaBroadcastConfigResponse(RadioResponseInfo responseInfo) {
    872         responseVoid(responseInfo);
    873     }
    874 
    875     /**
    876      * @param responseInfo Response info struct containing response type, serial no. and error
    877      */
    878     public void setCdmaBroadcastActivationResponse(RadioResponseInfo responseInfo) {
    879         responseVoid(responseInfo);
    880     }
    881 
    882     /**
    883      *
    884      * @param responseInfo Response info struct containing response type, serial no. and error
    885      * @param mdn MDN if CDMA subscription is available
    886      * @param hSid is a comma separated list of H_SID (Home SID) if
    887      *        CDMA subscription is available, in decimal format
    888      * @param hNid is a comma separated list of H_NID (Home NID) if
    889      *        CDMA subscription is available, in decimal format
    890      * @param min MIN (10 digits, MIN2+MIN1) if CDMA subscription is available
    891      * @param prl PRL version if CDMA subscription is available
    892      */
    893     public void getCDMASubscriptionResponse(RadioResponseInfo responseInfo, String mdn,
    894                                             String hSid, String hNid, String min, String prl) {
    895         responseStrings(responseInfo, mdn, hSid, hNid, min, prl);
    896     }
    897 
    898     /**
    899      *
    900      * @param responseInfo Response info struct containing response type, serial no. and error
    901      * @param index record index where the cmda sms message is stored
    902      */
    903     public void writeSmsToRuimResponse(RadioResponseInfo responseInfo, int index) {
    904         responseInts(responseInfo, index);
    905     }
    906 
    907     /**
    908      * @param responseInfo Response info struct containing response type, serial no. and error
    909      */
    910     public void deleteSmsOnRuimResponse(RadioResponseInfo responseInfo) {
    911         responseVoid(responseInfo);
    912     }
    913 
    914     /**
    915      * @param responseInfo Response info struct containing response type, serial no. and error
    916      * @param imei IMEI if GSM subscription is available
    917      * @param imeisv IMEISV if GSM subscription is available
    918      * @param esn ESN if CDMA subscription is available
    919      * @param meid MEID if CDMA subscription is available
    920      */
    921     public void getDeviceIdentityResponse(RadioResponseInfo responseInfo, String imei,
    922                                           String imeisv, String esn, String meid) {
    923         responseStrings(responseInfo, imei, imeisv, esn, meid);
    924     }
    925 
    926     /**
    927      * @param responseInfo Response info struct containing response type, serial no. and error
    928      */
    929     public void exitEmergencyCallbackModeResponse(RadioResponseInfo responseInfo) {
    930         responseVoid(responseInfo);
    931     }
    932 
    933     /**
    934      * @param responseInfo Response info struct containing response type, serial no. and error
    935      * @param smsc Short Message Service Center address on the device
    936      */
    937     public void getSmscAddressResponse(RadioResponseInfo responseInfo, String smsc) {
    938         responseString(responseInfo, smsc);
    939     }
    940 
    941     /**
    942      * @param responseInfo Response info struct containing response type, serial no. and error
    943      */
    944     public void setSmscAddressResponse(RadioResponseInfo responseInfo) {
    945         responseVoid(responseInfo);
    946     }
    947 
    948     /**
    949      * @param responseInfo Response info struct containing response type, serial no. and error
    950      */
    951     public void reportSmsMemoryStatusResponse(RadioResponseInfo responseInfo) {
    952         responseVoid(responseInfo);
    953     }
    954 
    955     /**
    956      * @param responseInfo Response info struct containing response type, serial no. and error
    957      */
    958     public void reportStkServiceIsRunningResponse(RadioResponseInfo responseInfo) {
    959         responseVoid(responseInfo);
    960     }
    961 
    962     /**
    963      *
    964      * @param responseInfo Response info struct containing response type, serial no. and error
    965      * @param source CDMA subscription source
    966      */
    967     public void getCdmaSubscriptionSourceResponse(RadioResponseInfo responseInfo, int source) {
    968         responseInts(responseInfo, source);
    969     }
    970 
    971     /**
    972      * This method is deprecated and should not be used.
    973      *
    974      * @param responseInfo Response info struct containing response type, serial no. and error
    975      * @param response response string of the challenge/response algo for ISIM auth in base64 format
    976      */
    977     public void requestIsimAuthenticationResponse(RadioResponseInfo responseInfo, String response) {
    978         throw new RuntimeException("Inexplicable response received for requestIsimAuthentication");
    979     }
    980 
    981     /**
    982      * @param responseInfo Response info struct containing response type, serial no. and error
    983      */
    984     public void acknowledgeIncomingGsmSmsWithPduResponse(RadioResponseInfo responseInfo) {
    985         responseVoid(responseInfo);
    986     }
    987 
    988     /**
    989      *
    990      * @param responseInfo Response info struct containing response type, serial no. and error
    991      * @param iccIo IccIoResult as defined in types.hal corresponding to ICC IO response
    992      */
    993     public void sendEnvelopeWithStatusResponse(RadioResponseInfo responseInfo,
    994                                                android.hardware.radio.V1_0.IccIoResult iccIo) {
    995         responseIccIo(responseInfo, iccIo);
    996     }
    997 
    998     /**
    999      *
   1000      * @param responseInfo Response info struct containing response type, serial no. and error
   1001      * @param rat Current voice RAT
   1002      */
   1003     public void getVoiceRadioTechnologyResponse(RadioResponseInfo responseInfo, int rat) {
   1004         responseInts(responseInfo, rat);
   1005     }
   1006 
   1007     public void getCellInfoListResponse(RadioResponseInfo responseInfo,
   1008                                         ArrayList<android.hardware.radio.V1_0.CellInfo> cellInfo) {
   1009         responseCellInfoList(responseInfo, cellInfo);
   1010     }
   1011 
   1012     /**
   1013      * @param responseInfo Response info struct containing response type, serial no. and error
   1014      * @param cellInfo List of current cell information known to radio
   1015      */
   1016     public void getCellInfoListResponse_1_2(
   1017             RadioResponseInfo responseInfo,
   1018             ArrayList<android.hardware.radio.V1_2.CellInfo> cellInfo) {
   1019         responseCellInfoList_1_2(responseInfo, cellInfo);
   1020     }
   1021 
   1022     /**
   1023      * @param responseInfo Response info struct containing response type, serial no. and error
   1024      */
   1025     public void setCellInfoListRateResponse(RadioResponseInfo responseInfo) {
   1026         responseVoid(responseInfo);
   1027     }
   1028 
   1029     /**
   1030      * @param responseInfo Response info struct containing response type, serial no. and error
   1031      */
   1032     public void setInitialAttachApnResponse(RadioResponseInfo responseInfo) {
   1033         responseVoid(responseInfo);
   1034     }
   1035 
   1036     /**
   1037      *
   1038      * @param responseInfo Response info struct containing response type, serial no. and error
   1039      * @param isRegistered false = not registered, true = registered
   1040      * @param ratFamily RadioTechnologyFamily as defined in types.hal. This value is valid only if
   1041      *        isRegistered is true.
   1042      */
   1043     public void getImsRegistrationStateResponse(RadioResponseInfo responseInfo,
   1044                                                 boolean isRegistered, int ratFamily) {
   1045         responseInts(responseInfo, isRegistered ? 1 : 0, ratFamily);
   1046     }
   1047 
   1048     /**
   1049      *
   1050      * @param responseInfo Response info struct containing response type, serial no. and error
   1051      * @param sms Response to sms sent as defined by SendSmsResult in types.hal
   1052      */
   1053     public void sendImsSmsResponse(RadioResponseInfo responseInfo, SendSmsResult sms) {
   1054         responseSms(responseInfo, sms);
   1055     }
   1056 
   1057     /**
   1058      *
   1059      * @param responseInfo Response info struct containing response type, serial no. and error
   1060      * @param result IccIoResult as defined in types.hal
   1061      */
   1062     public void iccTransmitApduBasicChannelResponse(RadioResponseInfo responseInfo,
   1063                                                     android.hardware.radio.V1_0.IccIoResult
   1064                                                             result) {
   1065         responseIccIo(responseInfo, result);
   1066     }
   1067 
   1068     /**
   1069      *
   1070      * @param responseInfo Response info struct containing response type, serial no. and error
   1071      * @param channelId session id of the logical channel.
   1072      * @param selectResponse Contains the select response for the open channel command with one
   1073      *        byte per integer
   1074      */
   1075     public void iccOpenLogicalChannelResponse(RadioResponseInfo responseInfo, int channelId,
   1076                                               ArrayList<Byte> selectResponse) {
   1077         ArrayList<Integer> arr = new ArrayList<>();
   1078         arr.add(channelId);
   1079         for (int i = 0; i < selectResponse.size(); i++) {
   1080             arr.add((int) selectResponse.get(i));
   1081         }
   1082         responseIntArrayList(responseInfo, arr);
   1083     }
   1084 
   1085     /**
   1086      * @param responseInfo Response info struct containing response type, serial no. and error
   1087      */
   1088     public void iccCloseLogicalChannelResponse(RadioResponseInfo responseInfo) {
   1089         responseVoid(responseInfo);
   1090     }
   1091 
   1092     /**
   1093      *
   1094      * @param responseInfo Response info struct containing response type, serial no. and error
   1095      * @param result IccIoResult as defined in types.hal
   1096      */
   1097     public void iccTransmitApduLogicalChannelResponse(
   1098             RadioResponseInfo responseInfo,
   1099             android.hardware.radio.V1_0.IccIoResult result) {
   1100         responseIccIo(responseInfo, result);
   1101     }
   1102 
   1103     /**
   1104      *
   1105      * @param responseInfo Response info struct containing response type, serial no. and error
   1106      * @param result string containing the contents of the NV item
   1107      */
   1108     public void nvReadItemResponse(RadioResponseInfo responseInfo, String result) {
   1109         responseString(responseInfo, result);
   1110     }
   1111 
   1112     /**
   1113      * @param responseInfo Response info struct containing response type, serial no. and error
   1114      */
   1115     public void nvWriteItemResponse(RadioResponseInfo responseInfo) {
   1116         responseVoid(responseInfo);
   1117     }
   1118 
   1119     /**
   1120      * @param responseInfo Response info struct containing response type, serial no. and error
   1121      */
   1122     public void nvWriteCdmaPrlResponse(RadioResponseInfo responseInfo) {
   1123         responseVoid(responseInfo);
   1124     }
   1125 
   1126     /**
   1127      * @param responseInfo Response info struct containing response type, serial no. and error
   1128      */
   1129     public void nvResetConfigResponse(RadioResponseInfo responseInfo) {
   1130         responseVoid(responseInfo);
   1131     }
   1132 
   1133     /**
   1134      * @param responseInfo Response info struct containing response type, serial no. and error
   1135      */
   1136     public void setUiccSubscriptionResponse(RadioResponseInfo responseInfo) {
   1137         responseVoid(responseInfo);
   1138     }
   1139 
   1140     /**
   1141      * @param responseInfo Response info struct containing response type, serial no. and error
   1142      */
   1143     public void setDataAllowedResponse(RadioResponseInfo responseInfo) {
   1144         responseVoid(responseInfo);
   1145     }
   1146 
   1147     public void getHardwareConfigResponse(
   1148             RadioResponseInfo responseInfo,
   1149             ArrayList<android.hardware.radio.V1_0.HardwareConfig> config) {
   1150         responseHardwareConfig(responseInfo, config);
   1151     }
   1152 
   1153     /**
   1154      *
   1155      * @param responseInfo Response info struct containing response type, serial no. and error
   1156      * @param result IccIoResult as defined in types.hal
   1157      */
   1158     public void requestIccSimAuthenticationResponse(RadioResponseInfo responseInfo,
   1159                                                     android.hardware.radio.V1_0.IccIoResult
   1160                                                             result) {
   1161         responseICC_IOBase64(responseInfo, result);
   1162     }
   1163 
   1164     /**
   1165      * @param responseInfo Response info struct containing response type, serial no. and error
   1166      */
   1167     public void setDataProfileResponse(RadioResponseInfo responseInfo) {
   1168         responseVoid(responseInfo);
   1169     }
   1170 
   1171     /**
   1172      * @param responseInfo Response info struct containing response type, serial no. and error
   1173      */
   1174     public void requestShutdownResponse(RadioResponseInfo responseInfo) {
   1175         responseVoid(responseInfo);
   1176     }
   1177 
   1178     public void getRadioCapabilityResponse(RadioResponseInfo responseInfo,
   1179                                            android.hardware.radio.V1_0.RadioCapability rc) {
   1180         RILRequest rr = mRil.processResponse(responseInfo);
   1181 
   1182         if (rr != null) {
   1183             RadioCapability ret = RIL.convertHalRadioCapability(rc, mRil);
   1184             if (responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED
   1185                     || responseInfo.error == RadioError.GENERIC_FAILURE) {
   1186                 // we should construct the RAF bitmask the radio
   1187                 // supports based on preferred network bitmasks
   1188                 ret = mRil.makeStaticRadioCapability();
   1189                 responseInfo.error = RadioError.NONE;
   1190             }
   1191             if (responseInfo.error == RadioError.NONE) {
   1192                 sendMessageResponse(rr.mResult, ret);
   1193             }
   1194             mRil.processResponseDone(rr, responseInfo, ret);
   1195         }
   1196     }
   1197 
   1198     public void setRadioCapabilityResponse(RadioResponseInfo responseInfo,
   1199                                            android.hardware.radio.V1_0.RadioCapability rc) {
   1200         responseRadioCapability(responseInfo, rc);
   1201     }
   1202 
   1203     /**
   1204      *
   1205      * @param responseInfo Response info struct containing response type, serial no. and error
   1206      * @param statusInfo LceStatusInfo indicating LCE status
   1207      */
   1208     public void startLceServiceResponse(RadioResponseInfo responseInfo, LceStatusInfo statusInfo) {
   1209         responseLceStatus(responseInfo, statusInfo);
   1210     }
   1211 
   1212     /**
   1213      *
   1214      * @param responseInfo Response info struct containing response type, serial no. and error
   1215      * @param statusInfo LceStatusInfo indicating LCE status
   1216      */
   1217     public void stopLceServiceResponse(RadioResponseInfo responseInfo, LceStatusInfo statusInfo) {
   1218         responseLceStatus(responseInfo, statusInfo);
   1219     }
   1220 
   1221     public void pullLceDataResponse(RadioResponseInfo responseInfo, LceDataInfo lceInfo) {
   1222         responseLceData(responseInfo, lceInfo);
   1223     }
   1224 
   1225     /**
   1226      *
   1227      * @param responseInfo Response info struct containing response type, serial no. and error
   1228      * @param activityInfo modem activity information
   1229      */
   1230     public void getModemActivityInfoResponse(RadioResponseInfo responseInfo,
   1231                                              ActivityStatsInfo activityInfo) {
   1232         responseActivityData(responseInfo, activityInfo);
   1233     }
   1234 
   1235     /**
   1236      *
   1237      * @param responseInfo Response info struct containing response type, serial no. and error
   1238      * @param numAllowed number of allowed carriers which have been set correctly.
   1239      *        On success, it must match the length of list Carriers->allowedCarriers.
   1240      *        if Length of allowed carriers list is 0, numAllowed = 0.
   1241      */
   1242     public void setAllowedCarriersResponse(RadioResponseInfo responseInfo, int numAllowed) {
   1243         responseInts(responseInfo, numAllowed);
   1244     }
   1245 
   1246     /**
   1247      *
   1248      * @param responseInfo Response info struct containing response type, serial no. and error
   1249      * @param allAllowed true only when all carriers are allowed. Ignore "carriers" struct.
   1250      *                   If false, consider "carriers" struct
   1251      * @param carriers Carrier restriction information.
   1252      */
   1253     public void getAllowedCarriersResponse(RadioResponseInfo responseInfo, boolean allAllowed,
   1254                                            CarrierRestrictions carriers) {
   1255         responseCarrierIdentifiers(responseInfo, allAllowed, carriers);
   1256     }
   1257 
   1258     /**
   1259      * @param responseInfo Response info struct containing response type, serial no. and error
   1260      */
   1261     public void sendDeviceStateResponse(RadioResponseInfo responseInfo) {
   1262         responseVoid(responseInfo);
   1263     }
   1264 
   1265     /**
   1266      * @param responseInfo Response info struct containing response type, serial no. and error
   1267      */
   1268     public void setCarrierInfoForImsiEncryptionResponse(RadioResponseInfo responseInfo) {
   1269         responseVoid(responseInfo);
   1270     }
   1271 
   1272     /**
   1273      * @param responseInfo Response info struct containing response type, serial no. and error
   1274      */
   1275     public void setIndicationFilterResponse(RadioResponseInfo responseInfo) {
   1276         responseVoid(responseInfo);
   1277     }
   1278 
   1279     /**
   1280      * @param responseInfo Response info struct containing response type, serial no. and error
   1281      */
   1282     public void setSimCardPowerResponse(RadioResponseInfo responseInfo) {
   1283         responseVoid(responseInfo);
   1284     }
   1285 
   1286     /**
   1287      * @param responseInfo Response info struct containing response type, serial no. and error
   1288      */
   1289     public void setSignalStrengthReportingCriteriaResponse(RadioResponseInfo responseInfo) {
   1290         responseVoid(responseInfo);
   1291     }
   1292 
   1293     /**
   1294      * @param responseInfo Response info struct containing response type, serial no. and error
   1295      */
   1296     public void setLinkCapacityReportingCriteriaResponse(RadioResponseInfo responseInfo) {
   1297         responseVoid(responseInfo);
   1298     }
   1299 
   1300     /**
   1301      * @param responseInfo Response info struct containing response type, serial no. and error
   1302      */
   1303     public void setSimCardPowerResponse_1_1(RadioResponseInfo responseInfo) {
   1304         responseVoid(responseInfo);
   1305     }
   1306 
   1307 
   1308     /**
   1309      * @param responseInfo Response info struct containing response type, serial no. and error
   1310      * @param keepaliveStatus status of the keepalive with a handle for the session
   1311      */
   1312     public void startKeepaliveResponse(RadioResponseInfo responseInfo,
   1313             android.hardware.radio.V1_1.KeepaliveStatus keepaliveStatus) {
   1314 
   1315         RILRequest rr = mRil.processResponse(responseInfo);
   1316 
   1317         if (rr == null) {
   1318             return;
   1319         }
   1320 
   1321         KeepaliveStatus ret = null;
   1322 
   1323         switch(responseInfo.error) {
   1324             case RadioError.NONE:
   1325                 int convertedStatus = convertHalKeepaliveStatusCode(keepaliveStatus.code);
   1326                 if (convertedStatus < 0) {
   1327                     ret = new KeepaliveStatus(KeepaliveStatus.ERROR_UNSUPPORTED);
   1328                 } else {
   1329                     ret = new KeepaliveStatus(keepaliveStatus.sessionHandle, convertedStatus);
   1330                 }
   1331                 break;
   1332             case RadioError.REQUEST_NOT_SUPPORTED:
   1333                 ret = new KeepaliveStatus(KeepaliveStatus.ERROR_UNSUPPORTED);
   1334                 // The request is unsupported, which is ok. We'll report it to the higher
   1335                 // layer and treat it as acceptable in the RIL.
   1336                 responseInfo.error = RadioError.NONE;
   1337                 break;
   1338             case RadioError.NO_RESOURCES:
   1339                 ret = new KeepaliveStatus(KeepaliveStatus.ERROR_NO_RESOURCES);
   1340                 break;
   1341             default:
   1342                 ret = new KeepaliveStatus(KeepaliveStatus.ERROR_UNKNOWN);
   1343                 break;
   1344         }
   1345         sendMessageResponse(rr.mResult, ret);
   1346         mRil.processResponseDone(rr, responseInfo, ret);
   1347     }
   1348 
   1349     /**
   1350      * @param responseInfo Response info struct containing response type, serial no. and error
   1351      */
   1352     public void stopKeepaliveResponse(RadioResponseInfo responseInfo) {
   1353         RILRequest rr = mRil.processResponse(responseInfo);
   1354 
   1355         if (rr == null) {
   1356             return;
   1357         }
   1358 
   1359         if (responseInfo.error == RadioError.NONE) {
   1360             sendMessageResponse(rr.mResult, null);
   1361             mRil.processResponseDone(rr, responseInfo, null);
   1362         } else {
   1363             //TODO: Error code translation
   1364         }
   1365     }
   1366 
   1367     private int convertHalKeepaliveStatusCode(int halCode) {
   1368         switch (halCode) {
   1369             case android.hardware.radio.V1_1.KeepaliveStatusCode.ACTIVE:
   1370                 return KeepaliveStatus.STATUS_ACTIVE;
   1371             case android.hardware.radio.V1_1.KeepaliveStatusCode.INACTIVE:
   1372                 return KeepaliveStatus.STATUS_INACTIVE;
   1373             case android.hardware.radio.V1_1.KeepaliveStatusCode.PENDING:
   1374                 return KeepaliveStatus.STATUS_PENDING;
   1375             default:
   1376                 mRil.riljLog("Invalid Keepalive Status" + halCode);
   1377                 return -1;
   1378         }
   1379     }
   1380 
   1381     private IccCardStatus convertHalCardStatus(CardStatus cardStatus) {
   1382         IccCardStatus iccCardStatus = new IccCardStatus();
   1383         iccCardStatus.setCardState(cardStatus.cardState);
   1384         iccCardStatus.setUniversalPinState(cardStatus.universalPinState);
   1385         iccCardStatus.mGsmUmtsSubscriptionAppIndex = cardStatus.gsmUmtsSubscriptionAppIndex;
   1386         iccCardStatus.mCdmaSubscriptionAppIndex = cardStatus.cdmaSubscriptionAppIndex;
   1387         iccCardStatus.mImsSubscriptionAppIndex = cardStatus.imsSubscriptionAppIndex;
   1388         int numApplications = cardStatus.applications.size();
   1389 
   1390         // limit to maximum allowed applications
   1391         if (numApplications
   1392                 > com.android.internal.telephony.uicc.IccCardStatus.CARD_MAX_APPS) {
   1393             numApplications =
   1394                 com.android.internal.telephony.uicc.IccCardStatus.CARD_MAX_APPS;
   1395         }
   1396         iccCardStatus.mApplications = new IccCardApplicationStatus[numApplications];
   1397         for (int i = 0; i < numApplications; i++) {
   1398             AppStatus rilAppStatus = cardStatus.applications.get(i);
   1399             IccCardApplicationStatus appStatus = new IccCardApplicationStatus();
   1400             appStatus.app_type       = appStatus.AppTypeFromRILInt(rilAppStatus.appType);
   1401             appStatus.app_state      = appStatus.AppStateFromRILInt(rilAppStatus.appState);
   1402             appStatus.perso_substate = appStatus.PersoSubstateFromRILInt(
   1403                 rilAppStatus.persoSubstate);
   1404             appStatus.aid            = rilAppStatus.aidPtr;
   1405             appStatus.app_label      = rilAppStatus.appLabelPtr;
   1406             appStatus.pin1_replaced  = rilAppStatus.pin1Replaced;
   1407             appStatus.pin1           = appStatus.PinStateFromRILInt(rilAppStatus.pin1);
   1408             appStatus.pin2           = appStatus.PinStateFromRILInt(rilAppStatus.pin2);
   1409             iccCardStatus.mApplications[i] = appStatus;
   1410             mRil.riljLog("IccCardApplicationStatus " + i + ":" + appStatus.toString());
   1411         }
   1412         return iccCardStatus;
   1413     }
   1414 
   1415     private void responseIccCardStatus(RadioResponseInfo responseInfo, CardStatus cardStatus) {
   1416         RILRequest rr = mRil.processResponse(responseInfo);
   1417 
   1418         if (rr != null) {
   1419             IccCardStatus iccCardStatus = convertHalCardStatus(cardStatus);
   1420             mRil.riljLog("responseIccCardStatus: from HIDL: " + iccCardStatus);
   1421             if (responseInfo.error == RadioError.NONE) {
   1422                 sendMessageResponse(rr.mResult, iccCardStatus);
   1423             }
   1424             mRil.processResponseDone(rr, responseInfo, iccCardStatus);
   1425         }
   1426     }
   1427 
   1428     private void responseIccCardStatus_1_2(RadioResponseInfo responseInfo,
   1429                                            android.hardware.radio.V1_2.CardStatus cardStatus) {
   1430         RILRequest rr = mRil.processResponse(responseInfo);
   1431 
   1432         if (rr != null) {
   1433             IccCardStatus iccCardStatus = convertHalCardStatus(cardStatus.base);
   1434             iccCardStatus.physicalSlotIndex = cardStatus.physicalSlotId;
   1435             iccCardStatus.atr = cardStatus.atr;
   1436             iccCardStatus.iccid = cardStatus.iccid;
   1437             mRil.riljLog("responseIccCardStatus: from HIDL: " + iccCardStatus);
   1438             if (responseInfo.error == RadioError.NONE) {
   1439                 sendMessageResponse(rr.mResult, iccCardStatus);
   1440             }
   1441             mRil.processResponseDone(rr, responseInfo, iccCardStatus);
   1442         }
   1443     }
   1444 
   1445     private void responseInts(RadioResponseInfo responseInfo, int ...var) {
   1446         final ArrayList<Integer> ints = new ArrayList<>();
   1447         for (int i = 0; i < var.length; i++) {
   1448             ints.add(var[i]);
   1449         }
   1450         responseIntArrayList(responseInfo, ints);
   1451     }
   1452 
   1453     private void responseIntArrayList(RadioResponseInfo responseInfo, ArrayList<Integer> var) {
   1454         RILRequest rr = mRil.processResponse(responseInfo);
   1455 
   1456         if (rr != null) {
   1457             int[] ret = new int[var.size()];
   1458             for (int i = 0; i < var.size(); i++) {
   1459                 ret[i] = var.get(i);
   1460             }
   1461             if (responseInfo.error == RadioError.NONE) {
   1462                 sendMessageResponse(rr.mResult, ret);
   1463             }
   1464             mRil.processResponseDone(rr, responseInfo, ret);
   1465         }
   1466     }
   1467 
   1468     private void responseCurrentCalls(RadioResponseInfo responseInfo,
   1469                                       ArrayList<android.hardware.radio.V1_0.Call> calls) {
   1470         RILRequest rr = mRil.processResponse(responseInfo);
   1471 
   1472         if (rr != null) {
   1473             int num = calls.size();
   1474             ArrayList<DriverCall> dcCalls = new ArrayList<DriverCall>(num);
   1475             DriverCall dc;
   1476 
   1477             for (int i = 0; i < num; i++) {
   1478                 dc = new DriverCall();
   1479                 // TODO: change name of function stateFromCLCC() in DriverCall.java to name
   1480                 // clarifying what is CLCC
   1481                 dc.state = DriverCall.stateFromCLCC((int) (calls.get(i).state));
   1482                 dc.index = calls.get(i).index;
   1483                 dc.TOA = calls.get(i).toa;
   1484                 dc.isMpty = calls.get(i).isMpty;
   1485                 dc.isMT = calls.get(i).isMT;
   1486                 dc.als = calls.get(i).als;
   1487                 dc.isVoice = calls.get(i).isVoice;
   1488                 dc.isVoicePrivacy = calls.get(i).isVoicePrivacy;
   1489                 dc.number = calls.get(i).number;
   1490                 dc.numberPresentation =
   1491                         DriverCall.presentationFromCLIP(
   1492                                 (int) (calls.get(i).numberPresentation));
   1493                 dc.name = calls.get(i).name;
   1494                 dc.namePresentation =
   1495                         DriverCall.presentationFromCLIP((int) (calls.get(i).namePresentation));
   1496                 if (calls.get(i).uusInfo.size() == 1) {
   1497                     dc.uusInfo = new UUSInfo();
   1498                     dc.uusInfo.setType(calls.get(i).uusInfo.get(0).uusType);
   1499                     dc.uusInfo.setDcs(calls.get(i).uusInfo.get(0).uusDcs);
   1500                     if (!TextUtils.isEmpty(calls.get(i).uusInfo.get(0).uusData)) {
   1501                         byte[] userData = calls.get(i).uusInfo.get(0).uusData.getBytes();
   1502                         dc.uusInfo.setUserData(userData);
   1503                     } else {
   1504                         mRil.riljLog("responseCurrentCalls: uusInfo data is null or empty");
   1505                     }
   1506 
   1507                     mRil.riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
   1508                             dc.uusInfo.getType(), dc.uusInfo.getDcs(),
   1509                             dc.uusInfo.getUserData().length));
   1510                     mRil.riljLogv("Incoming UUS : data (hex): "
   1511                             + IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
   1512                 } else {
   1513                     mRil.riljLogv("Incoming UUS : NOT present!");
   1514                 }
   1515 
   1516                 // Make sure there's a leading + on addresses with a TOA of 145
   1517                 dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
   1518 
   1519                 dcCalls.add(dc);
   1520 
   1521                 if (dc.isVoicePrivacy) {
   1522                     mRil.mVoicePrivacyOnRegistrants.notifyRegistrants();
   1523                     mRil.riljLog("InCall VoicePrivacy is enabled");
   1524                 } else {
   1525                     mRil.mVoicePrivacyOffRegistrants.notifyRegistrants();
   1526                     mRil.riljLog("InCall VoicePrivacy is disabled");
   1527                 }
   1528             }
   1529 
   1530             Collections.sort(dcCalls);
   1531 
   1532             if ((num == 0) && mRil.mTestingEmergencyCall.getAndSet(false)) {
   1533                 if (mRil.mEmergencyCallbackModeRegistrant != null) {
   1534                     mRil.riljLog("responseCurrentCalls: call ended, testing emergency call,"
   1535                             + " notify ECM Registrants");
   1536                     mRil.mEmergencyCallbackModeRegistrant.notifyRegistrant();
   1537                 }
   1538             }
   1539 
   1540             if (responseInfo.error == RadioError.NONE) {
   1541                 sendMessageResponse(rr.mResult, dcCalls);
   1542             }
   1543             mRil.processResponseDone(rr, responseInfo, dcCalls);
   1544         }
   1545     }
   1546 
   1547     private void responseCurrentCalls_1_2(RadioResponseInfo responseInfo,
   1548                                       ArrayList<android.hardware.radio.V1_2.Call> calls) {
   1549         RILRequest rr = mRil.processResponse(responseInfo);
   1550 
   1551         if (rr != null) {
   1552             int num = calls.size();
   1553             ArrayList<DriverCall> dcCalls = new ArrayList<DriverCall>(num);
   1554             DriverCall dc;
   1555 
   1556             for (int i = 0; i < num; i++) {
   1557                 dc = new DriverCall();
   1558                 // TODO: change name of function stateFromCLCC() in DriverCall.java to name
   1559                 // clarifying what is CLCC
   1560                 dc.state = DriverCall.stateFromCLCC((int) (calls.get(i).base.state));
   1561                 dc.index = calls.get(i).base.index;
   1562                 dc.TOA = calls.get(i).base.toa;
   1563                 dc.isMpty = calls.get(i).base.isMpty;
   1564                 dc.isMT = calls.get(i).base.isMT;
   1565                 dc.als = calls.get(i).base.als;
   1566                 dc.isVoice = calls.get(i).base.isVoice;
   1567                 dc.isVoicePrivacy = calls.get(i).base.isVoicePrivacy;
   1568                 dc.number = calls.get(i).base.number;
   1569                 dc.numberPresentation =
   1570                         DriverCall.presentationFromCLIP(
   1571                                 (int) (calls.get(i).base.numberPresentation));
   1572                 dc.name = calls.get(i).base.name;
   1573                 dc.namePresentation =
   1574                         DriverCall.presentationFromCLIP((int) (calls.get(i).base.namePresentation));
   1575                 if (calls.get(i).base.uusInfo.size() == 1) {
   1576                     dc.uusInfo = new UUSInfo();
   1577                     dc.uusInfo.setType(calls.get(i).base.uusInfo.get(0).uusType);
   1578                     dc.uusInfo.setDcs(calls.get(i).base.uusInfo.get(0).uusDcs);
   1579                     if (!TextUtils.isEmpty(calls.get(i).base.uusInfo.get(0).uusData)) {
   1580                         byte[] userData = calls.get(i).base.uusInfo.get(0).uusData.getBytes();
   1581                         dc.uusInfo.setUserData(userData);
   1582                     } else {
   1583                         mRil.riljLog("responseCurrentCalls: uusInfo data is null or empty");
   1584                     }
   1585 
   1586                     mRil.riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
   1587                             dc.uusInfo.getType(), dc.uusInfo.getDcs(),
   1588                             dc.uusInfo.getUserData().length));
   1589                     mRil.riljLogv("Incoming UUS : data (hex): "
   1590                             + IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
   1591                 } else {
   1592                     mRil.riljLogv("Incoming UUS : NOT present!");
   1593                 }
   1594 
   1595                 // Make sure there's a leading + on addresses with a TOA of 145
   1596                 dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
   1597 
   1598                 dc.audioQuality = (int) (calls.get(i).audioQuality);
   1599 
   1600                 dcCalls.add(dc);
   1601 
   1602                 if (dc.isVoicePrivacy) {
   1603                     mRil.mVoicePrivacyOnRegistrants.notifyRegistrants();
   1604                     mRil.riljLog("InCall VoicePrivacy is enabled");
   1605                 } else {
   1606                     mRil.mVoicePrivacyOffRegistrants.notifyRegistrants();
   1607                     mRil.riljLog("InCall VoicePrivacy is disabled");
   1608                 }
   1609             }
   1610 
   1611             Collections.sort(dcCalls);
   1612 
   1613             if ((num == 0) && mRil.mTestingEmergencyCall.getAndSet(false)) {
   1614                 if (mRil.mEmergencyCallbackModeRegistrant != null) {
   1615                     mRil.riljLog("responseCurrentCalls: call ended, testing emergency call,"
   1616                             + " notify ECM Registrants");
   1617                     mRil.mEmergencyCallbackModeRegistrant.notifyRegistrant();
   1618                 }
   1619             }
   1620 
   1621             if (responseInfo.error == RadioError.NONE) {
   1622                 sendMessageResponse(rr.mResult, dcCalls);
   1623             }
   1624             mRil.processResponseDone(rr, responseInfo, dcCalls);
   1625         }
   1626     }
   1627 
   1628 
   1629     private void responseVoid(RadioResponseInfo responseInfo) {
   1630         RILRequest rr = mRil.processResponse(responseInfo);
   1631 
   1632         if (rr != null) {
   1633             Object ret = null;
   1634             if (responseInfo.error == RadioError.NONE) {
   1635                 sendMessageResponse(rr.mResult, ret);
   1636             }
   1637             mRil.processResponseDone(rr, responseInfo, ret);
   1638         }
   1639     }
   1640 
   1641     private void responseString(RadioResponseInfo responseInfo, String str) {
   1642         RILRequest rr = mRil.processResponse(responseInfo);
   1643 
   1644         if (rr != null) {
   1645             if (responseInfo.error == RadioError.NONE) {
   1646                 sendMessageResponse(rr.mResult, str);
   1647             }
   1648             mRil.processResponseDone(rr, responseInfo, str);
   1649         }
   1650     }
   1651 
   1652     private void responseStrings(RadioResponseInfo responseInfo, String ...str) {
   1653         ArrayList<String> strings = new ArrayList<>();
   1654         for (int i = 0; i < str.length; i++) {
   1655             strings.add(str[i]);
   1656         }
   1657         responseStringArrayList(mRil, responseInfo, strings);
   1658     }
   1659 
   1660     static void responseStringArrayList(RIL ril, RadioResponseInfo responseInfo,
   1661                                         ArrayList<String> strings) {
   1662         RILRequest rr = ril.processResponse(responseInfo);
   1663 
   1664         if (rr != null) {
   1665             String[] ret = new String[strings.size()];
   1666             for (int i = 0; i < strings.size(); i++) {
   1667                 ret[i] = strings.get(i);
   1668             }
   1669             if (responseInfo.error == RadioError.NONE) {
   1670                 sendMessageResponse(rr.mResult, ret);
   1671             }
   1672             ril.processResponseDone(rr, responseInfo, ret);
   1673         }
   1674     }
   1675 
   1676     private void responseLastCallFailCauseInfo(RadioResponseInfo responseInfo,
   1677                                                LastCallFailCauseInfo fcInfo) {
   1678         RILRequest rr = mRil.processResponse(responseInfo);
   1679 
   1680         if (rr != null) {
   1681             LastCallFailCause ret = new LastCallFailCause();
   1682             ret.causeCode = fcInfo.causeCode;
   1683             ret.vendorCause = fcInfo.vendorCause;
   1684             if (responseInfo.error == RadioError.NONE) {
   1685                 sendMessageResponse(rr.mResult, ret);
   1686             }
   1687             mRil.processResponseDone(rr, responseInfo, ret);
   1688         }
   1689     }
   1690 
   1691     private void responseSignalStrength(
   1692             RadioResponseInfo responseInfo,
   1693             android.hardware.radio.V1_0.SignalStrength signalStrength) {
   1694         RILRequest rr = mRil.processResponse(responseInfo);
   1695 
   1696         if (rr != null) {
   1697             SignalStrength ret = RIL.convertHalSignalStrength(signalStrength);
   1698             if (responseInfo.error == RadioError.NONE) {
   1699                 sendMessageResponse(rr.mResult, ret);
   1700             }
   1701             mRil.processResponseDone(rr, responseInfo, ret);
   1702         }
   1703     }
   1704 
   1705     private void responseSignalStrength_1_2(
   1706             RadioResponseInfo responseInfo,
   1707             android.hardware.radio.V1_2.SignalStrength signalStrength) {
   1708         RILRequest rr = mRil.processResponse(responseInfo);
   1709 
   1710         if (rr != null) {
   1711             SignalStrength ret = RIL.convertHalSignalStrength_1_2(signalStrength);
   1712             if (responseInfo.error == RadioError.NONE) {
   1713                 sendMessageResponse(rr.mResult, ret);
   1714             }
   1715             mRil.processResponseDone(rr, responseInfo, ret);
   1716         }
   1717     }
   1718 
   1719     private void responseSms(RadioResponseInfo responseInfo, SendSmsResult sms) {
   1720         RILRequest rr = mRil.processResponse(responseInfo);
   1721 
   1722         if (rr != null) {
   1723             SmsResponse ret = new SmsResponse(sms.messageRef, sms.ackPDU, sms.errorCode);
   1724             if (responseInfo.error == RadioError.NONE) {
   1725                 sendMessageResponse(rr.mResult, ret);
   1726             }
   1727             mRil.processResponseDone(rr, responseInfo, ret);
   1728         }
   1729     }
   1730 
   1731     private void responseSetupDataCall(RadioResponseInfo responseInfo,
   1732                                        SetupDataCallResult setupDataCallResult) {
   1733         RILRequest rr = mRil.processResponse(responseInfo);
   1734 
   1735         if (rr != null) {
   1736             if (responseInfo.error == RadioError.NONE) {
   1737                 sendMessageResponse(rr.mResult, setupDataCallResult);
   1738             }
   1739             mRil.processResponseDone(rr, responseInfo, setupDataCallResult);
   1740         }
   1741     }
   1742 
   1743     private void responseIccIo(RadioResponseInfo responseInfo,
   1744                                android.hardware.radio.V1_0.IccIoResult result) {
   1745         RILRequest rr = mRil.processResponse(responseInfo);
   1746 
   1747         if (rr != null) {
   1748             IccIoResult ret = new IccIoResult(result.sw1, result.sw2, result.simResponse);
   1749             if (responseInfo.error == RadioError.NONE) {
   1750                 sendMessageResponse(rr.mResult, ret);
   1751             }
   1752             mRil.processResponseDone(rr, responseInfo, ret);
   1753         }
   1754     }
   1755 
   1756     private void responseCallForwardInfo(RadioResponseInfo responseInfo,
   1757                                          ArrayList<android.hardware.radio.V1_0.CallForwardInfo>
   1758                                                  callForwardInfos) {
   1759         RILRequest rr = mRil.processResponse(responseInfo);
   1760         if (rr != null) {
   1761             CallForwardInfo[] ret = new CallForwardInfo[callForwardInfos.size()];
   1762             for (int i = 0; i < callForwardInfos.size(); i++) {
   1763                 ret[i] = new CallForwardInfo();
   1764                 ret[i].status = callForwardInfos.get(i).status;
   1765                 ret[i].reason = callForwardInfos.get(i).reason;
   1766                 ret[i].serviceClass = callForwardInfos.get(i).serviceClass;
   1767                 ret[i].toa = callForwardInfos.get(i).toa;
   1768                 ret[i].number = callForwardInfos.get(i).number;
   1769                 ret[i].timeSeconds = callForwardInfos.get(i).timeSeconds;
   1770             }
   1771             if (responseInfo.error == RadioError.NONE) {
   1772                 sendMessageResponse(rr.mResult, ret);
   1773             }
   1774             mRil.processResponseDone(rr, responseInfo, ret);
   1775         }
   1776     }
   1777 
   1778     private static String convertOpertatorInfoToString(int status) {
   1779         if (status == android.hardware.radio.V1_0.OperatorStatus.UNKNOWN) {
   1780             return "unknown";
   1781         } else if (status == android.hardware.radio.V1_0.OperatorStatus.AVAILABLE) {
   1782             return "available";
   1783         } else if (status == android.hardware.radio.V1_0.OperatorStatus.CURRENT) {
   1784             return "current";
   1785         } else if (status == android.hardware.radio.V1_0.OperatorStatus.FORBIDDEN) {
   1786             return "forbidden";
   1787         } else {
   1788             return "";
   1789         }
   1790     }
   1791 
   1792     private void responseOperatorInfos(RadioResponseInfo responseInfo,
   1793                                        ArrayList<android.hardware.radio.V1_0.OperatorInfo>
   1794                                                networkInfos) {
   1795         RILRequest rr = mRil.processResponse(responseInfo);
   1796 
   1797         if (rr != null) {
   1798             ArrayList<OperatorInfo> ret = new ArrayList<OperatorInfo>();
   1799             for (int i = 0; i < networkInfos.size(); i++) {
   1800                 ret.add(new OperatorInfo(networkInfos.get(i).alphaLong,
   1801                         networkInfos.get(i).alphaShort, networkInfos.get(i).operatorNumeric,
   1802                         convertOpertatorInfoToString(networkInfos.get(i).status)));
   1803             }
   1804             if (responseInfo.error == RadioError.NONE) {
   1805                 sendMessageResponse(rr.mResult, ret);
   1806             }
   1807             mRil.processResponseDone(rr, responseInfo, ret);
   1808         }
   1809     }
   1810 
   1811     private void responseScanStatus(RadioResponseInfo responseInfo) {
   1812         RILRequest rr = mRil.processResponse(responseInfo);
   1813 
   1814         if (rr != null) {
   1815             NetworkScanResult nsr = null;
   1816             if (responseInfo.error == RadioError.NONE) {
   1817                 nsr = new NetworkScanResult(
   1818                         NetworkScanResult.SCAN_STATUS_PARTIAL, RadioError.NONE, null);
   1819                 sendMessageResponse(rr.mResult, nsr);
   1820             }
   1821             mRil.processResponseDone(rr, responseInfo, nsr);
   1822         }
   1823     }
   1824 
   1825     private void responseDataCallList(RadioResponseInfo responseInfo,
   1826                                       ArrayList<SetupDataCallResult> dataCallResultList) {
   1827         RILRequest rr = mRil.processResponse(responseInfo);
   1828 
   1829         if (rr != null) {
   1830             if (responseInfo.error == RadioError.NONE) {
   1831                 sendMessageResponse(rr.mResult, dataCallResultList);
   1832             }
   1833             mRil.processResponseDone(rr, responseInfo, dataCallResultList);
   1834         }
   1835     }
   1836 
   1837     private void responseCellList(RadioResponseInfo responseInfo,
   1838                                   ArrayList<NeighboringCell> cells) {
   1839         RILRequest rr = mRil.processResponse(responseInfo);
   1840 
   1841         if (rr != null) {
   1842             int rssi;
   1843             String location;
   1844             ArrayList<NeighboringCellInfo> ret = new ArrayList<NeighboringCellInfo>();
   1845             NeighboringCellInfo cell;
   1846 
   1847             int[] subId = SubscriptionManager.getSubId(mRil.mPhoneId);
   1848             int radioType =
   1849                     ((TelephonyManager) mRil.mContext.getSystemService(
   1850                             Context.TELEPHONY_SERVICE)).getDataNetworkType(subId[0]);
   1851 
   1852             if (radioType != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
   1853                 for (int i = 0; i < cells.size(); i++) {
   1854                     rssi = cells.get(i).rssi;
   1855                     location = cells.get(i).cid;
   1856                     cell = new NeighboringCellInfo(rssi, location, radioType);
   1857                     ret.add(cell);
   1858                 }
   1859             }
   1860             if (responseInfo.error == RadioError.NONE) {
   1861                 sendMessageResponse(rr.mResult, ret);
   1862             }
   1863             mRil.processResponseDone(rr, responseInfo, ret);
   1864         }
   1865     }
   1866 
   1867     private void responseGmsBroadcastConfig(RadioResponseInfo responseInfo,
   1868                                             ArrayList<GsmBroadcastSmsConfigInfo> configs) {
   1869         RILRequest rr = mRil.processResponse(responseInfo);
   1870 
   1871         if (rr != null) {
   1872             ArrayList<SmsBroadcastConfigInfo> ret = new ArrayList<SmsBroadcastConfigInfo>();
   1873             for (int i = 0; i < configs.size(); i++) {
   1874                 ret.add(new SmsBroadcastConfigInfo(configs.get(i).fromServiceId,
   1875                         configs.get(i).toServiceId, configs.get(i).fromCodeScheme,
   1876                         configs.get(i).toCodeScheme, configs.get(i).selected));
   1877             }
   1878             if (responseInfo.error == RadioError.NONE) {
   1879                 sendMessageResponse(rr.mResult, ret);
   1880             }
   1881             mRil.processResponseDone(rr, responseInfo, ret);
   1882         }
   1883     }
   1884 
   1885     private void responseCdmaBroadcastConfig(RadioResponseInfo responseInfo,
   1886                                             ArrayList<CdmaBroadcastSmsConfigInfo> configs) {
   1887         RILRequest rr = mRil.processResponse(responseInfo);
   1888 
   1889         if (rr != null) {
   1890             int[] ret = null;
   1891 
   1892             int numServiceCategories = configs.size();
   1893 
   1894             if (numServiceCategories == 0) {
   1895                 // TODO: The logic of providing default values should
   1896                 // not be done by this transport layer. And needs to
   1897                 // be done by the vendor ril or application logic.
   1898                 int numInts;
   1899                 numInts = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES
   1900                         * CDMA_BSI_NO_OF_INTS_STRUCT + 1;
   1901                 ret = new int[numInts];
   1902 
   1903                 // Faking a default record for all possible records.
   1904                 ret[0] = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES;
   1905 
   1906                 // Loop over CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES set 'english' as
   1907                 // default language and selection status to false for all.
   1908                 for (int i = 1; i < numInts; i += CDMA_BSI_NO_OF_INTS_STRUCT) {
   1909                     ret[i + 0] = i / CDMA_BSI_NO_OF_INTS_STRUCT;
   1910                     ret[i + 1] = 1;
   1911                     ret[i + 2] = 0;
   1912                 }
   1913             } else {
   1914                 int numInts;
   1915                 numInts = (numServiceCategories * CDMA_BSI_NO_OF_INTS_STRUCT) + 1;
   1916                 ret = new int[numInts];
   1917 
   1918                 ret[0] = numServiceCategories;
   1919                 for (int i = 1, j = 0; j < configs.size();
   1920                         j++, i = i + CDMA_BSI_NO_OF_INTS_STRUCT) {
   1921                     ret[i] = configs.get(j).serviceCategory;
   1922                     ret[i + 1] = configs.get(j).language;
   1923                     ret[i + 2] = configs.get(j).selected ? 1 : 0;
   1924                 }
   1925             }
   1926             if (responseInfo.error == RadioError.NONE) {
   1927                 sendMessageResponse(rr.mResult, ret);
   1928             }
   1929             mRil.processResponseDone(rr, responseInfo, ret);
   1930         }
   1931     }
   1932 
   1933     private void responseCellInfoList(RadioResponseInfo responseInfo,
   1934                                       ArrayList<android.hardware.radio.V1_0.CellInfo> cellInfo) {
   1935         RILRequest rr = mRil.processResponse(responseInfo);
   1936 
   1937         if (rr != null) {
   1938             ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(cellInfo);
   1939             if (responseInfo.error == RadioError.NONE) {
   1940                 sendMessageResponse(rr.mResult, ret);
   1941             }
   1942             mRil.processResponseDone(rr, responseInfo, ret);
   1943         }
   1944     }
   1945 
   1946     private void responseCellInfoList_1_2(
   1947             RadioResponseInfo responseInfo,
   1948             ArrayList<android.hardware.radio.V1_2.CellInfo> cellInfo) {
   1949         RILRequest rr = mRil.processResponse(responseInfo);
   1950 
   1951         if (rr != null) {
   1952             ArrayList<CellInfo> ret = RIL.convertHalCellInfoList_1_2(cellInfo);
   1953             if (responseInfo.error == RadioError.NONE) {
   1954                 sendMessageResponse(rr.mResult, ret);
   1955             }
   1956             mRil.processResponseDone(rr, responseInfo, ret);
   1957         }
   1958     }
   1959 
   1960     private void responseActivityData(RadioResponseInfo responseInfo,
   1961                                       ActivityStatsInfo activityInfo) {
   1962         RILRequest rr = mRil.processResponse(responseInfo);
   1963 
   1964         if (rr != null) {
   1965             ModemActivityInfo ret = null;
   1966             if (responseInfo.error == RadioError.NONE) {
   1967                 final int sleepModeTimeMs = activityInfo.sleepModeTimeMs;
   1968                 final int idleModeTimeMs = activityInfo.idleModeTimeMs;
   1969                 int [] txModeTimeMs = new int[ModemActivityInfo.TX_POWER_LEVELS];
   1970                 for (int i = 0; i < ModemActivityInfo.TX_POWER_LEVELS; i++) {
   1971                     txModeTimeMs[i] = activityInfo.txmModetimeMs[i];
   1972                 }
   1973                 final int rxModeTimeMs = activityInfo.rxModeTimeMs;
   1974                 ret = new ModemActivityInfo(SystemClock.elapsedRealtime(), sleepModeTimeMs,
   1975                         idleModeTimeMs, txModeTimeMs, rxModeTimeMs, 0);
   1976             } else {
   1977                 ret = new ModemActivityInfo(0, 0, 0, new int [ModemActivityInfo.TX_POWER_LEVELS],
   1978                         0, 0);
   1979                 responseInfo.error = RadioError.NONE;
   1980             }
   1981             sendMessageResponse(rr.mResult, ret);
   1982             mRil.processResponseDone(rr, responseInfo, ret);
   1983         }
   1984     }
   1985 
   1986     private void responseHardwareConfig(
   1987             RadioResponseInfo responseInfo,
   1988             ArrayList<android.hardware.radio.V1_0.HardwareConfig> config) {
   1989         RILRequest rr = mRil.processResponse(responseInfo);
   1990 
   1991         if (rr != null) {
   1992             ArrayList<HardwareConfig> ret = RIL.convertHalHwConfigList(config, mRil);
   1993             if (responseInfo.error == RadioError.NONE) {
   1994                 sendMessageResponse(rr.mResult, ret);
   1995             }
   1996             mRil.processResponseDone(rr, responseInfo, ret);
   1997         }
   1998     }
   1999 
   2000     private void responseICC_IOBase64(RadioResponseInfo responseInfo,
   2001                                       android.hardware.radio.V1_0.IccIoResult result) {
   2002         RILRequest rr = mRil.processResponse(responseInfo);
   2003 
   2004         if (rr != null) {
   2005             IccIoResult ret = new IccIoResult(
   2006                     result.sw1,
   2007                     result.sw2,
   2008                     (!(result.simResponse).equals(""))
   2009                             ? android.util.Base64.decode(result.simResponse,
   2010                             android.util.Base64.DEFAULT) : (byte[]) null);
   2011             if (responseInfo.error == RadioError.NONE) {
   2012                 sendMessageResponse(rr.mResult, ret);
   2013             }
   2014             mRil.processResponseDone(rr, responseInfo, ret);
   2015         }
   2016     }
   2017 
   2018     private void responseRadioCapability(RadioResponseInfo responseInfo,
   2019                                          android.hardware.radio.V1_0.RadioCapability rc) {
   2020         RILRequest rr = mRil.processResponse(responseInfo);
   2021 
   2022         if (rr != null) {
   2023             RadioCapability ret = RIL.convertHalRadioCapability(rc, mRil);
   2024             if (responseInfo.error == RadioError.NONE) {
   2025                 sendMessageResponse(rr.mResult, ret);
   2026             }
   2027             mRil.processResponseDone(rr, responseInfo, ret);
   2028         }
   2029     }
   2030 
   2031     private void responseLceStatus(RadioResponseInfo responseInfo, LceStatusInfo statusInfo) {
   2032         RILRequest rr = mRil.processResponse(responseInfo);
   2033 
   2034         if (rr != null) {
   2035             ArrayList<Integer> ret = new ArrayList<Integer>();
   2036             ret.add(statusInfo.lceStatus);
   2037             ret.add(Byte.toUnsignedInt(statusInfo.actualIntervalMs));
   2038             if (responseInfo.error == RadioError.NONE) {
   2039                 sendMessageResponse(rr.mResult, ret);
   2040             }
   2041             mRil.processResponseDone(rr, responseInfo, ret);
   2042         }
   2043     }
   2044 
   2045     private void responseLceData(RadioResponseInfo responseInfo, LceDataInfo lceInfo) {
   2046         RILRequest rr = mRil.processResponse(responseInfo);
   2047 
   2048         if (rr != null) {
   2049             LinkCapacityEstimate ret = RIL.convertHalLceData(lceInfo, mRil);
   2050             if (responseInfo.error == RadioError.NONE) {
   2051                 sendMessageResponse(rr.mResult, ret);
   2052             }
   2053             mRil.processResponseDone(rr, responseInfo, ret);
   2054         }
   2055     }
   2056 
   2057     private void responseCarrierIdentifiers(RadioResponseInfo responseInfo, boolean allAllowed,
   2058                                             CarrierRestrictions carriers) {
   2059         RILRequest rr = mRil.processResponse(responseInfo);
   2060 
   2061         if (rr != null) {
   2062             List<CarrierIdentifier> ret = new ArrayList<CarrierIdentifier>();
   2063             for (int i = 0; i < carriers.allowedCarriers.size(); i++) {
   2064                 String mcc = carriers.allowedCarriers.get(i).mcc;
   2065                 String mnc = carriers.allowedCarriers.get(i).mnc;
   2066                 String spn = null, imsi = null, gid1 = null, gid2 = null;
   2067                 int matchType = carriers.allowedCarriers.get(i).matchType;
   2068                 String matchData = carriers.allowedCarriers.get(i).matchData;
   2069                 if (matchType == CarrierIdentifier.MatchType.SPN) {
   2070                     spn = matchData;
   2071                 } else if (matchType == CarrierIdentifier.MatchType.IMSI_PREFIX) {
   2072                     imsi = matchData;
   2073                 } else if (matchType == CarrierIdentifier.MatchType.GID1) {
   2074                     gid1 = matchData;
   2075                 } else if (matchType == CarrierIdentifier.MatchType.GID2) {
   2076                     gid2 = matchData;
   2077                 }
   2078                 ret.add(new CarrierIdentifier(mcc, mnc, spn, imsi, gid1, gid2));
   2079             }
   2080             if (responseInfo.error == RadioError.NONE) {
   2081                 /* TODO: Handle excluded carriers */
   2082                 sendMessageResponse(rr.mResult, ret);
   2083             }
   2084             mRil.processResponseDone(rr, responseInfo, ret);
   2085         }
   2086     }
   2087 }
   2088