FileDocCategorySizeDatePackage
ServiceState.javaAPI DocAndroid 1.5 API9926Wed May 06 22:42:00 BST 2009android.telephony

ServiceState

public class ServiceState extends Object implements android.os.Parcelable
Contains phone state and service related information. The following phone information is included in returned ServiceState:
  • Service state: IN_SERVICE, OUT_OF_SERVICE, EMERGENCY_ONLY, POWER_OFF
  • Roaming indicator
  • Operator name, short name and numeric id
  • Network selection mode

Fields Summary
public static final int
STATE_IN_SERVICE
Normal operation condition, the phone is registered with an operator either in home network or in roaming.
public static final int
STATE_OUT_OF_SERVICE
Phone is not registered with any operator, the phone can be currently searching a new operator to register to, or not searching to registration at all, or registration is denied, or radio signal is not available.
public static final int
STATE_EMERGENCY_ONLY
The phone is registered and locked. Only emergency numbers are allowed. {@more}
public static final int
STATE_POWER_OFF
Radio of telephony is explictly powered off.
private int
mState
private boolean
mRoaming
private String
mOperatorAlphaLong
private String
mOperatorAlphaShort
private String
mOperatorNumeric
private boolean
mIsManualNetworkSelection
public static final Parcelable.Creator
CREATOR
Constructors Summary
public ServiceState()
Empty constructor

    
public ServiceState(ServiceState s)
Copy constructors

param
s Source service state

        copyFrom(s);
    
public ServiceState(android.os.Parcel in)
Construct a ServiceState object from the given parcel.

        mState = in.readInt();
        mRoaming = in.readInt() != 0;
        mOperatorAlphaLong = in.readString();
        mOperatorAlphaShort = in.readString();
        mOperatorNumeric = in.readString();
        mIsManualNetworkSelection = in.readInt() != 0;
    
Methods Summary
protected voidcopyFrom(android.telephony.ServiceState s)

        mState = s.mState;
        mRoaming = s.mRoaming;
        mOperatorAlphaLong = s.mOperatorAlphaLong;
        mOperatorAlphaShort = s.mOperatorAlphaShort;
        mOperatorNumeric = s.mOperatorNumeric;
        mIsManualNetworkSelection = s.mIsManualNetworkSelection;
    
public intdescribeContents()

        return 0;
    
public booleanequals(java.lang.Object o)

        ServiceState s;
        
        try {
            s = (ServiceState) o;
        } catch (ClassCastException ex) {
            return false;
        }

        if (o == null) {
            return false;
        }

        return mState == s.mState
                && mRoaming == s.mRoaming
                && mIsManualNetworkSelection == s.mIsManualNetworkSelection
                && equalsHandlesNulls(mOperatorAlphaLong, s.mOperatorAlphaLong)
                && equalsHandlesNulls(mOperatorAlphaShort, s.mOperatorAlphaShort)
                && equalsHandlesNulls(mOperatorNumeric, s.mOperatorNumeric);
    
private static booleanequalsHandlesNulls(java.lang.Object a, java.lang.Object b)
Test whether two objects hold the same data values or both are null

param
a first obj
param
b second obj
return
true if two objects equal or both are null

        return (a == null) ? (b == null) : a.equals (b);
    
public voidfillInNotifierBundle(android.os.Bundle m)
Set intent notifier Bundle based on service state

param
m intent notifier Bundle
hide

        m.putInt("state", mState);
        m.putBoolean("roaming", Boolean.valueOf(mRoaming));
        m.putString("operator-alpha-long", mOperatorAlphaLong);
        m.putString("operator-alpha-short", mOperatorAlphaShort);
        m.putString("operator-numeric", mOperatorNumeric);
        m.putBoolean("manual", Boolean.valueOf(mIsManualNetworkSelection));
    
public booleangetIsManualSelection()
Get current network selection mode

return
true if manual mode, false if automatic mode

        return mIsManualNetworkSelection;
    
public java.lang.StringgetOperatorAlphaLong()
Get current registered operator name in long alphanumeric format In GSM/UMTS, long format can be upto 16 characters long

return
long name of operator, null if unregistered or unknown

        return mOperatorAlphaLong;
    
public java.lang.StringgetOperatorAlphaShort()
Get current registered operator name in short lphanumeric format In GSM/UMST, short format can be upto 8 characters long

return
short name of operator, null if unregistered or unknown

        return mOperatorAlphaShort;
    
public java.lang.StringgetOperatorNumeric()
Get current registered operator numeric id In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit network code The country code can be decoded using MccTable.countryCodeForMcc()

return
numeric format of operator, null if unregistered or unknown

        return mOperatorNumeric;
    
public booleangetRoaming()
Get current roaming indicator of phone (note: not just decoding from TS 27.007 7.2)

return
true if TS 27.007 7.2 roaming is true and ONS is different from SPN

        return mRoaming;
    
public intgetState()
Get current servcie state of phone

see
#STATE_IN_SERVICE
see
#STATE_OUT_OF_SERVICE
see
#STATE_EMERGENCY_ONLY
see
#STATE_POWER_OFF


                       
       
        return mState;
    
public inthashCode()

        return (mState * 0x1234)
                + (mRoaming ? 1 : 0)
                + (mIsManualNetworkSelection ? 1 : 0)
                + ((null == mOperatorAlphaLong) ? 0 : mOperatorAlphaLong.hashCode())
                + ((null == mOperatorAlphaShort) ? 0 : mOperatorAlphaShort.hashCode())
                + ((null == mOperatorNumeric) ? 0 : mOperatorNumeric.hashCode());
    
public static android.telephony.ServiceStatenewFromBundle(android.os.Bundle m)
Create a new ServiceState from a intent notifier Bundle This method is used by PhoneStateIntentReceiver and maybe by external applications.

param
m Bundle from intent notifier
return
newly created ServiceState
hide


                                        
         
        ServiceState ret;
        ret = new ServiceState();
        ret.setFromNotifierBundle(m);
        return ret;
    
private voidsetFromNotifierBundle(android.os.Bundle m)
Set ServiceState based on intent notifier map

param
m intent notifier map
hide

        mState = m.getInt("state");
        mRoaming = m.getBoolean("roaming");
        mOperatorAlphaLong = m.getString("operator-alpha-long");
        mOperatorAlphaShort = m.getString("operator-alpha-short");
        mOperatorNumeric = m.getString("operator-numeric");
        mIsManualNetworkSelection = m.getBoolean("manual");
    
public voidsetIsManualSelection(boolean isManual)

        mIsManualNetworkSelection = isManual;
    
public voidsetOperatorName(java.lang.String longName, java.lang.String shortName, java.lang.String numeric)

        mOperatorAlphaLong = longName;
        mOperatorAlphaShort = shortName;
        mOperatorNumeric = numeric;
    
public voidsetRoaming(boolean roaming)

        mRoaming = roaming;
    
public voidsetState(int state)

        mState = state;
    
public voidsetStateOff()

        mState = STATE_POWER_OFF;
        mRoaming = false;
        mOperatorAlphaLong = null;
        mOperatorAlphaShort = null;
        mOperatorNumeric = null;
        mIsManualNetworkSelection = false;
    
public voidsetStateOutOfService()

        mState = STATE_OUT_OF_SERVICE;
        mRoaming = false;
        mOperatorAlphaLong = null;
        mOperatorAlphaShort = null;
        mOperatorNumeric = null;
        mIsManualNetworkSelection = false;
    
public java.lang.StringtoString()

        return mState + " " + (mRoaming ? "roaming" : "home")
                + " " + mOperatorAlphaLong
                + " " + mOperatorAlphaShort
                + " " + mOperatorNumeric
                + " " + (mIsManualNetworkSelection ? "(manual)" : "");
    
public voidwriteToParcel(android.os.Parcel out, int flags)

        out.writeInt(mState);
        out.writeInt(mRoaming ? 1 : 0);
        out.writeString(mOperatorAlphaLong);
        out.writeString(mOperatorAlphaShort);
        out.writeString(mOperatorNumeric);
        out.writeInt(mIsManualNetworkSelection ? 1 : 0);