diff options
| -rw-r--r-- | api/current.txt | 29 | ||||
| -rw-r--r-- | api/system-current.txt | 29 | ||||
| -rw-r--r-- | api/test-current.txt | 29 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellIdentityCdma.java | 71 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellIdentityGsm.java | 181 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellIdentityLte.java | 171 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellIdentityWcdma.java | 174 |
7 files changed, 521 insertions, 163 deletions
diff --git a/api/current.txt b/api/current.txt index a0cd51b238f1..671d80c5cba0 100644 --- a/api/current.txt +++ b/api/current.txt @@ -39645,6 +39645,8 @@ package android.telephony { method public int getLatitude(); method public int getLongitude(); method public int getNetworkId(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getSystemId(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityCdma> CREATOR; @@ -39656,8 +39658,13 @@ package android.telephony { method public int getBsic(); method public int getCid(); method public int getLac(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public deprecated int getPsc(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityGsm> CREATOR; @@ -39667,8 +39674,13 @@ package android.telephony { method public int describeContents(); method public int getCi(); method public int getEarfcn(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getPci(); method public int getTac(); method public void writeToParcel(android.os.Parcel, int); @@ -39679,8 +39691,13 @@ package android.telephony { method public int describeContents(); method public int getCid(); method public int getLac(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getPsc(); method public int getUarfcn(); method public void writeToParcel(android.os.Parcel, int); diff --git a/api/system-current.txt b/api/system-current.txt index c9b656bad18f..998dabcdf497 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -43076,6 +43076,8 @@ package android.telephony { method public int getLatitude(); method public int getLongitude(); method public int getNetworkId(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getSystemId(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityCdma> CREATOR; @@ -43087,8 +43089,13 @@ package android.telephony { method public int getBsic(); method public int getCid(); method public int getLac(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public deprecated int getPsc(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityGsm> CREATOR; @@ -43098,8 +43105,13 @@ package android.telephony { method public int describeContents(); method public int getCi(); method public int getEarfcn(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getPci(); method public int getTac(); method public void writeToParcel(android.os.Parcel, int); @@ -43110,8 +43122,13 @@ package android.telephony { method public int describeContents(); method public int getCid(); method public int getLac(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getPsc(); method public int getUarfcn(); method public void writeToParcel(android.os.Parcel, int); diff --git a/api/test-current.txt b/api/test-current.txt index 6936d5618f72..5e61d4dc7278 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -39867,6 +39867,8 @@ package android.telephony { method public int getLatitude(); method public int getLongitude(); method public int getNetworkId(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getSystemId(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityCdma> CREATOR; @@ -39878,8 +39880,13 @@ package android.telephony { method public int getBsic(); method public int getCid(); method public int getLac(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public deprecated int getPsc(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityGsm> CREATOR; @@ -39889,8 +39896,13 @@ package android.telephony { method public int describeContents(); method public int getCi(); method public int getEarfcn(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getPci(); method public int getTac(); method public void writeToParcel(android.os.Parcel, int); @@ -39901,8 +39913,13 @@ package android.telephony { method public int describeContents(); method public int getCid(); method public int getLac(); - method public int getMcc(); - method public int getMnc(); + method public deprecated int getMcc(); + method public java.lang.String getMccStr(); + method public deprecated int getMnc(); + method public java.lang.String getMncStr(); + method public java.lang.String getMobileNetworkOperator(); + method public java.lang.CharSequence getOperatorAlphaLong(); + method public java.lang.CharSequence getOperatorAlphaShort(); method public int getPsc(); method public int getUarfcn(); method public void writeToParcel(android.os.Parcel, int); diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java index b39b4c76ff04..ddc938e64841 100644 --- a/telephony/java/android/telephony/CellIdentityCdma.java +++ b/telephony/java/android/telephony/CellIdentityCdma.java @@ -19,6 +19,7 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import android.text.TextUtils; import java.util.Objects; @@ -50,6 +51,10 @@ public final class CellIdentityCdma implements Parcelable { * to +90 degrees). */ private final int mLatitude; + // long alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaLong; + // short alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaShort; /** * @hide @@ -60,6 +65,8 @@ public final class CellIdentityCdma implements Parcelable { mBasestationId = Integer.MAX_VALUE; mLongitude = Integer.MAX_VALUE; mLatitude = Integer.MAX_VALUE; + mAlphaLong = null; + mAlphaShort = null; } /** @@ -75,19 +82,37 @@ public final class CellIdentityCdma implements Parcelable { * @hide */ public CellIdentityCdma (int nid, int sid, int bid, int lon, int lat) { + this(nid, sid, bid, lon, lat, null, null); + } + + /** + * public constructor + * @param nid Network Id 0..65535 + * @param sid CDMA System Id 0..32767 + * @param bid Base Station Id 0..65535 + * @param lon Longitude is a decimal number ranges from -2592000 + * to 2592000 + * @param lat Latitude is a decimal number ranges from -1296000 + * to 1296000 + * @param alphal long alpha Operator Name String or Enhanced Operator Name String + * @param alphas short alpha Operator Name String or Enhanced Operator Name String + * + * @hide + */ + public CellIdentityCdma (int nid, int sid, int bid, int lon, int lat, String alphal, + String alphas) { mNetworkId = nid; mSystemId = sid; mBasestationId = bid; mLongitude = lon; mLatitude = lat; + mAlphaLong = alphal; + mAlphaShort = alphas; } private CellIdentityCdma(CellIdentityCdma cid) { - mNetworkId = cid.mNetworkId; - mSystemId = cid.mSystemId; - mBasestationId = cid.mBasestationId; - mLongitude = cid.mLongitude; - mLatitude = cid.mLatitude; + this(cid.mNetworkId, cid.mSystemId, cid.mBasestationId, cid.mLongitude, cid.mLatitude, + cid.mAlphaLong, cid.mAlphaShort); } CellIdentityCdma copy() { @@ -137,9 +162,26 @@ public final class CellIdentityCdma implements Parcelable { return mLatitude; } + /** + * @return The long alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaLong() { + return mAlphaLong; + } + + /** + * @return The short alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaShort() { + return mAlphaShort; + } + @Override public int hashCode() { - return Objects.hash(mNetworkId, mSystemId, mBasestationId, mLatitude, mLongitude); + return Objects.hash(mNetworkId, mSystemId, mBasestationId, mLatitude, mLongitude, + mAlphaLong, mAlphaShort); } @Override @@ -153,11 +195,14 @@ public final class CellIdentityCdma implements Parcelable { } CellIdentityCdma o = (CellIdentityCdma) other; + return mNetworkId == o.mNetworkId && mSystemId == o.mSystemId && mBasestationId == o.mBasestationId && mLatitude == o.mLatitude && - mLongitude == o.mLongitude; + mLongitude == o.mLongitude && + TextUtils.equals(mAlphaLong, o.mAlphaLong) && + TextUtils.equals(mAlphaShort, o.mAlphaShort); } @Override @@ -168,6 +213,8 @@ public final class CellIdentityCdma implements Parcelable { sb.append(" mBasestationId="); sb.append(mBasestationId); sb.append(" mLongitude="); sb.append(mLongitude); sb.append(" mLatitude="); sb.append(mLatitude); + sb.append(" mAlphaLong="); sb.append(mAlphaLong); + sb.append(" mAlphaShort="); sb.append(mAlphaShort); sb.append("}"); return sb.toString(); @@ -188,15 +235,15 @@ public final class CellIdentityCdma implements Parcelable { dest.writeInt(mBasestationId); dest.writeInt(mLongitude); dest.writeInt(mLatitude); + dest.writeString(mAlphaLong); + dest.writeString(mAlphaShort); } /** Construct from Parcel, type has already been processed */ private CellIdentityCdma(Parcel in) { - mNetworkId = in.readInt(); - mSystemId = in.readInt(); - mBasestationId = in.readInt(); - mLongitude = in.readInt(); - mLatitude = in.readInt(); + this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readInt(), + in.readString(), in.readString()); + if (DBG) log("CellIdentityCdma(Parcel): " + toString()); } diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index ec008e285bb2..6276626afae2 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -19,6 +19,7 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import android.text.TextUtils; import java.util.Objects; @@ -30,10 +31,6 @@ public final class CellIdentityGsm implements Parcelable { private static final String LOG_TAG = "CellIdentityGsm"; 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; // 16-bit GSM Cell Identity described in TS 27.007, 0..65535 @@ -42,17 +39,27 @@ public final class CellIdentityGsm implements Parcelable { private final int mArfcn; // 6-bit Base Station Identity Code private final int mBsic; + // 3-digit Mobile Country Code in string format + private final String mMccStr; + // 2 or 3-digit Mobile Network Code in string format + private final String mMncStr; + // long alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaLong; + // short alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaShort; /** * @hide */ public CellIdentityGsm() { - mMcc = Integer.MAX_VALUE; - mMnc = Integer.MAX_VALUE; mLac = Integer.MAX_VALUE; mCid = Integer.MAX_VALUE; mArfcn = Integer.MAX_VALUE; mBsic = Integer.MAX_VALUE; + mMccStr = null; + mMncStr = null; + mAlphaLong = null; + mAlphaShort = null; } /** * public constructor @@ -64,7 +71,8 @@ public final class CellIdentityGsm implements Parcelable { * @hide */ public CellIdentityGsm (int mcc, int mnc, int lac, int cid) { - this(mcc, mnc, lac, cid, Integer.MAX_VALUE, Integer.MAX_VALUE); + this(lac, cid, Integer.MAX_VALUE, Integer.MAX_VALUE, + String.valueOf(mcc), String.valueOf(mnc), null, null); } /** @@ -79,39 +87,81 @@ public final class CellIdentityGsm implements Parcelable { * @hide */ public CellIdentityGsm (int mcc, int mnc, int lac, int cid, int arfcn, int bsic) { - mMcc = mcc; - mMnc = mnc; + this(lac, cid, arfcn, bsic, String.valueOf(mcc), String.valueOf(mnc), null, null); + } + + /** + * public constructor + * @param lac 16-bit Location Area Code, 0..65535 + * @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity + * @param arfcn 16-bit GSM Absolute RF Channel Number + * @param bsic 6-bit Base Station Identity Code + * @param mccStr 3-digit Mobile Country Code in string format + * @param mncStr 2 or 3-digit Mobile Network Code in string format + * @param alphal long alpha Operator Name String or Enhanced Operator Name String + * @param alphas short alpha Operator Name String or Enhanced Operator Name String + * + * @throws IllegalArgumentException if the input MCC is not a 3-digit code or the input MNC is + * not a 2 or 3-digit code. + * + * @hide + */ + public CellIdentityGsm (int lac, int cid, int arfcn, int bsic, String mccStr, + String mncStr, String alphal, String alphas) { mLac = lac; mCid = cid; mArfcn = arfcn; - mBsic = bsic; + // In RIL BSIC is a UINT8, so 0xFF is the 'INVALID' designator + // for inbound parcels + mBsic = (bsic == 0xFF) ? Integer.MAX_VALUE : bsic; + + if (mccStr == null || mccStr.matches("^[0-9]{3}$")) { + mMccStr = mccStr; + } else if (mccStr.isEmpty()) { + // If the mccStr parsed from Parcel is empty, set it as null. + mMccStr = null; + } else { + throw new IllegalArgumentException("invalid MCC format"); + } + + if (mncStr == null || mncStr.matches("^[0-9]{2,3}$")) { + mMncStr = mncStr; + } else if (mncStr.isEmpty()) { + // If the mncStr parsed from Parcel is empty, set it as null. + mMncStr = null; + } else { + throw new IllegalArgumentException("invalid MNC format"); + } + + mAlphaLong = alphal; + mAlphaShort = alphas; } private CellIdentityGsm(CellIdentityGsm cid) { - mMcc = cid.mMcc; - mMnc = cid.mMnc; - mLac = cid.mLac; - mCid = cid.mCid; - mArfcn = cid.mArfcn; - mBsic = cid.mBsic; + this(cid.mLac, cid.mCid, cid.mArfcn, cid.mBsic, cid.mMccStr, + cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort); } CellIdentityGsm copy() { - return new CellIdentityGsm(this); + return new CellIdentityGsm(this); } /** * @return 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown + * @deprecated Use {@link #getMccStr} instead. */ + @Deprecated public int getMcc() { - return mMcc; + return (mMccStr != null) ? Integer.valueOf(mMccStr) : Integer.MAX_VALUE; } /** * @return 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown + * @deprecated Use {@link #getMncStr} instead. */ + @Deprecated public int getMnc() { - return mMnc; + return (mMncStr != null) ? Integer.valueOf(mMncStr) : Integer.MAX_VALUE; } /** @@ -144,6 +194,43 @@ public final class CellIdentityGsm implements Parcelable { return mBsic; } + /** + * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown + */ + public String getMobileNetworkOperator() { + return (mMncStr == null || mMncStr == null) ? null : mMccStr + mMncStr; + } + + /** + * @return Mobile Country Code in string format, null if unknown + */ + public String getMccStr() { + return mMccStr; + } + + /** + * @return Mobile Network Code in string format, null if unknown + */ + public String getMncStr() { + return mMncStr; + } + + /** + * @return The long alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaLong() { + return mAlphaLong; + } + + /** + * @return The short alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaShort() { + return mAlphaShort; + } + /** * @return Integer.MAX_VALUE, undefined for GSM @@ -155,7 +242,7 @@ public final class CellIdentityGsm implements Parcelable { @Override public int hashCode() { - return Objects.hash(mMcc, mMnc, mLac, mCid); + return Objects.hash(mMccStr, mMncStr, mLac, mCid, mAlphaLong, mAlphaShort); } @Override @@ -169,23 +256,27 @@ public final class CellIdentityGsm implements Parcelable { } CellIdentityGsm o = (CellIdentityGsm) other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mLac == o.mLac && + return mLac == o.mLac && mCid == o.mCid && mArfcn == o.mArfcn && - mBsic == o.mBsic; + mBsic == o.mBsic && + TextUtils.equals(mMccStr, o.mMccStr) && + TextUtils.equals(mMncStr, o.mMncStr) && + TextUtils.equals(mAlphaLong, o.mAlphaLong) && + TextUtils.equals(mAlphaShort, o.mAlphaShort); } @Override public String toString() { 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(" mArfcn=").append(mArfcn); sb.append(" mBsic=").append("0x").append(Integer.toHexString(mBsic)); + sb.append(" mMcc=").append(mMccStr); + sb.append(" mMnc=").append(mMncStr); + sb.append(" mAlphaLong=").append(mAlphaLong); + sb.append(" mAlphaShort=").append(mAlphaShort); sb.append("}"); return sb.toString(); @@ -201,26 +292,20 @@ public final class CellIdentityGsm implements Parcelable { @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(mArfcn); dest.writeInt(mBsic); + dest.writeString(mMccStr); + dest.writeString(mMncStr); + dest.writeString(mAlphaLong); + dest.writeString(mAlphaShort); } /** Construct from Parcel, type has already been processed */ private CellIdentityGsm(Parcel in) { - mMcc = in.readInt(); - mMnc = in.readInt(); - mLac = in.readInt(); - mCid = in.readInt(); - mArfcn = in.readInt(); - int bsic = in.readInt(); - // In RIL BSIC is a UINT8, so 0xFF is the 'INVALID' designator - // for inbound parcels - if (bsic == 0xFF) bsic = Integer.MAX_VALUE; - mBsic = bsic; + this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString(), + in.readString(), in.readString(), in.readString()); if (DBG) log("CellIdentityGsm(Parcel): " + toString()); } @@ -229,16 +314,16 @@ public final class CellIdentityGsm implements Parcelable { @SuppressWarnings("hiding") public static final Creator<CellIdentityGsm> CREATOR = new Creator<CellIdentityGsm>() { - @Override - public CellIdentityGsm createFromParcel(Parcel in) { - return new CellIdentityGsm(in); - } + @Override + public CellIdentityGsm createFromParcel(Parcel in) { + return new CellIdentityGsm(in); + } - @Override - public CellIdentityGsm[] newArray(int size) { - return new CellIdentityGsm[size]; - } - }; + @Override + public CellIdentityGsm[] newArray(int size) { + return new CellIdentityGsm[size]; + } + }; /** * log @@ -246,4 +331,4 @@ public final class CellIdentityGsm implements Parcelable { private static void log(String s) { Rlog.w(LOG_TAG, s); } -} +}
\ No newline at end of file diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index ce7438354a50..74d2966b25bc 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -19,6 +19,7 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import android.text.TextUtils; import java.util.Objects; @@ -30,10 +31,6 @@ public final class CellIdentityLte implements Parcelable { private static final String LOG_TAG = "CellIdentityLte"; 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; // 28-bit cell identity private final int mCi; // physical cell id 0..503 @@ -42,17 +39,27 @@ public final class CellIdentityLte implements Parcelable { private final int mTac; // 18-bit Absolute RF Channel Number private final int mEarfcn; + // 3-digit Mobile Country Code in string format + private final String mMccStr; + // 2 or 3-digit Mobile Network Code in string format + private final String mMncStr; + // long alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaLong; + // short alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaShort; /** * @hide */ public CellIdentityLte() { - mMcc = Integer.MAX_VALUE; - mMnc = Integer.MAX_VALUE; mCi = Integer.MAX_VALUE; mPci = Integer.MAX_VALUE; mTac = Integer.MAX_VALUE; mEarfcn = Integer.MAX_VALUE; + mMccStr = null; + mMncStr = null; + mAlphaLong = null; + mAlphaShort = null; } /** @@ -66,7 +73,7 @@ public final class CellIdentityLte implements Parcelable { * @hide */ public CellIdentityLte (int mcc, int mnc, int ci, int pci, int tac) { - this(mcc, mnc, ci, pci, tac, Integer.MAX_VALUE); + this(ci, pci, tac, Integer.MAX_VALUE, String.valueOf(mcc), String.valueOf(mnc), null, null); } /** @@ -81,21 +88,57 @@ public final class CellIdentityLte implements Parcelable { * @hide */ public CellIdentityLte (int mcc, int mnc, int ci, int pci, int tac, int earfcn) { - mMcc = mcc; - mMnc = mnc; + this(ci, pci, tac, earfcn, String.valueOf(mcc), String.valueOf(mnc), null, null); + } + + /** + * + * @param ci 28-bit Cell Identity + * @param pci Physical Cell Id 0..503 + * @param tac 16-bit Tracking Area Code + * @param earfcn 18-bit LTE Absolute RF Channel Number + * @param mccStr 3-digit Mobile Country Code in string format + * @param mncStr 2 or 3-digit Mobile Network Code in string format + * @param alphal long alpha Operator Name String or Enhanced Operator Name String + * @param alphas short alpha Operator Name String or Enhanced Operator Name String + * + * @throws IllegalArgumentException if the input MCC is not a 3-digit code or the input MNC is + * not a 2 or 3-digit code. + * + * @hide + */ + public CellIdentityLte (int ci, int pci, int tac, int earfcn, String mccStr, + String mncStr, String alphal, String alphas) { mCi = ci; mPci = pci; mTac = tac; mEarfcn = earfcn; + + if (mccStr == null || mccStr.matches("^[0-9]{3}$")) { + mMccStr = mccStr; + } else if (mccStr.isEmpty()) { + // If the mccStr parsed from Parcel is empty, set it as null. + mMccStr = null; + } else { + throw new IllegalArgumentException("invalid MCC format"); + } + + if (mncStr == null || mncStr.matches("^[0-9]{2,3}$")) { + mMncStr = mncStr; + } else if (mncStr.isEmpty()) { + // If the mncStr parsed from Parcel is empty, set it as null. + mMncStr = null; + } else { + throw new IllegalArgumentException("invalid MNC format"); + } + + mAlphaLong = alphal; + mAlphaShort = alphas; } private CellIdentityLte(CellIdentityLte cid) { - mMcc = cid.mMcc; - mMnc = cid.mMnc; - mCi = cid.mCi; - mPci = cid.mPci; - mTac = cid.mTac; - mEarfcn = cid.mEarfcn; + this(cid.mCi, cid.mPci, cid.mTac, cid.mEarfcn, cid.mMccStr, + cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort); } CellIdentityLte copy() { @@ -104,16 +147,20 @@ public final class CellIdentityLte implements Parcelable { /** * @return 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown + * @deprecated Use {@link #getMccStr} instead. */ + @Deprecated public int getMcc() { - return mMcc; + return (mMccStr != null) ? Integer.valueOf(mMccStr) : Integer.MAX_VALUE; } /** * @return 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown + * @deprecated Use {@link #getMncStr} instead. */ + @Deprecated public int getMnc() { - return mMnc; + return (mMncStr != null) ? Integer.valueOf(mMncStr) : Integer.MAX_VALUE; } /** @@ -144,9 +191,46 @@ public final class CellIdentityLte implements Parcelable { return mEarfcn; } + /** + * @return Mobile Country Code in string format, null if unknown + */ + public String getMccStr() { + return mMccStr; + } + + /** + * @return Mobile Network Code in string format, null if unknown + */ + public String getMncStr() { + return mMncStr; + } + + /** + * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown + */ + public String getMobileNetworkOperator() { + return (mMncStr == null || mMncStr == null) ? null : mMccStr + mMncStr; + } + + /** + * @return The long alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaLong() { + return mAlphaLong; + } + + /** + * @return The short alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaShort() { + return mAlphaShort; + } + @Override public int hashCode() { - return Objects.hash(mMcc, mMnc, mCi, mPci, mTac); + return Objects.hash(mMccStr, mMncStr, mCi, mPci, mTac, mAlphaLong, mAlphaShort); } @Override @@ -160,23 +244,27 @@ public final class CellIdentityLte implements Parcelable { } CellIdentityLte o = (CellIdentityLte) other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mCi == o.mCi && + return mCi == o.mCi && mPci == o.mPci && mTac == o.mTac && - mEarfcn == o.mEarfcn; + mEarfcn == o.mEarfcn && + TextUtils.equals(mMccStr, o.mMccStr) && + TextUtils.equals(mMncStr, o.mMncStr) && + TextUtils.equals(mAlphaLong, o.mAlphaLong) && + TextUtils.equals(mAlphaShort, o.mAlphaShort); } @Override public String toString() { StringBuilder sb = new StringBuilder("CellIdentityLte:{"); - sb.append(" mMcc="); sb.append(mMcc); - sb.append(" mMnc="); sb.append(mMnc); sb.append(" mCi="); sb.append(mCi); sb.append(" mPci="); sb.append(mPci); sb.append(" mTac="); sb.append(mTac); sb.append(" mEarfcn="); sb.append(mEarfcn); + sb.append(" mMcc="); sb.append(mMccStr); + sb.append(" mMnc="); sb.append(mMncStr); + sb.append(" mAlphaLong="); sb.append(mAlphaLong); + sb.append(" mAlphaShort="); sb.append(mAlphaShort); sb.append("}"); return sb.toString(); @@ -192,22 +280,21 @@ public final class CellIdentityLte implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { if (DBG) log("writeToParcel(Parcel, int): " + toString()); - dest.writeInt(mMcc); - dest.writeInt(mMnc); dest.writeInt(mCi); dest.writeInt(mPci); dest.writeInt(mTac); dest.writeInt(mEarfcn); + dest.writeString(mMccStr); + dest.writeString(mMncStr); + dest.writeString(mAlphaLong); + dest.writeString(mAlphaShort); } /** Construct from Parcel, type has already been processed */ private CellIdentityLte(Parcel in) { - mMcc = in.readInt(); - mMnc = in.readInt(); - mCi = in.readInt(); - mPci = in.readInt(); - mTac = in.readInt(); - mEarfcn = in.readInt(); + this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString(), + in.readString(), in.readString(), in.readString()); + if (DBG) log("CellIdentityLte(Parcel): " + toString()); } @@ -215,16 +302,16 @@ public final class CellIdentityLte implements Parcelable { @SuppressWarnings("hiding") public static final Creator<CellIdentityLte> CREATOR = new Creator<CellIdentityLte>() { - @Override - public CellIdentityLte createFromParcel(Parcel in) { - return new CellIdentityLte(in); - } + @Override + public CellIdentityLte createFromParcel(Parcel in) { + return new CellIdentityLte(in); + } - @Override - public CellIdentityLte[] newArray(int size) { - return new CellIdentityLte[size]; - } - }; + @Override + public CellIdentityLte[] newArray(int size) { + return new CellIdentityLte[size]; + } + }; /** * log @@ -232,4 +319,4 @@ public final class CellIdentityLte implements Parcelable { private static void log(String s) { Rlog.w(LOG_TAG, s); } -} +}
\ No newline at end of file diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index 0d13efd279c9..51b11aa82b9a 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -19,6 +19,7 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import android.text.TextUtils; import java.util.Objects; @@ -30,10 +31,6 @@ 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 @@ -42,17 +39,27 @@ public final class CellIdentityWcdma implements Parcelable { private final int mPsc; // 16-bit UMTS Absolute RF Channel Number private final int mUarfcn; + // 3-digit Mobile Country Code in string format + private final String mMccStr; + // 2 or 3-digit Mobile Network Code in string format + private final String mMncStr; + // long alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaLong; + // short alpha Operator Name String or Enhanced Operator Name String + private final String mAlphaShort; /** * @hide */ public CellIdentityWcdma() { - mMcc = Integer.MAX_VALUE; - mMnc = Integer.MAX_VALUE; mLac = Integer.MAX_VALUE; mCid = Integer.MAX_VALUE; mPsc = Integer.MAX_VALUE; mUarfcn = Integer.MAX_VALUE; + mMccStr = null; + mMncStr = null; + mAlphaLong = null; + mAlphaShort = null; } /** * public constructor @@ -65,7 +72,8 @@ public final class CellIdentityWcdma implements Parcelable { * @hide */ public CellIdentityWcdma (int mcc, int mnc, int lac, int cid, int psc) { - this(mcc, mnc, lac, cid, psc, Integer.MAX_VALUE); + this(lac, cid, psc, Integer.MAX_VALUE, String.valueOf(mcc), String.valueOf(mnc), + null, null); } /** @@ -80,39 +88,79 @@ public final class CellIdentityWcdma implements Parcelable { * @hide */ public CellIdentityWcdma (int mcc, int mnc, int lac, int cid, int psc, int uarfcn) { - mMcc = mcc; - mMnc = mnc; + this(lac, cid, psc, uarfcn, String.valueOf(mcc), String.valueOf(mnc), null, null); + } + + /** + * public constructor + * @param lac 16-bit Location Area Code, 0..65535 + * @param cid 28-bit UMTS Cell Identity + * @param psc 9-bit UMTS Primary Scrambling Code + * @param uarfcn 16-bit UMTS Absolute RF Channel Number + * @param mccStr 3-digit Mobile Country Code in string format + * @param mncStr 2 or 3-digit Mobile Network Code in string format + * @param alphal long alpha Operator Name String or Enhanced Operator Name String + * @param alphas short alpha Operator Name String or Enhanced Operator Name String + * + * @throws IllegalArgumentException if the input MCC is not a 3-digit code or the input MNC is + * not a 2 or 3-digit code. + * + * @hide + */ + public CellIdentityWcdma (int lac, int cid, int psc, int uarfcn, + String mccStr, String mncStr, String alphal, String alphas) { mLac = lac; mCid = cid; mPsc = psc; mUarfcn = uarfcn; + + if (mccStr == null || mccStr.matches("^[0-9]{3}$")) { + mMccStr = mccStr; + } else if (mccStr.isEmpty()) { + // If the mccStr parsed from Parcel is empty, set it as null. + mMccStr = null; + } else { + throw new IllegalArgumentException("invalid MCC format"); + } + + if (mncStr == null || mncStr.matches("^[0-9]{2,3}$")) { + mMncStr = mncStr; + } else if (mncStr.isEmpty()) { + // If the mncStr parsed from Parcel is empty, set it as null. + mMncStr = null; + } else { + throw new IllegalArgumentException("invalid MNC format"); + } + + mAlphaLong = alphal; + mAlphaShort = alphas; } private CellIdentityWcdma(CellIdentityWcdma cid) { - mMcc = cid.mMcc; - mMnc = cid.mMnc; - mLac = cid.mLac; - mCid = cid.mCid; - mPsc = cid.mPsc; - mUarfcn = cid.mUarfcn; + this(cid.mLac, cid.mCid, cid.mPsc, cid.mUarfcn, cid.mMccStr, + cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort); } CellIdentityWcdma copy() { - return new CellIdentityWcdma(this); + return new CellIdentityWcdma(this); } /** * @return 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown + * @deprecated Use {@link #getMccStr} instead. */ + @Deprecated public int getMcc() { - return mMcc; + return (mMccStr != null) ? Integer.valueOf(mMccStr) : Integer.MAX_VALUE; } /** * @return 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown + * @deprecated Use {@link #getMncStr} instead. */ + @Deprecated public int getMnc() { - return mMnc; + return (mMncStr != null) ? Integer.valueOf(mMncStr) : Integer.MAX_VALUE; } /** @@ -138,9 +186,46 @@ public final class CellIdentityWcdma implements Parcelable { return mPsc; } + /** + * @return Mobile Country Code in string version, null if unknown + */ + public String getMccStr() { + return mMccStr; + } + + /** + * @return Mobile Network Code in string version, null if unknown + */ + public String getMncStr() { + return mMncStr; + } + + /** + * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown + */ + public String getMobileNetworkOperator() { + return (mMncStr == null || mMncStr == null) ? null : mMccStr + mMncStr; + } + + /** + * @return The long alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaLong() { + return mAlphaLong; + } + + /** + * @return The short alpha tag associated with the current scan result (may be the operator + * name string or extended operator name string). May be null if unknown. + */ + public CharSequence getOperatorAlphaShort() { + return mAlphaShort; + } + @Override public int hashCode() { - return Objects.hash(mMcc, mMnc, mLac, mCid, mPsc); + return Objects.hash(mMccStr, mMncStr, mLac, mCid, mPsc, mAlphaLong, mAlphaShort); } /** @@ -161,23 +246,27 @@ public final class CellIdentityWcdma implements Parcelable { } CellIdentityWcdma o = (CellIdentityWcdma) other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mLac == o.mLac && + return mLac == o.mLac && mCid == o.mCid && mPsc == o.mPsc && - mUarfcn == o.mUarfcn; + mUarfcn == o.mUarfcn && + TextUtils.equals(mMccStr, o.mMccStr) && + TextUtils.equals(mMncStr, o.mMncStr) && + TextUtils.equals(mAlphaLong, o.mAlphaLong) && + TextUtils.equals(mAlphaShort, o.mAlphaShort); } @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(" mUarfcn=").append(mUarfcn); + sb.append(" mMcc=").append(mMccStr); + sb.append(" mMnc=").append(mMncStr); + sb.append(" mAlphaLong=").append(mAlphaLong); + sb.append(" mAlphaShort=").append(mAlphaShort); sb.append("}"); return sb.toString(); @@ -193,22 +282,21 @@ public final class CellIdentityWcdma implements Parcelable { @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); dest.writeInt(mUarfcn); + dest.writeString(mMccStr); + dest.writeString(mMncStr); + dest.writeString(mAlphaLong); + dest.writeString(mAlphaShort); } /** 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(); - mUarfcn = in.readInt(); + this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString(), + in.readString(), in.readString(), in.readString()); + if (DBG) log("CellIdentityWcdma(Parcel): " + toString()); } @@ -216,16 +304,16 @@ public final class CellIdentityWcdma implements Parcelable { @SuppressWarnings("hiding") public static final Creator<CellIdentityWcdma> CREATOR = new Creator<CellIdentityWcdma>() { - @Override - public CellIdentityWcdma createFromParcel(Parcel in) { - return new CellIdentityWcdma(in); - } + @Override + public CellIdentityWcdma createFromParcel(Parcel in) { + return new CellIdentityWcdma(in); + } - @Override - public CellIdentityWcdma[] newArray(int size) { - return new CellIdentityWcdma[size]; - } - }; + @Override + public CellIdentityWcdma[] newArray(int size) { + return new CellIdentityWcdma[size]; + } + }; /** * log @@ -233,4 +321,4 @@ public final class CellIdentityWcdma implements Parcelable { private static void log(String s) { Rlog.w(LOG_TAG, s); } -} +}
\ No newline at end of file |