NeighboringCellInfopublic class NeighboringCellInfo extends Object implements android.os.ParcelableRepresents the neighboring cell information, including
Received Signal Strength and Cell ID location. |
Fields Summary |
---|
public static final int | UNKNOWN_RSSISignal strength is not available | public static final int | UNKNOWN_CIDCell location is not available | private int | mRssiIn GSM, mRssi is the Received RSSI;
In UMTS, mRssi is the Level index of CPICH Received Signal Code Power | private int | mCidCID in 16 bits format in GSM. Return UNKNOWN_CID in UMTS and CMDA. | private int | mLacLAC in 16 bits format in GSM. Return UNKNOWN_CID in UMTS and CMDA. | private int | mPscPrimary Scrambling Code in 9 bits format in UMTS
Return UNKNOWN_CID in GSM and CMDA. | private int | mNetworkTypeRadio 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.
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.
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 int | describeContents()
return 0;
| public int | getCid()
return mCid;
| public int | getLac()
return mLac;
| public int | getNetworkType()
return mNetworkType;
| public int | getPsc()
return mPsc;
| public int | getRssi()
return mRssi;
| public void | setCid(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.
mCid = cid;
| public void | setRssi(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.
mRssi = rssi;
| public java.lang.String | toString()
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 void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mRssi);
dest.writeInt(mLac);
dest.writeInt(mCid);
dest.writeInt(mPsc);
dest.writeInt(mNetworkType);
|
|