am 7f6fc129: Merge "Add CellInfoWcdma and related classes." into jb-mr2-dev
* commit '7f6fc12997d67ae80a044bc0b4cc17797d887911': Add CellInfoWcdma and related classes.
This commit is contained in:
@@ -21571,7 +21571,7 @@ package android.telephony {
|
||||
method public int getLac();
|
||||
method public int getMcc();
|
||||
method public int getMnc();
|
||||
method public int getPsc();
|
||||
method public deprecated int getPsc();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
@@ -21587,6 +21587,17 @@ package android.telephony {
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public final class CellIdentityWcdma implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public int getCid();
|
||||
method public int getLac();
|
||||
method public int getMcc();
|
||||
method public int getMnc();
|
||||
method public int getPsc();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public abstract class CellInfo implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public long getTimeStamp();
|
||||
@@ -21616,6 +21627,13 @@ package android.telephony {
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public final class CellInfoWcdma extends android.telephony.CellInfo implements android.os.Parcelable {
|
||||
method public android.telephony.CellIdentityWcdma getCellIdentity();
|
||||
method public android.telephony.CellSignalStrengthWcdma getCellSignalStrength();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public abstract class CellLocation {
|
||||
ctor public CellLocation();
|
||||
method public static android.telephony.CellLocation getEmpty();
|
||||
@@ -21671,6 +21689,17 @@ package android.telephony {
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public final class CellSignalStrengthWcdma extends android.telephony.CellSignalStrength implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public boolean equals(java.lang.Object);
|
||||
method public int getAsuLevel();
|
||||
method public int getDbm();
|
||||
method public int getLevel();
|
||||
method public int hashCode();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public class NeighboringCellInfo implements android.os.Parcelable {
|
||||
ctor public deprecated NeighboringCellInfo();
|
||||
ctor public deprecated NeighboringCellInfo(int, int);
|
||||
|
||||
@@ -93,21 +93,21 @@ public final class CellIdentityCdma implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Network Id 0..65535
|
||||
* @return Network Id 0..65535, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getNetworkId() {
|
||||
return mNetworkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return System Id 0..32767
|
||||
* @return System Id 0..32767, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getSystemId() {
|
||||
return mSystemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Base Station Id 0..65535
|
||||
* @return Base Station Id 0..65535, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getBasestationId() {
|
||||
return mBasestationId;
|
||||
@@ -118,7 +118,7 @@ public final class CellIdentityCdma implements Parcelable {
|
||||
* specified in 3GPP2 C.S0005-A v6.0. It is represented in units
|
||||
* of 0.25 seconds and ranges from -2592000 to 2592000, both
|
||||
* values inclusive (corresponding to a range of -180
|
||||
* to +180 degrees).
|
||||
* to +180 degrees). Integer.MAX_VALUE if unknown.
|
||||
*/
|
||||
public int getLongitude() {
|
||||
return mLongitude;
|
||||
@@ -129,7 +129,7 @@ public final class CellIdentityCdma implements Parcelable {
|
||||
* specified in 3GPP2 C.S0005-A v6.0. It is represented in units
|
||||
* of 0.25 seconds and ranges from -1296000 to 1296000, both
|
||||
* values inclusive (corresponding to a range of -90
|
||||
* to +90 degrees).
|
||||
* to +90 degrees). Integer.MAX_VALUE if unknown.
|
||||
*/
|
||||
public int getLatitude() {
|
||||
return mLatitude;
|
||||
@@ -162,7 +162,7 @@ public final class CellIdentityCdma implements Parcelable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("CellIdentitiyCdma:{");
|
||||
StringBuilder sb = new StringBuilder("CellIdentityCdma:{");
|
||||
sb.append(" mNetworkId="); sb.append(mNetworkId);
|
||||
sb.append(" mSystemId="); sb.append(mSystemId);
|
||||
sb.append(" mBasestationId="); sb.append(mBasestationId);
|
||||
|
||||
@@ -21,7 +21,7 @@ import android.os.Parcelable;
|
||||
import android.telephony.Rlog;
|
||||
|
||||
/**
|
||||
* CellIdentity to represent a unique GSM or UMTS cell
|
||||
* CellIdentity to represent a unique GSM cell
|
||||
*/
|
||||
public final class CellIdentityGsm implements Parcelable {
|
||||
|
||||
@@ -35,10 +35,7 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
// 16-bit Location Area Code, 0..65535
|
||||
private final int mLac;
|
||||
// 16-bit GSM Cell Identity described in TS 27.007, 0..65535
|
||||
// 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455
|
||||
private final int mCid;
|
||||
// 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511
|
||||
private final int mPsc;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -48,7 +45,6 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
mMnc = Integer.MAX_VALUE;
|
||||
mLac = Integer.MAX_VALUE;
|
||||
mCid = Integer.MAX_VALUE;
|
||||
mPsc = Integer.MAX_VALUE;
|
||||
}
|
||||
/**
|
||||
* public constructor
|
||||
@@ -56,16 +52,14 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
|
||||
* @param lac 16-bit Location Area Code, 0..65535
|
||||
* @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity
|
||||
* @param psc 9-bit UMTS Primary Scrambling Code
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellIdentityGsm (int mcc, int mnc, int lac, int cid, int psc) {
|
||||
public CellIdentityGsm (int mcc, int mnc, int lac, int cid) {
|
||||
mMcc = mcc;
|
||||
mMnc = mnc;
|
||||
mLac = lac;
|
||||
mCid = cid;
|
||||
mPsc = psc;
|
||||
}
|
||||
|
||||
private CellIdentityGsm(CellIdentityGsm cid) {
|
||||
@@ -73,7 +67,6 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
mMnc = cid.mMnc;
|
||||
mLac = cid.mLac;
|
||||
mCid = cid.mCid;
|
||||
mPsc = cid.mPsc;
|
||||
}
|
||||
|
||||
CellIdentityGsm copy() {
|
||||
@@ -81,21 +74,21 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 3-digit Mobile Country Code, 0..999
|
||||
* @return 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getMcc() {
|
||||
return mMcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 2 or 3-digit Mobile Network Code, 0..999
|
||||
* @return 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getMnc() {
|
||||
return mMnc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 16-bit Location Area Code, 0..65535
|
||||
* @return 16-bit Location Area Code, 0..65535, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getLac() {
|
||||
return mLac;
|
||||
@@ -104,27 +97,24 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
/**
|
||||
* @return CID
|
||||
* Either 16-bit GSM Cell Identity described
|
||||
* in TS 27.007, 0..65535
|
||||
* or 28-bit UMTS Cell Identity described
|
||||
* in TS 25.331, 0..268435455
|
||||
* in TS 27.007, 0..65535, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getCid() {
|
||||
return mCid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 9-bit UMTS Primary Scrambling Code described in
|
||||
* TS 25.331, 0..511
|
||||
* @return Integer.MAX_VALUE, undefined for GSM
|
||||
*/
|
||||
@Deprecated
|
||||
public int getPsc() {
|
||||
return mPsc;
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum) +
|
||||
(mPsc * primeNum);
|
||||
return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,8 +125,7 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
return mMcc == o.mMcc &&
|
||||
mMnc == o.mMnc &&
|
||||
mLac == o.mLac &&
|
||||
mCid == o.mCid &&
|
||||
mPsc == o.mPsc;
|
||||
mCid == o.mCid;
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
@@ -147,12 +136,11 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("CellIdentitiyGsm:{");
|
||||
StringBuilder sb = new StringBuilder("CellIdentityGsm:{");
|
||||
sb.append(" mMcc=").append(mMcc);
|
||||
sb.append(" mMnc=").append(mMnc);
|
||||
sb.append(" mLac=").append(mLac);
|
||||
sb.append(" mCid=").append(mCid);
|
||||
sb.append(" mPsc=").append(mPsc);
|
||||
sb.append("}");
|
||||
|
||||
return sb.toString();
|
||||
@@ -172,7 +160,6 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
dest.writeInt(mMnc);
|
||||
dest.writeInt(mLac);
|
||||
dest.writeInt(mCid);
|
||||
dest.writeInt(mPsc);
|
||||
}
|
||||
|
||||
/** Construct from Parcel, type has already been processed */
|
||||
@@ -181,7 +168,6 @@ public final class CellIdentityGsm implements Parcelable {
|
||||
mMnc = in.readInt();
|
||||
mLac = in.readInt();
|
||||
mCid = in.readInt();
|
||||
mPsc = in.readInt();
|
||||
if (DBG) log("CellIdentityGsm(Parcel): " + toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -81,35 +81,35 @@ public final class CellIdentityLte implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 3-digit Mobile Country Code, 0..999
|
||||
* @return 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getMcc() {
|
||||
return mMcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 2 or 3-digit Mobile Network Code, 0..999
|
||||
* @return 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getMnc() {
|
||||
return mMnc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 28-bit Cell Identity
|
||||
* @return 28-bit Cell Identity, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getCi() {
|
||||
return mCi;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Physical Cell Id 0..503
|
||||
* @return Physical Cell Id 0..503, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getPci() {
|
||||
return mPci;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 16-bit Tracking Area Code
|
||||
* @return 16-bit Tracking Area Code, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getTac() {
|
||||
return mTac;
|
||||
@@ -142,7 +142,7 @@ public final class CellIdentityLte implements Parcelable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("CellIdentitiyLte:{");
|
||||
StringBuilder sb = new StringBuilder("CellIdentityLte:{");
|
||||
sb.append(" mMcc="); sb.append(mMcc);
|
||||
sb.append(" mMnc="); sb.append(mMnc);
|
||||
sb.append(" mCi="); sb.append(mCi);
|
||||
|
||||
205
telephony/java/android/telephony/CellIdentityWcdma.java
Normal file
205
telephony/java/android/telephony/CellIdentityWcdma.java
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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;
|
||||
import android.telephony.Rlog;
|
||||
|
||||
/**
|
||||
* CellIdentity to represent a unique UMTS cell
|
||||
*/
|
||||
public final class CellIdentityWcdma implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellIdentityWcdma";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
// 3-digit Mobile Country Code, 0..999
|
||||
private final int mMcc;
|
||||
// 2 or 3-digit Mobile Network Code, 0..999
|
||||
private final int mMnc;
|
||||
// 16-bit Location Area Code, 0..65535
|
||||
private final int mLac;
|
||||
// 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455
|
||||
private final int mCid;
|
||||
// 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511
|
||||
private final int mPsc;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public CellIdentityWcdma() {
|
||||
mMcc = Integer.MAX_VALUE;
|
||||
mMnc = Integer.MAX_VALUE;
|
||||
mLac = Integer.MAX_VALUE;
|
||||
mCid = Integer.MAX_VALUE;
|
||||
mPsc = Integer.MAX_VALUE;
|
||||
}
|
||||
/**
|
||||
* public constructor
|
||||
* @param mcc 3-digit Mobile Country Code, 0..999
|
||||
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
|
||||
* @param lac 16-bit Location Area Code, 0..65535
|
||||
* @param cid 28-bit UMTS Cell Identity
|
||||
* @param psc 9-bit UMTS Primary Scrambling Code
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellIdentityWcdma (int mcc, int mnc, int lac, int cid, int psc) {
|
||||
mMcc = mcc;
|
||||
mMnc = mnc;
|
||||
mLac = lac;
|
||||
mCid = cid;
|
||||
mPsc = psc;
|
||||
}
|
||||
|
||||
private CellIdentityWcdma(CellIdentityWcdma cid) {
|
||||
mMcc = cid.mMcc;
|
||||
mMnc = cid.mMnc;
|
||||
mLac = cid.mLac;
|
||||
mCid = cid.mCid;
|
||||
mPsc = cid.mPsc;
|
||||
}
|
||||
|
||||
CellIdentityWcdma copy() {
|
||||
return new CellIdentityWcdma(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getMcc() {
|
||||
return mMcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getMnc() {
|
||||
return mMnc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 16-bit Location Area Code, 0..65535, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getLac() {
|
||||
return mLac;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CID
|
||||
* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, Integer.MAX_VALUE if unknown
|
||||
*/
|
||||
public int getCid() {
|
||||
return mCid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, Integer.MAX_VALUE
|
||||
* if unknown
|
||||
*/
|
||||
public int getPsc() {
|
||||
return mPsc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum) +
|
||||
(mPsc * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (super.equals(other)) {
|
||||
try {
|
||||
CellIdentityWcdma o = (CellIdentityWcdma)other;
|
||||
return mMcc == o.mMcc &&
|
||||
mMnc == o.mMnc &&
|
||||
mLac == o.mLac &&
|
||||
mCid == o.mCid &&
|
||||
mPsc == o.mPsc;
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("CellIdentityWcdma:{");
|
||||
sb.append(" mMcc=").append(mMcc);
|
||||
sb.append(" mMnc=").append(mMnc);
|
||||
sb.append(" mLac=").append(mLac);
|
||||
sb.append(" mCid=").append(mCid);
|
||||
sb.append(" mPsc=").append(mPsc);
|
||||
sb.append("}");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(mMcc);
|
||||
dest.writeInt(mMnc);
|
||||
dest.writeInt(mLac);
|
||||
dest.writeInt(mCid);
|
||||
dest.writeInt(mPsc);
|
||||
}
|
||||
|
||||
/** Construct from Parcel, type has already been processed */
|
||||
private CellIdentityWcdma(Parcel in) {
|
||||
mMcc = in.readInt();
|
||||
mMnc = in.readInt();
|
||||
mLac = in.readInt();
|
||||
mCid = in.readInt();
|
||||
mPsc = in.readInt();
|
||||
if (DBG) log("CellIdentityWcdma(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Creator<CellIdentityWcdma> CREATOR =
|
||||
new Creator<CellIdentityWcdma>() {
|
||||
@Override
|
||||
public CellIdentityWcdma createFromParcel(Parcel in) {
|
||||
return new CellIdentityWcdma(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellIdentityWcdma[] newArray(int size) {
|
||||
return new CellIdentityWcdma[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Rlog.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ public abstract class CellInfo implements Parcelable {
|
||||
protected static final int TYPE_CDMA = 2;
|
||||
/** @hide */
|
||||
protected static final int TYPE_LTE = 3;
|
||||
/** @hide */
|
||||
protected static final int TYPE_WCDMA = 4;
|
||||
|
||||
// Type to distinguish where time stamp gets recorded.
|
||||
|
||||
@@ -201,6 +203,7 @@ public abstract class CellInfo implements Parcelable {
|
||||
case TYPE_GSM: return CellInfoGsm.createFromParcelBody(in);
|
||||
case TYPE_CDMA: return CellInfoCdma.createFromParcelBody(in);
|
||||
case TYPE_LTE: return CellInfoLte.createFromParcelBody(in);
|
||||
case TYPE_WCDMA: return CellInfoWcdma.createFromParcelBody(in);
|
||||
default: throw new RuntimeException("Bad CellInfo Parcel");
|
||||
}
|
||||
}
|
||||
|
||||
148
telephony/java/android/telephony/CellInfoWcdma.java
Normal file
148
telephony/java/android/telephony/CellInfoWcdma.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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;
|
||||
import android.telephony.Rlog;
|
||||
|
||||
/**
|
||||
* Immutable cell information from a point in time.
|
||||
*/
|
||||
public final class CellInfoWcdma extends CellInfo implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellInfoWcdma";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private CellIdentityWcdma mCellIdentityWcdma;
|
||||
private CellSignalStrengthWcdma mCellSignalStrengthWcdma;
|
||||
|
||||
/** @hide */
|
||||
public CellInfoWcdma() {
|
||||
super();
|
||||
mCellIdentityWcdma = new CellIdentityWcdma();
|
||||
mCellSignalStrengthWcdma = new CellSignalStrengthWcdma();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public CellInfoWcdma(CellInfoWcdma ci) {
|
||||
super(ci);
|
||||
this.mCellIdentityWcdma = ci.mCellIdentityWcdma.copy();
|
||||
this.mCellSignalStrengthWcdma = ci.mCellSignalStrengthWcdma.copy();
|
||||
}
|
||||
|
||||
public CellIdentityWcdma getCellIdentity() {
|
||||
return mCellIdentityWcdma;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellIdentity(CellIdentityWcdma cid) {
|
||||
mCellIdentityWcdma = cid;
|
||||
}
|
||||
|
||||
public CellSignalStrengthWcdma getCellSignalStrength() {
|
||||
return mCellSignalStrengthWcdma;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellSignalStrength(CellSignalStrengthWcdma css) {
|
||||
mCellSignalStrengthWcdma = css;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + mCellIdentityWcdma.hashCode() + mCellSignalStrengthWcdma.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!super.equals(other)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
CellInfoWcdma o = (CellInfoWcdma) other;
|
||||
return mCellIdentityWcdma.equals(o.mCellIdentityWcdma)
|
||||
&& mCellSignalStrengthWcdma.equals(o.mCellSignalStrengthWcdma);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append("CellInfoWcdma:{");
|
||||
sb.append(super.toString());
|
||||
sb.append(" ").append(mCellIdentityWcdma);
|
||||
sb.append(" ").append(mCellSignalStrengthWcdma);
|
||||
sb.append("}");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags, TYPE_WCDMA);
|
||||
mCellIdentityWcdma.writeToParcel(dest, flags);
|
||||
mCellSignalStrengthWcdma.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a CellInfoWcdma object from the given parcel
|
||||
* where the token is already been processed.
|
||||
*/
|
||||
private CellInfoWcdma(Parcel in) {
|
||||
super(in);
|
||||
mCellIdentityWcdma = CellIdentityWcdma.CREATOR.createFromParcel(in);
|
||||
mCellSignalStrengthWcdma = CellSignalStrengthWcdma.CREATOR.createFromParcel(in);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public static final Creator<CellInfoWcdma> CREATOR = new Creator<CellInfoWcdma>() {
|
||||
@Override
|
||||
public CellInfoWcdma createFromParcel(Parcel in) {
|
||||
in.readInt(); // Skip past token, we know what it is
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellInfoWcdma[] newArray(int size) {
|
||||
return new CellInfoWcdma[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
protected static CellInfoWcdma createFromParcelBody(Parcel in) {
|
||||
return new CellInfoWcdma(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Rlog.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import android.os.Parcelable;
|
||||
import android.telephony.Rlog;
|
||||
|
||||
/**
|
||||
* LTE signal strength related information.
|
||||
* GSM signal strength related information.
|
||||
*/
|
||||
public final class CellSignalStrengthGsm extends CellSignalStrength implements Parcelable {
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class CellSignalStrengthGsm extends CellSignalStrength implements P
|
||||
|
||||
private static final int GSM_SIGNAL_STRENGTH_GREAT = 12;
|
||||
private static final int GSM_SIGNAL_STRENGTH_GOOD = 8;
|
||||
private static final int GSM_SIGNAL_STRENGTH_MODERATE = 8;
|
||||
private static final int GSM_SIGNAL_STRENGTH_MODERATE = 5;
|
||||
|
||||
private int mSignalStrength; // Valid values are (0-31, 99) as defined in TS 27.007 8.5
|
||||
private int mBitErrorRate; // bit error rate (0-7, 99) as defined in TS 27.007 8.5
|
||||
@@ -67,7 +67,8 @@ public final class CellSignalStrengthGsm extends CellSignalStrength implements P
|
||||
/**
|
||||
* Initialize all the values
|
||||
*
|
||||
* @param SignalStrength
|
||||
* @param ss SignalStrength as ASU value
|
||||
* @param ber is Bit Error Rate
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@@ -139,7 +140,7 @@ public final class CellSignalStrengthGsm extends CellSignalStrength implements P
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LTE signal level as an asu value between 0..97, 99 is unknown
|
||||
* Get the signal level as an asu value between 0..31, 99 is unknown
|
||||
* Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
|
||||
*/
|
||||
@Override
|
||||
|
||||
235
telephony/java/android/telephony/CellSignalStrengthWcdma.java
Normal file
235
telephony/java/android/telephony/CellSignalStrengthWcdma.java
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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;
|
||||
import android.telephony.Rlog;
|
||||
|
||||
/**
|
||||
* Wcdma signal strength related information.
|
||||
*/
|
||||
public final class CellSignalStrengthWcdma extends CellSignalStrength implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellSignalStrengthWcdma";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private static final int WCDMA_SIGNAL_STRENGTH_GREAT = 12;
|
||||
private static final int WCDMA_SIGNAL_STRENGTH_GOOD = 8;
|
||||
private static final int WCDMA_SIGNAL_STRENGTH_MODERATE = 5;
|
||||
|
||||
private int mSignalStrength; // Valid values are (0-31, 99) as defined in TS 27.007 8.5
|
||||
private int mBitErrorRate; // bit error rate (0-7, 99) as defined in TS 27.007 8.5
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthWcdma() {
|
||||
setDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthWcdma(int ss, int ber) {
|
||||
initialize(ss, ber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructors
|
||||
*
|
||||
* @param s Source SignalStrength
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthWcdma(CellSignalStrengthWcdma s) {
|
||||
copyFrom(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all the values
|
||||
*
|
||||
* @param ss SignalStrength as ASU value
|
||||
* @param ber is Bit Error Rate
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void initialize(int ss, int ber) {
|
||||
mSignalStrength = ss;
|
||||
mBitErrorRate = ber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
protected void copyFrom(CellSignalStrengthWcdma s) {
|
||||
mSignalStrength = s.mSignalStrength;
|
||||
mBitErrorRate = s.mBitErrorRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public CellSignalStrengthWcdma copy() {
|
||||
return new CellSignalStrengthWcdma(this);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void setDefaultValues() {
|
||||
mSignalStrength = Integer.MAX_VALUE;
|
||||
mBitErrorRate = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get signal level as an int from 0..4
|
||||
*/
|
||||
@Override
|
||||
public int getLevel() {
|
||||
int level;
|
||||
|
||||
// ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
|
||||
// asu = 0 (-113dB or less) is very weak
|
||||
// signal, its better to show 0 bars to the user in such cases.
|
||||
// asu = 99 is a special case, where the signal strength is unknown.
|
||||
int asu = mSignalStrength;
|
||||
if (asu <= 2 || asu == 99) level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
||||
else if (asu >= WCDMA_SIGNAL_STRENGTH_GREAT) level = SIGNAL_STRENGTH_GREAT;
|
||||
else if (asu >= WCDMA_SIGNAL_STRENGTH_GOOD) level = SIGNAL_STRENGTH_GOOD;
|
||||
else if (asu >= WCDMA_SIGNAL_STRENGTH_MODERATE) level = SIGNAL_STRENGTH_MODERATE;
|
||||
else level = SIGNAL_STRENGTH_POOR;
|
||||
if (DBG) log("getLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the signal strength as dBm
|
||||
*/
|
||||
@Override
|
||||
public int getDbm() {
|
||||
int dBm;
|
||||
|
||||
int level = mSignalStrength;
|
||||
int asu = (level == 99 ? Integer.MAX_VALUE : level);
|
||||
if (asu != Integer.MAX_VALUE) {
|
||||
dBm = -113 + (2 * asu);
|
||||
} else {
|
||||
dBm = Integer.MAX_VALUE;
|
||||
}
|
||||
if (DBG) log("getDbm=" + dBm);
|
||||
return dBm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the signal level as an asu value between 0..31, 99 is unknown
|
||||
* Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
|
||||
*/
|
||||
@Override
|
||||
public int getAsuLevel() {
|
||||
// ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
|
||||
// asu = 0 (-113dB or less) is very weak
|
||||
// signal, its better to show 0 bars to the user in such cases.
|
||||
// asu = 99 is a special case, where the signal strength is unknown.
|
||||
int level = mSignalStrength;
|
||||
if (DBG) log("getAsuLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mSignalStrength * primeNum) + (mBitErrorRate * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object o) {
|
||||
CellSignalStrengthWcdma s;
|
||||
|
||||
try {
|
||||
s = (CellSignalStrengthWcdma) o;
|
||||
} catch (ClassCastException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mSignalStrength == s.mSignalStrength && mBitErrorRate == s.mBitErrorRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string representation.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CellSignalStrengthWcdma:"
|
||||
+ " ss=" + mSignalStrength
|
||||
+ " ber=" + mBitErrorRate;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(mSignalStrength);
|
||||
dest.writeInt(mBitErrorRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a SignalStrength object from the given parcel
|
||||
* where the token is already been processed.
|
||||
*/
|
||||
private CellSignalStrengthWcdma(Parcel in) {
|
||||
mSignalStrength = in.readInt();
|
||||
mBitErrorRate = in.readInt();
|
||||
if (DBG) log("CellSignalStrengthWcdma(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Parcelable.Creator<CellSignalStrengthWcdma> CREATOR =
|
||||
new Parcelable.Creator<CellSignalStrengthWcdma>() {
|
||||
@Override
|
||||
public CellSignalStrengthWcdma createFromParcel(Parcel in) {
|
||||
return new CellSignalStrengthWcdma(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellSignalStrengthWcdma[] newArray(int size) {
|
||||
return new CellSignalStrengthWcdma[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Rlog.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user