FileDocCategorySizeDatePackage
NeighboringCellInfo.javaAPI DocAndroid 5.1 API10161Thu Mar 12 22:22:42 GMT 2015android.telephony

NeighboringCellInfo

public class NeighboringCellInfo extends Object implements android.os.Parcelable
Represents the neighboring cell information, including Received Signal Strength and Cell ID location.

Fields Summary
public static final int
UNKNOWN_RSSI
Signal strength is not available
public static final int
UNKNOWN_CID
Cell location is not available
private int
mRssi
In GSM, mRssi is the Received RSSI; In UMTS, mRssi is the Level index of CPICH Received Signal Code Power
private int
mCid
CID in 16 bits format in GSM. Return UNKNOWN_CID in UMTS and CMDA.
private int
mLac
LAC in 16 bits format in GSM. Return UNKNOWN_CID in UMTS and CMDA.
private int
mPsc
Primary Scrambling Code in 9 bits format in UMTS Return UNKNOWN_CID in GSM and CMDA.
private int
mNetworkType
Radio network type, value is one of following TelephonyManager.NETWORK_TYPE_XXXXXX.
public static final Parcelable.Creator
CREATOR
Constructors Summary
public NeighboringCellInfo()
Empty constructor. Initializes the RSSI and CID. NeighboringCellInfo is one time shot for the neighboring cells based on the radio network type at that moment. Its constructor needs radio network type.

deprecated
by {@link #NeighboringCellInfo(int, String, int)}


                                               
    
      
        mRssi = UNKNOWN_RSSI;
        mLac = UNKNOWN_CID;
        mCid = UNKNOWN_CID;
        mPsc = UNKNOWN_CID;
        mNetworkType = NETWORK_TYPE_UNKNOWN;
    
public NeighboringCellInfo(int rssi, int cid)
Initialize the object from rssi and cid. NeighboringCellInfo is one time shot for the neighboring cells based on the radio network type at that moment. Its constructor needs radio network type.

deprecated
by {@link #NeighboringCellInfo(int, String, int)}

        mRssi = rssi;
        mCid = cid;
    
public NeighboringCellInfo(int rssi, String location, int radioType)
Initialize the object from rssi, location string, and radioType radioType is one of following {@link TelephonyManager#NETWORK_TYPE_GPRS TelephonyManager.NETWORK_TYPE_GPRS}, {@link TelephonyManager#NETWORK_TYPE_EDGE TelephonyManager.NETWORK_TYPE_EDGE}, {@link TelephonyManager#NETWORK_TYPE_UMTS TelephonyManager.NETWORK_TYPE_UMTS}, {@link TelephonyManager#NETWORK_TYPE_HSDPA TelephonyManager.NETWORK_TYPE_HSDPA}, {@link TelephonyManager#NETWORK_TYPE_HSUPA TelephonyManager.NETWORK_TYPE_HSUPA}, and {@link TelephonyManager#NETWORK_TYPE_HSPA TelephonyManager.NETWORK_TYPE_HSPA}.

        // set default value
        mRssi = rssi;
        mNetworkType = NETWORK_TYPE_UNKNOWN;
        mPsc = UNKNOWN_CID;
        mLac = UNKNOWN_CID;
        mCid = UNKNOWN_CID;


        // pad location string with leading "0"
        int l = location.length();
        if (l > 8) return;
        if (l < 8) {
            for (int i = 0; i < (8-l); i++) {
                location = "0" + location;
            }
        }
        // TODO - handle LTE and eHRPD (or find they can't be supported)
        try {// set LAC/CID or PSC based on radioType
            switch (radioType) {
            case NETWORK_TYPE_GPRS:
            case NETWORK_TYPE_EDGE:
                mNetworkType = radioType;
                // check if 0xFFFFFFFF for UNKNOWN_CID
                if (!location.equalsIgnoreCase("FFFFFFFF")) {
                    mCid = Integer.valueOf(location.substring(4), 16);
                    mLac = Integer.valueOf(location.substring(0, 4), 16);
                }
                break;
            case NETWORK_TYPE_UMTS:
            case NETWORK_TYPE_HSDPA:
            case NETWORK_TYPE_HSUPA:
            case NETWORK_TYPE_HSPA:
                mNetworkType = radioType;
                mPsc = Integer.valueOf(location, 16);
                break;
            }
        } catch (NumberFormatException e) {
            // parsing location error
            mPsc = UNKNOWN_CID;
            mLac = UNKNOWN_CID;
            mCid = UNKNOWN_CID;
            mNetworkType = NETWORK_TYPE_UNKNOWN;
        }
    
public NeighboringCellInfo(android.os.Parcel in)
Initialize the object from a parcel.

        mRssi = in.readInt();
        mLac = in.readInt();
        mCid = in.readInt();
        mPsc = in.readInt();
        mNetworkType = in.readInt();
    
Methods Summary
public intdescribeContents()

        return 0;
    
public intgetCid()

return
cell id in GSM, 0xffff max legal value UNKNOWN_CID if in UMTS or CDMA or unknown

        return mCid;
    
public intgetLac()

return
LAC in GSM, 0xffff max legal value UNKNOWN_CID if in UMTS or CMDA or unknown

        return mLac;
    
public intgetNetworkType()

return
Radio network type while neighboring cell location is stored. Return {@link TelephonyManager#NETWORK_TYPE_UNKNOWN TelephonyManager.NETWORK_TYPE_UNKNOWN} means that the location information is unavailable. Return {@link TelephonyManager#NETWORK_TYPE_GPRS TelephonyManager.NETWORK_TYPE_GPRS} or {@link TelephonyManager#NETWORK_TYPE_EDGE TelephonyManager.NETWORK_TYPE_EDGE} means that Neighboring Cell information is stored for GSM network, in which {@link NeighboringCellInfo#getLac NeighboringCellInfo.getLac} and {@link NeighboringCellInfo#getCid NeighboringCellInfo.getCid} should be called to access location. Return {@link TelephonyManager#NETWORK_TYPE_UMTS TelephonyManager.NETWORK_TYPE_UMTS}, {@link TelephonyManager#NETWORK_TYPE_HSDPA TelephonyManager.NETWORK_TYPE_HSDPA}, {@link TelephonyManager#NETWORK_TYPE_HSUPA TelephonyManager.NETWORK_TYPE_HSUPA}, or {@link TelephonyManager#NETWORK_TYPE_HSPA TelephonyManager.NETWORK_TYPE_HSPA} means that Neighboring Cell information is stored for UMTS network, in which {@link NeighboringCellInfo#getPsc NeighboringCellInfo.getPsc} should be called to access location.

        return mNetworkType;
    
public intgetPsc()

return
Primary Scrambling Code in 9 bits format in UMTS, 0x1ff max value UNKNOWN_CID if in GSM or CMDA or unknown

        return mPsc;
    
public intgetRssi()

return
received signal strength or UNKNOWN_RSSI if unknown For GSM, it is in "asu" ranging from 0 to 31 (dBm = -113 + 2*asu) 0 means "-113 dBm or less" and 31 means "-51 dBm or greater" For UMTS, it is the Level index of CPICH RSCP defined in TS 25.125

        return mRssi;
    
public voidsetCid(int cid)
Set the cell id. NeighboringCellInfo is a one time shot for the neighboring cells based on the radio network type at that moment. It shouldn't be changed after creation.

deprecated
cid value passed as in location parameter passed to constructor {@link #NeighboringCellInfo(int, String, int)}

        mCid = cid;
    
public voidsetRssi(int rssi)
Set the signal strength of the cell. NeighboringCellInfo is a one time shot for the neighboring cells based on the radio network type at that moment. It shouldn't be changed after creation.

deprecated
initial rssi value passed as parameter to constructor {@link #NeighboringCellInfo(int, String, int)}

        mRssi = rssi;
    
public java.lang.StringtoString()

        StringBuilder sb = new StringBuilder();

        sb.append("[");
        if (mPsc != UNKNOWN_CID) {
            sb.append(Integer.toHexString(mPsc))
                    .append("@").append(((mRssi == UNKNOWN_RSSI)? "-" : mRssi));
        } else if(mLac != UNKNOWN_CID && mCid != UNKNOWN_CID) {
            sb.append(Integer.toHexString(mLac))
                    .append(Integer.toHexString(mCid))
                    .append("@").append(((mRssi == UNKNOWN_RSSI)? "-" : mRssi));
        }
        sb.append("]");

        return sb.toString();
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeInt(mRssi);
        dest.writeInt(mLac);
        dest.writeInt(mCid);
        dest.writeInt(mPsc);
        dest.writeInt(mNetworkType);