diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:43 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:43 -0800 |
commit | f013e1afd1e68af5e3b868c26a653bbfb39538f8 (patch) | |
tree | 7ad6c8fd9c7b55f4b4017171dec1cb760bbd26bf /telephony/java/android/telephony/NeighboringCellInfo.java | |
parent | e70cfafe580c6f2994c4827cd8a534aabf3eb05c (diff) | |
download | frameworks_base-f013e1afd1e68af5e3b868c26a653bbfb39538f8.zip frameworks_base-f013e1afd1e68af5e3b868c26a653bbfb39538f8.tar.gz frameworks_base-f013e1afd1e68af5e3b868c26a653bbfb39538f8.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'telephony/java/android/telephony/NeighboringCellInfo.java')
-rw-r--r-- | telephony/java/android/telephony/NeighboringCellInfo.java | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/NeighboringCellInfo.java b/telephony/java/android/telephony/NeighboringCellInfo.java new file mode 100644 index 0000000..326401a --- /dev/null +++ b/telephony/java/android/telephony/NeighboringCellInfo.java @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Represents the neighboring cell information, including + * Received Signal Strength and Cell ID location. + */ +public class NeighboringCellInfo implements Parcelable +{ + /** + * Signal strength is not available + */ + static final public int UNKNOWN_RSSI = 99; + /** + * Cell location is not available + */ + static final public int UNKNOWN_CID = -1; + + private int mRssi; + private int mCid; + + /** + * Empty constructor. Initializes the RSSI and CID. + */ + public NeighboringCellInfo() { + mRssi = UNKNOWN_RSSI; + mCid = UNKNOWN_CID; + } + + /** + * Initialize the object from rssi and cid. + */ + public NeighboringCellInfo(int rssi, int cid) { + mRssi = rssi; + mCid = cid; + } + + /** + * Initialize the object from a parcel. + */ + public NeighboringCellInfo(Parcel in) { + mRssi = in.readInt(); + mCid = in.readInt(); + } + + /** + * @return received signal strength in "asu", ranging from 0 - 31, + * or UNKNOWN_RSSI if unknown + * + * For GSM, dBm = -113 + 2*asu, + * 0 means "-113 dBm or less" and 31 means "-51 dBm or greater" + */ + public int getRssi() { + return mRssi; + } + + /** + * @return cell id, UNKNOWN_CID if unknown, 0xffffffff max legal value + */ + public int getCid() { + return mCid; + } + + /** + * Set the cell id. + */ + public void setCid(int cid) { + mCid = cid; + } + + /** + * Set the signal strength of the cell. + */ + public void setRssi(int rssi) { + mRssi = rssi; + } + + @Override + public String toString() { + return "["+ ((mCid == UNKNOWN_CID) ? "/" : Integer.toHexString(mCid)) + + " at " + ((mRssi == UNKNOWN_RSSI)? "/" : mRssi) + "]"; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mRssi); + dest.writeInt(mCid); + } + + public static final Parcelable.Creator<NeighboringCellInfo> CREATOR + = new Parcelable.Creator<NeighboringCellInfo>() { + public NeighboringCellInfo createFromParcel(Parcel in) { + return new NeighboringCellInfo(in); + } + + public NeighboringCellInfo[] newArray(int size) { + return new NeighboringCellInfo[size]; + } + }; +} + + |