Home | History | Annotate | Download | only in telephony
      1 /*
      2  * Copyright (C) 2006 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 android.telephony;
     18 
     19 import android.os.Bundle;
     20 import android.os.Parcel;
     21 import android.os.Parcelable;
     22 import android.util.Log;
     23 
     24 /**
     25  * Contains phone state and service related information.
     26  *
     27  * The following phone information is included in returned ServiceState:
     28  *
     29  * <ul>
     30  *   <li>Service state: IN_SERVICE, OUT_OF_SERVICE, EMERGENCY_ONLY, POWER_OFF
     31  *   <li>Roaming indicator
     32  *   <li>Operator name, short name and numeric id
     33  *   <li>Network selection mode
     34  * </ul>
     35  */
     36 public class ServiceState implements Parcelable {
     37 
     38     static final String LOG_TAG = "PHONE";
     39 
     40     /**
     41      * Normal operation condition, the phone is registered
     42      * with an operator either in home network or in roaming.
     43      */
     44     public static final int STATE_IN_SERVICE = 0;
     45 
     46     /**
     47      * Phone is not registered with any operator, the phone
     48      * can be currently searching a new operator to register to, or not
     49      * searching to registration at all, or registration is denied, or radio
     50      * signal is not available.
     51      */
     52     public static final int STATE_OUT_OF_SERVICE = 1;
     53 
     54     /**
     55      * The phone is registered and locked.  Only emergency numbers are allowed. {@more}
     56      */
     57     public static final int STATE_EMERGENCY_ONLY = 2;
     58 
     59     /**
     60      * Radio of telephony is explicitly powered off.
     61      */
     62     public static final int STATE_POWER_OFF = 3;
     63 
     64 
     65     /**
     66      * Available radio technologies for GSM, UMTS and CDMA.
     67      * Duplicates the constants from hardware/radio/include/ril.h
     68      * This should only be used by agents working with the ril.  Others
     69      * should use the equivalent TelephonyManager.NETWORK_TYPE_*
     70      */
     71     /** @hide */
     72     public static final int RIL_RADIO_TECHNOLOGY_UNKNOWN = 0;
     73     /** @hide */
     74     public static final int RIL_RADIO_TECHNOLOGY_GPRS = 1;
     75     /** @hide */
     76     public static final int RIL_RADIO_TECHNOLOGY_EDGE = 2;
     77     /** @hide */
     78     public static final int RIL_RADIO_TECHNOLOGY_UMTS = 3;
     79     /** @hide */
     80     public static final int RIL_RADIO_TECHNOLOGY_IS95A = 4;
     81     /** @hide */
     82     public static final int RIL_RADIO_TECHNOLOGY_IS95B = 5;
     83     /** @hide */
     84     public static final int RIL_RADIO_TECHNOLOGY_1xRTT = 6;
     85     /** @hide */
     86     public static final int RIL_RADIO_TECHNOLOGY_EVDO_0 = 7;
     87     /** @hide */
     88     public static final int RIL_RADIO_TECHNOLOGY_EVDO_A = 8;
     89     /** @hide */
     90     public static final int RIL_RADIO_TECHNOLOGY_HSDPA = 9;
     91     /** @hide */
     92     public static final int RIL_RADIO_TECHNOLOGY_HSUPA = 10;
     93     /** @hide */
     94     public static final int RIL_RADIO_TECHNOLOGY_HSPA = 11;
     95     /** @hide */
     96     public static final int RIL_RADIO_TECHNOLOGY_EVDO_B = 12;
     97     /** @hide */
     98     public static final int RIL_RADIO_TECHNOLOGY_EHRPD = 13;
     99     /** @hide */
    100     public static final int RIL_RADIO_TECHNOLOGY_LTE = 14;
    101     /** @hide */
    102     public static final int RIL_RADIO_TECHNOLOGY_HSPAP = 15;
    103     /**
    104      * GSM radio technology only supports voice. It does not support data.
    105      * @hide
    106      */
    107     public static final int RIL_RADIO_TECHNOLOGY_GSM = 16;
    108 
    109     /**
    110      * Available registration states for GSM, UMTS and CDMA.
    111      */
    112     /** @hide */
    113     public static final int REGISTRATION_STATE_NOT_REGISTERED_AND_NOT_SEARCHING = 0;
    114     /** @hide */
    115     public static final int REGISTRATION_STATE_HOME_NETWORK = 1;
    116     /** @hide */
    117     public static final int REGISTRATION_STATE_NOT_REGISTERED_AND_SEARCHING = 2;
    118     /** @hide */
    119     public static final int REGISTRATION_STATE_REGISTRATION_DENIED = 3;
    120     /** @hide */
    121     public static final int REGISTRATION_STATE_UNKNOWN = 4;
    122     /** @hide */
    123     public static final int REGISTRATION_STATE_ROAMING = 5;
    124 
    125     private int mState = STATE_OUT_OF_SERVICE;
    126     private boolean mRoaming;
    127     private String mOperatorAlphaLong;
    128     private String mOperatorAlphaShort;
    129     private String mOperatorNumeric;
    130     private boolean mIsManualNetworkSelection;
    131 
    132     private boolean mIsEmergencyOnly;
    133 
    134     //***** CDMA
    135     private int mRadioTechnology;
    136     private boolean mCssIndicator;
    137     private int mNetworkId;
    138     private int mSystemId;
    139     private int mCdmaRoamingIndicator;
    140     private int mCdmaDefaultRoamingIndicator;
    141     private int mCdmaEriIconIndex;
    142     private int mCdmaEriIconMode;
    143 
    144     /**
    145      * Create a new ServiceState from a intent notifier Bundle
    146      *
    147      * This method is used by PhoneStateIntentReceiver and maybe by
    148      * external applications.
    149      *
    150      * @param m Bundle from intent notifier
    151      * @return newly created ServiceState
    152      * @hide
    153      */
    154     public static ServiceState newFromBundle(Bundle m) {
    155         ServiceState ret;
    156         ret = new ServiceState();
    157         ret.setFromNotifierBundle(m);
    158         return ret;
    159     }
    160 
    161     /**
    162      * Empty constructor
    163      */
    164     public ServiceState() {
    165     }
    166 
    167     /**
    168      * Copy constructors
    169      *
    170      * @param s Source service state
    171      */
    172     public ServiceState(ServiceState s) {
    173         copyFrom(s);
    174     }
    175 
    176     protected void copyFrom(ServiceState s) {
    177         mState = s.mState;
    178         mRoaming = s.mRoaming;
    179         mOperatorAlphaLong = s.mOperatorAlphaLong;
    180         mOperatorAlphaShort = s.mOperatorAlphaShort;
    181         mOperatorNumeric = s.mOperatorNumeric;
    182         mIsManualNetworkSelection = s.mIsManualNetworkSelection;
    183         mRadioTechnology = s.mRadioTechnology;
    184         mCssIndicator = s.mCssIndicator;
    185         mNetworkId = s.mNetworkId;
    186         mSystemId = s.mSystemId;
    187         mCdmaRoamingIndicator = s.mCdmaRoamingIndicator;
    188         mCdmaDefaultRoamingIndicator = s.mCdmaDefaultRoamingIndicator;
    189         mCdmaEriIconIndex = s.mCdmaEriIconIndex;
    190         mCdmaEriIconMode = s.mCdmaEriIconMode;
    191         mIsEmergencyOnly = s.mIsEmergencyOnly;
    192     }
    193 
    194     /**
    195      * Construct a ServiceState object from the given parcel.
    196      */
    197     public ServiceState(Parcel in) {
    198         mState = in.readInt();
    199         mRoaming = in.readInt() != 0;
    200         mOperatorAlphaLong = in.readString();
    201         mOperatorAlphaShort = in.readString();
    202         mOperatorNumeric = in.readString();
    203         mIsManualNetworkSelection = in.readInt() != 0;
    204         mRadioTechnology = in.readInt();
    205         mCssIndicator = (in.readInt() != 0);
    206         mNetworkId = in.readInt();
    207         mSystemId = in.readInt();
    208         mCdmaRoamingIndicator = in.readInt();
    209         mCdmaDefaultRoamingIndicator = in.readInt();
    210         mCdmaEriIconIndex = in.readInt();
    211         mCdmaEriIconMode = in.readInt();
    212         mIsEmergencyOnly = in.readInt() != 0;
    213     }
    214 
    215     public void writeToParcel(Parcel out, int flags) {
    216         out.writeInt(mState);
    217         out.writeInt(mRoaming ? 1 : 0);
    218         out.writeString(mOperatorAlphaLong);
    219         out.writeString(mOperatorAlphaShort);
    220         out.writeString(mOperatorNumeric);
    221         out.writeInt(mIsManualNetworkSelection ? 1 : 0);
    222         out.writeInt(mRadioTechnology);
    223         out.writeInt(mCssIndicator ? 1 : 0);
    224         out.writeInt(mNetworkId);
    225         out.writeInt(mSystemId);
    226         out.writeInt(mCdmaRoamingIndicator);
    227         out.writeInt(mCdmaDefaultRoamingIndicator);
    228         out.writeInt(mCdmaEriIconIndex);
    229         out.writeInt(mCdmaEriIconMode);
    230         out.writeInt(mIsEmergencyOnly ? 1 : 0);
    231     }
    232 
    233     public int describeContents() {
    234         return 0;
    235     }
    236 
    237     public static final Parcelable.Creator<ServiceState> CREATOR =
    238             new Parcelable.Creator<ServiceState>() {
    239         public ServiceState createFromParcel(Parcel in) {
    240             return new ServiceState(in);
    241         }
    242 
    243         public ServiceState[] newArray(int size) {
    244             return new ServiceState[size];
    245         }
    246     };
    247 
    248     /**
    249      * Get current service state of phone
    250      *
    251      * @see #STATE_IN_SERVICE
    252      * @see #STATE_OUT_OF_SERVICE
    253      * @see #STATE_EMERGENCY_ONLY
    254      * @see #STATE_POWER_OFF
    255      */
    256     public int getState() {
    257         return mState;
    258     }
    259 
    260     /**
    261      * Get current roaming indicator of phone
    262      * (note: not just decoding from TS 27.007 7.2)
    263      *
    264      * @return true if TS 27.007 7.2 roaming is true
    265      *              and ONS is different from SPN
    266      *
    267      */
    268     public boolean getRoaming() {
    269         return mRoaming;
    270     }
    271 
    272     /**
    273      * @hide
    274      */
    275     public boolean isEmergencyOnly() {
    276         return mIsEmergencyOnly;
    277     }
    278 
    279     /**
    280      * @hide
    281      */
    282     public int getCdmaRoamingIndicator(){
    283         return this.mCdmaRoamingIndicator;
    284     }
    285 
    286     /**
    287      * @hide
    288      */
    289     public int getCdmaDefaultRoamingIndicator(){
    290         return this.mCdmaDefaultRoamingIndicator;
    291     }
    292 
    293     /**
    294      * @hide
    295      */
    296     public int getCdmaEriIconIndex() {
    297         return this.mCdmaEriIconIndex;
    298     }
    299 
    300     /**
    301      * @hide
    302      */
    303     public int getCdmaEriIconMode() {
    304         return this.mCdmaEriIconMode;
    305     }
    306 
    307     /**
    308      * Get current registered operator name in long alphanumeric format.
    309      *
    310      * In GSM/UMTS, long format can be up to 16 characters long.
    311      * In CDMA, returns the ERI text, if set. Otherwise, returns the ONS.
    312      *
    313      * @return long name of operator, null if unregistered or unknown
    314      */
    315     public String getOperatorAlphaLong() {
    316         return mOperatorAlphaLong;
    317     }
    318 
    319     /**
    320      * Get current registered operator name in short alphanumeric format.
    321      *
    322      * In GSM/UMTS, short format can be up to 8 characters long.
    323      *
    324      * @return short name of operator, null if unregistered or unknown
    325      */
    326     public String getOperatorAlphaShort() {
    327         return mOperatorAlphaShort;
    328     }
    329 
    330     /**
    331      * Get current registered operator numeric id.
    332      *
    333      * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit
    334      * network code.
    335      *
    336      * @return numeric format of operator, null if unregistered or unknown
    337      */
    338     /*
    339      * The country code can be decoded using
    340      * {@link com.android.internal.telephony.MccTable#countryCodeForMcc(int)}.
    341      */
    342     public String getOperatorNumeric() {
    343         return mOperatorNumeric;
    344     }
    345 
    346     /**
    347      * Get current network selection mode.
    348      *
    349      * @return true if manual mode, false if automatic mode
    350      */
    351     public boolean getIsManualSelection() {
    352         return mIsManualNetworkSelection;
    353     }
    354 
    355     @Override
    356     public int hashCode() {
    357         return ((mState * 0x1234)
    358                 + (mRoaming ? 1 : 0)
    359                 + (mIsManualNetworkSelection ? 1 : 0)
    360                 + ((null == mOperatorAlphaLong) ? 0 : mOperatorAlphaLong.hashCode())
    361                 + ((null == mOperatorAlphaShort) ? 0 : mOperatorAlphaShort.hashCode())
    362                 + ((null == mOperatorNumeric) ? 0 : mOperatorNumeric.hashCode())
    363                 + mCdmaRoamingIndicator
    364                 + mCdmaDefaultRoamingIndicator
    365                 + (mIsEmergencyOnly ? 1 : 0));
    366     }
    367 
    368     @Override
    369     public boolean equals (Object o) {
    370         ServiceState s;
    371 
    372         try {
    373             s = (ServiceState) o;
    374         } catch (ClassCastException ex) {
    375             return false;
    376         }
    377 
    378         if (o == null) {
    379             return false;
    380         }
    381 
    382         return (mState == s.mState
    383                 && mRoaming == s.mRoaming
    384                 && mIsManualNetworkSelection == s.mIsManualNetworkSelection
    385                 && equalsHandlesNulls(mOperatorAlphaLong, s.mOperatorAlphaLong)
    386                 && equalsHandlesNulls(mOperatorAlphaShort, s.mOperatorAlphaShort)
    387                 && equalsHandlesNulls(mOperatorNumeric, s.mOperatorNumeric)
    388                 && equalsHandlesNulls(mRadioTechnology, s.mRadioTechnology)
    389                 && equalsHandlesNulls(mCssIndicator, s.mCssIndicator)
    390                 && equalsHandlesNulls(mNetworkId, s.mNetworkId)
    391                 && equalsHandlesNulls(mSystemId, s.mSystemId)
    392                 && equalsHandlesNulls(mCdmaRoamingIndicator, s.mCdmaRoamingIndicator)
    393                 && equalsHandlesNulls(mCdmaDefaultRoamingIndicator,
    394                         s.mCdmaDefaultRoamingIndicator)
    395                 && mIsEmergencyOnly == s.mIsEmergencyOnly);
    396     }
    397 
    398     /**
    399      * Convert radio technology to String
    400      *
    401      * @param radioTechnology
    402      * @return String representation of the RAT
    403      *
    404      * @hide
    405      */
    406     public static String rilRadioTechnologyToString(int rt) {
    407         String rtString;
    408 
    409         switch(rt) {
    410             case RIL_RADIO_TECHNOLOGY_UNKNOWN:
    411                 rtString = "Unknown";
    412                 break;
    413             case RIL_RADIO_TECHNOLOGY_GPRS:
    414                 rtString = "GPRS";
    415                 break;
    416             case RIL_RADIO_TECHNOLOGY_EDGE:
    417                 rtString = "EDGE";
    418                 break;
    419             case RIL_RADIO_TECHNOLOGY_UMTS:
    420                 rtString = "UMTS";
    421                 break;
    422             case RIL_RADIO_TECHNOLOGY_IS95A:
    423                 rtString = "CDMA-IS95A";
    424                 break;
    425             case RIL_RADIO_TECHNOLOGY_IS95B:
    426                 rtString = "CDMA-IS95B";
    427                 break;
    428             case RIL_RADIO_TECHNOLOGY_1xRTT:
    429                 rtString = "1xRTT";
    430                 break;
    431             case RIL_RADIO_TECHNOLOGY_EVDO_0:
    432                 rtString = "EvDo-rev.0";
    433                 break;
    434             case RIL_RADIO_TECHNOLOGY_EVDO_A:
    435                 rtString = "EvDo-rev.A";
    436                 break;
    437             case RIL_RADIO_TECHNOLOGY_HSDPA:
    438                 rtString = "HSDPA";
    439                 break;
    440             case RIL_RADIO_TECHNOLOGY_HSUPA:
    441                 rtString = "HSUPA";
    442                 break;
    443             case RIL_RADIO_TECHNOLOGY_HSPA:
    444                 rtString = "HSPA";
    445                 break;
    446             case RIL_RADIO_TECHNOLOGY_EVDO_B:
    447                 rtString = "EvDo-rev.B";
    448                 break;
    449             case RIL_RADIO_TECHNOLOGY_EHRPD:
    450                 rtString = "eHRPD";
    451                 break;
    452             case RIL_RADIO_TECHNOLOGY_LTE:
    453                 rtString = "LTE";
    454                 break;
    455             case RIL_RADIO_TECHNOLOGY_HSPAP:
    456                 rtString = "HSPAP";
    457                 break;
    458             case RIL_RADIO_TECHNOLOGY_GSM:
    459                 rtString = "GSM";
    460                 break;
    461             default:
    462                 rtString = "Unexpected";
    463                 Log.w(LOG_TAG, "Unexpected radioTechnology=" + rt);
    464                 break;
    465         }
    466         return rtString;
    467     }
    468 
    469     @Override
    470     public String toString() {
    471         String radioTechnology = rilRadioTechnologyToString(mRadioTechnology);
    472 
    473         return (mState + " " + (mRoaming ? "roaming" : "home")
    474                 + " " + mOperatorAlphaLong
    475                 + " " + mOperatorAlphaShort
    476                 + " " + mOperatorNumeric
    477                 + " " + (mIsManualNetworkSelection ? "(manual)" : "")
    478                 + " " + radioTechnology
    479                 + " " + (mCssIndicator ? "CSS supported" : "CSS not supported")
    480                 + " " + mNetworkId
    481                 + " " + mSystemId
    482                 + " RoamInd=" + mCdmaRoamingIndicator
    483                 + " DefRoamInd=" + mCdmaDefaultRoamingIndicator
    484                 + " EmergOnly=" + mIsEmergencyOnly);
    485     }
    486 
    487     private void setNullState(int state) {
    488         mState = state;
    489         mRoaming = false;
    490         mOperatorAlphaLong = null;
    491         mOperatorAlphaShort = null;
    492         mOperatorNumeric = null;
    493         mIsManualNetworkSelection = false;
    494         mRadioTechnology = 0;
    495         mCssIndicator = false;
    496         mNetworkId = -1;
    497         mSystemId = -1;
    498         mCdmaRoamingIndicator = -1;
    499         mCdmaDefaultRoamingIndicator = -1;
    500         mCdmaEriIconIndex = -1;
    501         mCdmaEriIconMode = -1;
    502         mIsEmergencyOnly = false;
    503     }
    504 
    505     public void setStateOutOfService() {
    506         setNullState(STATE_OUT_OF_SERVICE);
    507     }
    508 
    509     public void setStateOff() {
    510         setNullState(STATE_POWER_OFF);
    511     }
    512 
    513     public void setState(int state) {
    514         mState = state;
    515     }
    516 
    517     public void setRoaming(boolean roaming) {
    518         mRoaming = roaming;
    519     }
    520 
    521 
    522     /**
    523      * @hide
    524      */
    525     public void setEmergencyOnly(boolean emergencyOnly) {
    526         mIsEmergencyOnly = emergencyOnly;
    527     }
    528 
    529     /**
    530      * @hide
    531      */
    532     public void setCdmaRoamingIndicator(int roaming) {
    533         this.mCdmaRoamingIndicator = roaming;
    534     }
    535 
    536     /**
    537      * @hide
    538      */
    539     public void setCdmaDefaultRoamingIndicator (int roaming) {
    540         this.mCdmaDefaultRoamingIndicator = roaming;
    541     }
    542 
    543     /**
    544      * @hide
    545      */
    546     public void setCdmaEriIconIndex(int index) {
    547         this.mCdmaEriIconIndex = index;
    548     }
    549 
    550     /**
    551      * @hide
    552      */
    553     public void setCdmaEriIconMode(int mode) {
    554         this.mCdmaEriIconMode = mode;
    555     }
    556 
    557     public void setOperatorName(String longName, String shortName, String numeric) {
    558         mOperatorAlphaLong = longName;
    559         mOperatorAlphaShort = shortName;
    560         mOperatorNumeric = numeric;
    561     }
    562 
    563     /**
    564      * In CDMA, mOperatorAlphaLong can be set from the ERI text.
    565      * This is done from the CDMAPhone and not from the CdmaServiceStateTracker.
    566      *
    567      * @hide
    568      */
    569     public void setOperatorAlphaLong(String longName) {
    570         mOperatorAlphaLong = longName;
    571     }
    572 
    573     public void setIsManualSelection(boolean isManual) {
    574         mIsManualNetworkSelection = isManual;
    575     }
    576 
    577     /**
    578      * Test whether two objects hold the same data values or both are null.
    579      *
    580      * @param a first obj
    581      * @param b second obj
    582      * @return true if two objects equal or both are null
    583      */
    584     private static boolean equalsHandlesNulls (Object a, Object b) {
    585         return (a == null) ? (b == null) : a.equals (b);
    586     }
    587 
    588     /**
    589      * Set ServiceState based on intent notifier map.
    590      *
    591      * @param m intent notifier map
    592      * @hide
    593      */
    594     private void setFromNotifierBundle(Bundle m) {
    595         mState = m.getInt("state");
    596         mRoaming = m.getBoolean("roaming");
    597         mOperatorAlphaLong = m.getString("operator-alpha-long");
    598         mOperatorAlphaShort = m.getString("operator-alpha-short");
    599         mOperatorNumeric = m.getString("operator-numeric");
    600         mIsManualNetworkSelection = m.getBoolean("manual");
    601         mRadioTechnology = m.getInt("radioTechnology");
    602         mCssIndicator = m.getBoolean("cssIndicator");
    603         mNetworkId = m.getInt("networkId");
    604         mSystemId = m.getInt("systemId");
    605         mCdmaRoamingIndicator = m.getInt("cdmaRoamingIndicator");
    606         mCdmaDefaultRoamingIndicator = m.getInt("cdmaDefaultRoamingIndicator");
    607         mIsEmergencyOnly = m.getBoolean("emergencyOnly");
    608     }
    609 
    610     /**
    611      * Set intent notifier Bundle based on service state.
    612      *
    613      * @param m intent notifier Bundle
    614      * @hide
    615      */
    616     public void fillInNotifierBundle(Bundle m) {
    617         m.putInt("state", mState);
    618         m.putBoolean("roaming", Boolean.valueOf(mRoaming));
    619         m.putString("operator-alpha-long", mOperatorAlphaLong);
    620         m.putString("operator-alpha-short", mOperatorAlphaShort);
    621         m.putString("operator-numeric", mOperatorNumeric);
    622         m.putBoolean("manual", Boolean.valueOf(mIsManualNetworkSelection));
    623         m.putInt("radioTechnology", mRadioTechnology);
    624         m.putBoolean("cssIndicator", mCssIndicator);
    625         m.putInt("networkId", mNetworkId);
    626         m.putInt("systemId", mSystemId);
    627         m.putInt("cdmaRoamingIndicator", mCdmaRoamingIndicator);
    628         m.putInt("cdmaDefaultRoamingIndicator", mCdmaDefaultRoamingIndicator);
    629         m.putBoolean("emergencyOnly", Boolean.valueOf(mIsEmergencyOnly));
    630     }
    631 
    632     //***** CDMA
    633     /** @hide */
    634     public void setRadioTechnology(int state) {
    635         this.mRadioTechnology = state;
    636     }
    637 
    638     /** @hide */
    639     public void setCssIndicator(int css) {
    640         this.mCssIndicator = (css != 0);
    641     }
    642 
    643     /** @hide */
    644     public void setSystemAndNetworkId(int systemId, int networkId) {
    645         this.mSystemId = systemId;
    646         this.mNetworkId = networkId;
    647     }
    648 
    649     /** @hide */
    650     public int getRilRadioTechnology() {
    651         return this.mRadioTechnology;
    652     }
    653     /** @hide */
    654     public int getRadioTechnology() {
    655         return getRilRadioTechnology();
    656     }
    657 
    658     /** @hide */
    659     public int getNetworkType() {
    660         switch(mRadioTechnology) {
    661         case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS:
    662             return TelephonyManager.NETWORK_TYPE_GPRS;
    663         case ServiceState.RIL_RADIO_TECHNOLOGY_EDGE:
    664             return TelephonyManager.NETWORK_TYPE_EDGE;
    665         case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS:
    666             return TelephonyManager.NETWORK_TYPE_UMTS;
    667         case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA:
    668             return TelephonyManager.NETWORK_TYPE_HSDPA;
    669         case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA:
    670             return TelephonyManager.NETWORK_TYPE_HSUPA;
    671         case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA:
    672             return TelephonyManager.NETWORK_TYPE_HSPA;
    673         case ServiceState.RIL_RADIO_TECHNOLOGY_IS95A:
    674         case ServiceState.RIL_RADIO_TECHNOLOGY_IS95B:
    675             return TelephonyManager.NETWORK_TYPE_CDMA;
    676         case ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT:
    677             return TelephonyManager.NETWORK_TYPE_1xRTT;
    678         case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0:
    679             return TelephonyManager.NETWORK_TYPE_EVDO_0;
    680         case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A:
    681             return TelephonyManager.NETWORK_TYPE_EVDO_A;
    682         case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B:
    683             return TelephonyManager.NETWORK_TYPE_EVDO_B;
    684         case ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD:
    685             return TelephonyManager.NETWORK_TYPE_EHRPD;
    686         case ServiceState.RIL_RADIO_TECHNOLOGY_LTE:
    687             return TelephonyManager.NETWORK_TYPE_LTE;
    688         case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP:
    689             return TelephonyManager.NETWORK_TYPE_HSPAP;
    690         default:
    691             return TelephonyManager.NETWORK_TYPE_UNKNOWN;
    692         }
    693     }
    694 
    695     /** @hide */
    696     public int getCssIndicator() {
    697         return this.mCssIndicator ? 1 : 0;
    698     }
    699 
    700     /** @hide */
    701     public int getNetworkId() {
    702         return this.mNetworkId;
    703     }
    704 
    705     /** @hide */
    706     public int getSystemId() {
    707         return this.mSystemId;
    708     }
    709 
    710     /** @hide */
    711     public static boolean isGsm(int radioTechnology) {
    712         return radioTechnology == RIL_RADIO_TECHNOLOGY_GPRS
    713                 || radioTechnology == RIL_RADIO_TECHNOLOGY_EDGE
    714                 || radioTechnology == RIL_RADIO_TECHNOLOGY_UMTS
    715                 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSDPA
    716                 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSUPA
    717                 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPA
    718                 || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE
    719                 || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPAP
    720                 || radioTechnology == RIL_RADIO_TECHNOLOGY_GSM;
    721     }
    722 
    723     /** @hide */
    724     public static boolean isCdma(int radioTechnology) {
    725         return radioTechnology == RIL_RADIO_TECHNOLOGY_IS95A
    726                 || radioTechnology == RIL_RADIO_TECHNOLOGY_IS95B
    727                 || radioTechnology == RIL_RADIO_TECHNOLOGY_1xRTT
    728                 || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_0
    729                 || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_A
    730                 || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_B
    731                 || radioTechnology == RIL_RADIO_TECHNOLOGY_EHRPD;
    732     }
    733 }
    734