Loading api/current.txt +19 −7 Original line number Diff line number Diff line Loading @@ -40093,8 +40093,13 @@ package android.telephony { field public static final java.lang.String KEY_WORLD_PHONE_BOOL = "world_phone_bool"; } public final class CellIdentityCdma implements android.os.Parcelable { public abstract class CellIdentity implements android.os.Parcelable { method public int describeContents(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentity> CREATOR; } public final class CellIdentityCdma extends android.telephony.CellIdentity { method public int getBasestationId(); method public int getLatitude(); method public int getLongitude(); Loading @@ -40106,8 +40111,7 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityCdma> CREATOR; } public final class CellIdentityGsm implements android.os.Parcelable { method public int describeContents(); public final class CellIdentityGsm extends android.telephony.CellIdentity { method public int getArfcn(); method public int getBsic(); method public int getCid(); Loading @@ -40124,8 +40128,7 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityGsm> CREATOR; } public final class CellIdentityLte implements android.os.Parcelable { method public int describeContents(); public final class CellIdentityLte extends android.telephony.CellIdentity { method public int getCi(); method public int getEarfcn(); method public deprecated int getMcc(); Loading @@ -40141,8 +40144,17 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityLte> CREATOR; } public final class CellIdentityWcdma implements android.os.Parcelable { method public int describeContents(); public final class CellIdentityTdscdma extends android.telephony.CellIdentity { method public int getCid(); method public int getCpid(); method public int getLac(); method public java.lang.String getMccStr(); method public java.lang.String getMncStr(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityTdscdma> CREATOR; } public final class CellIdentityWcdma extends android.telephony.CellIdentity { method public int getCid(); method public int getLac(); method public deprecated int getMcc(); telephony/java/android/telephony/CellIdentity.aidl 0 → 100644 +20 −0 Original line number Diff line number Diff line /* * Copyright 2017 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. */ /** @hide */ package android.telephony; parcelable CellIdentity; telephony/java/android/telephony/CellIdentity.java 0 → 100644 +173 −0 Original line number Diff line number Diff line /* * Copyright 2017 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.annotation.CallSuper; import android.annotation.IntDef; import android.os.Parcel; import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * CellIdentity represents the identity of a unique cell. This is the base class for * CellIdentityXxx which represents cell identity for specific network access technology. */ public abstract class CellIdentity implements Parcelable { /** * Cell identity type * @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = "TYPE_", value = {TYPE_GSM, TYPE_CDMA, TYPE_LTE, TYPE_WCDMA, TYPE_TDSCDMA}) public @interface Type {} /** * Unknown cell identity type * @hide */ public static final int TYPE_UNKNOWN = 0; /** * GSM cell identity type * @hide */ public static final int TYPE_GSM = 1; /** * CDMA cell identity type * @hide */ public static final int TYPE_CDMA = 2; /** * LTE cell identity type * @hide */ public static final int TYPE_LTE = 3; /** * WCDMA cell identity type * @hide */ public static final int TYPE_WCDMA = 4; /** * TDS-CDMA cell identity type * @hide */ public static final int TYPE_TDSCDMA = 5; // Log tag /** @hide */ protected final String mTag; // Cell identity type /** @hide */ protected final int mType; // 3-digit Mobile Country Code in string format. Null for CDMA cell identity. /** @hide */ protected final String mMccStr; // 2 or 3-digit Mobile Network Code in string format. Null for CDMA cell identity. /** @hide */ protected final String mMncStr; /** @hide */ protected CellIdentity(String tag, int type, String mcc, String mnc) { mTag = tag; mType = type; // Only allow INT_MAX if unknown string mcc/mnc if (mcc == null || mcc.matches("^[0-9]{3}$")) { mMccStr = mcc; } else if (mcc.isEmpty() || mcc.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mccStr is empty or unknown, set it as null. mMccStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MCC format // after the bug got fixed. mMccStr = null; log("invalid MCC format: " + mcc); } if (mnc == null || mnc.matches("^[0-9]{2,3}$")) { mMncStr = mnc; } else if (mnc.isEmpty() || mnc.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mncStr is empty or unknown, set it as null. mMncStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MNC format // after the bug got fixed. mMncStr = null; log("invalid MNC format: " + mnc); } } /** Implement the Parcelable interface */ @Override public int describeContents() { return 0; } /** * @hide * @return The type of the cell identity */ public @Type int getType() { return mType; } /** * Used by child classes for parceling. * * @hide */ @CallSuper public void writeToParcel(Parcel dest, int type) { dest.writeInt(type); dest.writeString(mMccStr); dest.writeString(mMncStr); } /** * Construct from Parcel * @hide */ protected CellIdentity(String tag, int type, Parcel source) { this(tag, type, source.readString(), source.readString()); } /** Implement the Parcelable interface */ public static final Creator<CellIdentity> CREATOR = new Creator<CellIdentity>() { @Override public CellIdentity createFromParcel(Parcel in) { int type = in.readInt(); switch (type) { case TYPE_GSM: return CellIdentityGsm.createFromParcelBody(in); case TYPE_WCDMA: return CellIdentityWcdma.createFromParcelBody(in); case TYPE_CDMA: return CellIdentityCdma.createFromParcelBody(in); case TYPE_LTE: return CellIdentityLte.createFromParcelBody(in); case TYPE_TDSCDMA: return CellIdentityTdscdma.createFromParcelBody(in); default: throw new IllegalArgumentException("Bad Cell identity Parcel"); } } @Override public CellIdentity[] newArray(int size) { return new CellIdentity[size]; } }; /** @hide */ protected void log(String s) { Rlog.w(mTag, s); } } No newline at end of file telephony/java/android/telephony/CellIdentityCdma.java +38 −41 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; import android.text.TextUtils; import java.util.Objects; Loading @@ -26,9 +24,8 @@ import java.util.Objects; /** * CellIdentity is to represent a unique CDMA cell */ public final class CellIdentityCdma implements Parcelable { private static final String LOG_TAG = "CellSignalStrengthCdma"; public final class CellIdentityCdma extends CellIdentity { private static final String TAG = CellIdentityCdma.class.getSimpleName(); private static final boolean DBG = false; // Network Id 0..65535 Loading Loading @@ -60,6 +57,7 @@ public final class CellIdentityCdma implements Parcelable { * @hide */ public CellIdentityCdma() { super(TAG, TYPE_CDMA, null, null); mNetworkId = Integer.MAX_VALUE; mSystemId = Integer.MAX_VALUE; mBasestationId = Integer.MAX_VALUE; Loading Loading @@ -101,6 +99,7 @@ public final class CellIdentityCdma implements Parcelable { */ public CellIdentityCdma(int nid, int sid, int bid, int lon, int lat, String alphal, String alphas) { super(TAG, TYPE_CDMA, null, null); mNetworkId = nid; mSystemId = sid; mBasestationId = bid; Loading Loading @@ -196,40 +195,33 @@ 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 && TextUtils.equals(mAlphaLong, o.mAlphaLong) && TextUtils.equals(mAlphaShort, o.mAlphaShort); return mNetworkId == o.mNetworkId && mSystemId == o.mSystemId && mBasestationId == o.mBasestationId && mLatitude == o.mLatitude && mLongitude == o.mLongitude && TextUtils.equals(mAlphaLong, o.mAlphaLong) && TextUtils.equals(mAlphaShort, o.mAlphaShort); } @Override public String toString() { StringBuilder sb = new StringBuilder("CellIdentityCdma:{"); sb.append(" mNetworkId="); sb.append(mNetworkId); sb.append(" mSystemId="); sb.append(mSystemId); 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(); } /** Implement the Parcelable interface */ @Override public int describeContents() { return 0; return new StringBuilder(TAG) .append(":{ mNetworkId=").append(mNetworkId) .append(" mSystemId=").append(mSystemId) .append(" mBasestationId=").append(mBasestationId) .append(" mLongitude=").append(mLongitude) .append(" mLatitude=").append(mLatitude) .append(" mAlphaLong=").append(mAlphaLong) .append(" mAlphaShort=").append(mAlphaShort) .append("}").toString(); } /** Implement the Parcelable interface */ @Override public void writeToParcel(Parcel dest, int flags) { if (DBG) log("writeToParcel(Parcel, int): " + toString()); super.writeToParcel(dest, TYPE_CDMA); dest.writeInt(mNetworkId); dest.writeInt(mSystemId); dest.writeInt(mBasestationId); Loading @@ -241,10 +233,16 @@ public final class CellIdentityCdma implements Parcelable { /** Construct from Parcel, type has already been processed */ private CellIdentityCdma(Parcel in) { this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString(), in.readString()); if (DBG) log("CellIdentityCdma(Parcel): " + toString()); super(TAG, TYPE_CDMA, in); mNetworkId = in.readInt(); mSystemId = in.readInt(); mBasestationId = in.readInt(); mLongitude = in.readInt(); mLatitude = in.readInt(); mAlphaLong = in.readString(); mAlphaShort = in.readString(); if (DBG) log(toString()); } /** Implement the Parcelable interface */ Loading @@ -253,7 +251,8 @@ public final class CellIdentityCdma implements Parcelable { new Creator<CellIdentityCdma>() { @Override public CellIdentityCdma createFromParcel(Parcel in) { return new CellIdentityCdma(in); in.readInt(); // skip return createFromParcelBody(in); } @Override Loading @@ -262,10 +261,8 @@ public final class CellIdentityCdma implements Parcelable { } }; /** * log */ private static void log(String s) { Rlog.w(LOG_TAG, s); /** @hide */ protected static CellIdentityCdma createFromParcelBody(Parcel in) { return new CellIdentityCdma(in); } } telephony/java/android/telephony/CellIdentityGsm.java +42 −78 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; import android.text.TextUtils; import java.util.Objects; Loading @@ -26,9 +24,8 @@ import java.util.Objects; /** * CellIdentity to represent a unique GSM cell */ public final class CellIdentityGsm implements Parcelable { private static final String LOG_TAG = "CellIdentityGsm"; public final class CellIdentityGsm extends CellIdentity { private static final String TAG = CellIdentityGsm.class.getSimpleName(); private static final boolean DBG = false; // 16-bit Location Area Code, 0..65535 Loading @@ -39,10 +36,6 @@ 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 Loading @@ -52,12 +45,11 @@ public final class CellIdentityGsm implements Parcelable { * @hide */ public CellIdentityGsm() { super(TAG, TYPE_GSM, null, null); mLac = Integer.MAX_VALUE; mCid = Integer.MAX_VALUE; mArfcn = Integer.MAX_VALUE; mBsic = Integer.MAX_VALUE; mMccStr = null; mMncStr = null; mAlphaLong = null; mAlphaShort = null; } Loading Loading @@ -105,6 +97,7 @@ public final class CellIdentityGsm implements Parcelable { */ public CellIdentityGsm(int lac, int cid, int arfcn, int bsic, String mccStr, String mncStr, String alphal, String alphas) { super(TAG, TYPE_GSM, mccStr, mncStr); mLac = lac; mCid = cid; mArfcn = arfcn; Loading @@ -112,31 +105,6 @@ public final class CellIdentityGsm implements Parcelable { // for inbound parcels mBsic = (bsic == 0xFF) ? Integer.MAX_VALUE : bsic; // Only allow INT_MAX if unknown string mcc/mnc if (mccStr == null || mccStr.matches("^[0-9]{3}$")) { mMccStr = mccStr; } else if (mccStr.isEmpty() || mccStr.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mccStr is empty or unknown, set it as null. mMccStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MCC format // after the bug got fixed. mMccStr = null; log("invalid MCC format: " + mccStr); } if (mncStr == null || mncStr.matches("^[0-9]{2,3}$")) { mMncStr = mncStr; } else if (mncStr.isEmpty() || mncStr.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mncStr is empty or unknown, set it as null. mMncStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MNC format // after the bug got fixed. mMncStr = null; log("invalid MNC format: " + mncStr); } mAlphaLong = alphal; mAlphaShort = alphas; } Loading Loading @@ -237,6 +205,7 @@ public final class CellIdentityGsm implements Parcelable { /** * @deprecated Primary Scrambling Code is not applicable to GSM. * @return Integer.MAX_VALUE, undefined for GSM */ @Deprecated Loading @@ -260,58 +229,54 @@ public final class CellIdentityGsm implements Parcelable { } CellIdentityGsm o = (CellIdentityGsm) other; return mLac == o.mLac && mCid == o.mCid && mArfcn == o.mArfcn && mBsic == o.mBsic && TextUtils.equals(mMccStr, o.mMccStr) && TextUtils.equals(mMncStr, o.mMncStr) && TextUtils.equals(mAlphaLong, o.mAlphaLong) && TextUtils.equals(mAlphaShort, o.mAlphaShort); return mLac == o.mLac && mCid == o.mCid && mArfcn == o.mArfcn && 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(" 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(); } /** Implement the Parcelable interface */ @Override public int describeContents() { return 0; return new StringBuilder(TAG) .append(":{ mLac=").append(mLac) .append(" mCid=").append(mCid) .append(" mArfcn=").append(mArfcn) .append(" mBsic=").append("0x").append(Integer.toHexString(mBsic)) .append(" mMcc=").append(mMccStr) .append(" mMnc=").append(mMncStr) .append(" mAlphaLong=").append(mAlphaLong) .append(" mAlphaShort=").append(mAlphaShort) .append("}").toString(); } /** Implement the Parcelable interface */ @Override public void writeToParcel(Parcel dest, int flags) { if (DBG) log("writeToParcel(Parcel, int): " + toString()); super.writeToParcel(dest, TYPE_GSM); 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) { this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString(), in.readString(), in.readString(), in.readString()); super(TAG, TYPE_GSM, in); mLac = in.readInt(); mCid = in.readInt(); mArfcn = in.readInt(); mBsic = in.readInt(); mAlphaLong = in.readString(); mAlphaShort = in.readString(); if (DBG) log("CellIdentityGsm(Parcel): " + toString()); if (DBG) log(toString()); } /** Implement the Parcelable interface */ Loading @@ -320,7 +285,8 @@ public final class CellIdentityGsm implements Parcelable { new Creator<CellIdentityGsm>() { @Override public CellIdentityGsm createFromParcel(Parcel in) { return new CellIdentityGsm(in); in.readInt(); // skip return createFromParcelBody(in); } @Override Loading @@ -329,10 +295,8 @@ public final class CellIdentityGsm implements Parcelable { } }; /** * log */ private static void log(String s) { Rlog.w(LOG_TAG, s); /** @hide */ protected static CellIdentityGsm createFromParcelBody(Parcel in) { return new CellIdentityGsm(in); } } Loading
api/current.txt +19 −7 Original line number Diff line number Diff line Loading @@ -40093,8 +40093,13 @@ package android.telephony { field public static final java.lang.String KEY_WORLD_PHONE_BOOL = "world_phone_bool"; } public final class CellIdentityCdma implements android.os.Parcelable { public abstract class CellIdentity implements android.os.Parcelable { method public int describeContents(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentity> CREATOR; } public final class CellIdentityCdma extends android.telephony.CellIdentity { method public int getBasestationId(); method public int getLatitude(); method public int getLongitude(); Loading @@ -40106,8 +40111,7 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityCdma> CREATOR; } public final class CellIdentityGsm implements android.os.Parcelable { method public int describeContents(); public final class CellIdentityGsm extends android.telephony.CellIdentity { method public int getArfcn(); method public int getBsic(); method public int getCid(); Loading @@ -40124,8 +40128,7 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityGsm> CREATOR; } public final class CellIdentityLte implements android.os.Parcelable { method public int describeContents(); public final class CellIdentityLte extends android.telephony.CellIdentity { method public int getCi(); method public int getEarfcn(); method public deprecated int getMcc(); Loading @@ -40141,8 +40144,17 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityLte> CREATOR; } public final class CellIdentityWcdma implements android.os.Parcelable { method public int describeContents(); public final class CellIdentityTdscdma extends android.telephony.CellIdentity { method public int getCid(); method public int getCpid(); method public int getLac(); method public java.lang.String getMccStr(); method public java.lang.String getMncStr(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityTdscdma> CREATOR; } public final class CellIdentityWcdma extends android.telephony.CellIdentity { method public int getCid(); method public int getLac(); method public deprecated int getMcc();
telephony/java/android/telephony/CellIdentity.aidl 0 → 100644 +20 −0 Original line number Diff line number Diff line /* * Copyright 2017 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. */ /** @hide */ package android.telephony; parcelable CellIdentity;
telephony/java/android/telephony/CellIdentity.java 0 → 100644 +173 −0 Original line number Diff line number Diff line /* * Copyright 2017 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.annotation.CallSuper; import android.annotation.IntDef; import android.os.Parcel; import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * CellIdentity represents the identity of a unique cell. This is the base class for * CellIdentityXxx which represents cell identity for specific network access technology. */ public abstract class CellIdentity implements Parcelable { /** * Cell identity type * @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = "TYPE_", value = {TYPE_GSM, TYPE_CDMA, TYPE_LTE, TYPE_WCDMA, TYPE_TDSCDMA}) public @interface Type {} /** * Unknown cell identity type * @hide */ public static final int TYPE_UNKNOWN = 0; /** * GSM cell identity type * @hide */ public static final int TYPE_GSM = 1; /** * CDMA cell identity type * @hide */ public static final int TYPE_CDMA = 2; /** * LTE cell identity type * @hide */ public static final int TYPE_LTE = 3; /** * WCDMA cell identity type * @hide */ public static final int TYPE_WCDMA = 4; /** * TDS-CDMA cell identity type * @hide */ public static final int TYPE_TDSCDMA = 5; // Log tag /** @hide */ protected final String mTag; // Cell identity type /** @hide */ protected final int mType; // 3-digit Mobile Country Code in string format. Null for CDMA cell identity. /** @hide */ protected final String mMccStr; // 2 or 3-digit Mobile Network Code in string format. Null for CDMA cell identity. /** @hide */ protected final String mMncStr; /** @hide */ protected CellIdentity(String tag, int type, String mcc, String mnc) { mTag = tag; mType = type; // Only allow INT_MAX if unknown string mcc/mnc if (mcc == null || mcc.matches("^[0-9]{3}$")) { mMccStr = mcc; } else if (mcc.isEmpty() || mcc.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mccStr is empty or unknown, set it as null. mMccStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MCC format // after the bug got fixed. mMccStr = null; log("invalid MCC format: " + mcc); } if (mnc == null || mnc.matches("^[0-9]{2,3}$")) { mMncStr = mnc; } else if (mnc.isEmpty() || mnc.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mncStr is empty or unknown, set it as null. mMncStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MNC format // after the bug got fixed. mMncStr = null; log("invalid MNC format: " + mnc); } } /** Implement the Parcelable interface */ @Override public int describeContents() { return 0; } /** * @hide * @return The type of the cell identity */ public @Type int getType() { return mType; } /** * Used by child classes for parceling. * * @hide */ @CallSuper public void writeToParcel(Parcel dest, int type) { dest.writeInt(type); dest.writeString(mMccStr); dest.writeString(mMncStr); } /** * Construct from Parcel * @hide */ protected CellIdentity(String tag, int type, Parcel source) { this(tag, type, source.readString(), source.readString()); } /** Implement the Parcelable interface */ public static final Creator<CellIdentity> CREATOR = new Creator<CellIdentity>() { @Override public CellIdentity createFromParcel(Parcel in) { int type = in.readInt(); switch (type) { case TYPE_GSM: return CellIdentityGsm.createFromParcelBody(in); case TYPE_WCDMA: return CellIdentityWcdma.createFromParcelBody(in); case TYPE_CDMA: return CellIdentityCdma.createFromParcelBody(in); case TYPE_LTE: return CellIdentityLte.createFromParcelBody(in); case TYPE_TDSCDMA: return CellIdentityTdscdma.createFromParcelBody(in); default: throw new IllegalArgumentException("Bad Cell identity Parcel"); } } @Override public CellIdentity[] newArray(int size) { return new CellIdentity[size]; } }; /** @hide */ protected void log(String s) { Rlog.w(mTag, s); } } No newline at end of file
telephony/java/android/telephony/CellIdentityCdma.java +38 −41 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; import android.text.TextUtils; import java.util.Objects; Loading @@ -26,9 +24,8 @@ import java.util.Objects; /** * CellIdentity is to represent a unique CDMA cell */ public final class CellIdentityCdma implements Parcelable { private static final String LOG_TAG = "CellSignalStrengthCdma"; public final class CellIdentityCdma extends CellIdentity { private static final String TAG = CellIdentityCdma.class.getSimpleName(); private static final boolean DBG = false; // Network Id 0..65535 Loading Loading @@ -60,6 +57,7 @@ public final class CellIdentityCdma implements Parcelable { * @hide */ public CellIdentityCdma() { super(TAG, TYPE_CDMA, null, null); mNetworkId = Integer.MAX_VALUE; mSystemId = Integer.MAX_VALUE; mBasestationId = Integer.MAX_VALUE; Loading Loading @@ -101,6 +99,7 @@ public final class CellIdentityCdma implements Parcelable { */ public CellIdentityCdma(int nid, int sid, int bid, int lon, int lat, String alphal, String alphas) { super(TAG, TYPE_CDMA, null, null); mNetworkId = nid; mSystemId = sid; mBasestationId = bid; Loading Loading @@ -196,40 +195,33 @@ 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 && TextUtils.equals(mAlphaLong, o.mAlphaLong) && TextUtils.equals(mAlphaShort, o.mAlphaShort); return mNetworkId == o.mNetworkId && mSystemId == o.mSystemId && mBasestationId == o.mBasestationId && mLatitude == o.mLatitude && mLongitude == o.mLongitude && TextUtils.equals(mAlphaLong, o.mAlphaLong) && TextUtils.equals(mAlphaShort, o.mAlphaShort); } @Override public String toString() { StringBuilder sb = new StringBuilder("CellIdentityCdma:{"); sb.append(" mNetworkId="); sb.append(mNetworkId); sb.append(" mSystemId="); sb.append(mSystemId); 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(); } /** Implement the Parcelable interface */ @Override public int describeContents() { return 0; return new StringBuilder(TAG) .append(":{ mNetworkId=").append(mNetworkId) .append(" mSystemId=").append(mSystemId) .append(" mBasestationId=").append(mBasestationId) .append(" mLongitude=").append(mLongitude) .append(" mLatitude=").append(mLatitude) .append(" mAlphaLong=").append(mAlphaLong) .append(" mAlphaShort=").append(mAlphaShort) .append("}").toString(); } /** Implement the Parcelable interface */ @Override public void writeToParcel(Parcel dest, int flags) { if (DBG) log("writeToParcel(Parcel, int): " + toString()); super.writeToParcel(dest, TYPE_CDMA); dest.writeInt(mNetworkId); dest.writeInt(mSystemId); dest.writeInt(mBasestationId); Loading @@ -241,10 +233,16 @@ public final class CellIdentityCdma implements Parcelable { /** Construct from Parcel, type has already been processed */ private CellIdentityCdma(Parcel in) { this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString(), in.readString()); if (DBG) log("CellIdentityCdma(Parcel): " + toString()); super(TAG, TYPE_CDMA, in); mNetworkId = in.readInt(); mSystemId = in.readInt(); mBasestationId = in.readInt(); mLongitude = in.readInt(); mLatitude = in.readInt(); mAlphaLong = in.readString(); mAlphaShort = in.readString(); if (DBG) log(toString()); } /** Implement the Parcelable interface */ Loading @@ -253,7 +251,8 @@ public final class CellIdentityCdma implements Parcelable { new Creator<CellIdentityCdma>() { @Override public CellIdentityCdma createFromParcel(Parcel in) { return new CellIdentityCdma(in); in.readInt(); // skip return createFromParcelBody(in); } @Override Loading @@ -262,10 +261,8 @@ public final class CellIdentityCdma implements Parcelable { } }; /** * log */ private static void log(String s) { Rlog.w(LOG_TAG, s); /** @hide */ protected static CellIdentityCdma createFromParcelBody(Parcel in) { return new CellIdentityCdma(in); } }
telephony/java/android/telephony/CellIdentityGsm.java +42 −78 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; import android.text.TextUtils; import java.util.Objects; Loading @@ -26,9 +24,8 @@ import java.util.Objects; /** * CellIdentity to represent a unique GSM cell */ public final class CellIdentityGsm implements Parcelable { private static final String LOG_TAG = "CellIdentityGsm"; public final class CellIdentityGsm extends CellIdentity { private static final String TAG = CellIdentityGsm.class.getSimpleName(); private static final boolean DBG = false; // 16-bit Location Area Code, 0..65535 Loading @@ -39,10 +36,6 @@ 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 Loading @@ -52,12 +45,11 @@ public final class CellIdentityGsm implements Parcelable { * @hide */ public CellIdentityGsm() { super(TAG, TYPE_GSM, null, null); mLac = Integer.MAX_VALUE; mCid = Integer.MAX_VALUE; mArfcn = Integer.MAX_VALUE; mBsic = Integer.MAX_VALUE; mMccStr = null; mMncStr = null; mAlphaLong = null; mAlphaShort = null; } Loading Loading @@ -105,6 +97,7 @@ public final class CellIdentityGsm implements Parcelable { */ public CellIdentityGsm(int lac, int cid, int arfcn, int bsic, String mccStr, String mncStr, String alphal, String alphas) { super(TAG, TYPE_GSM, mccStr, mncStr); mLac = lac; mCid = cid; mArfcn = arfcn; Loading @@ -112,31 +105,6 @@ public final class CellIdentityGsm implements Parcelable { // for inbound parcels mBsic = (bsic == 0xFF) ? Integer.MAX_VALUE : bsic; // Only allow INT_MAX if unknown string mcc/mnc if (mccStr == null || mccStr.matches("^[0-9]{3}$")) { mMccStr = mccStr; } else if (mccStr.isEmpty() || mccStr.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mccStr is empty or unknown, set it as null. mMccStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MCC format // after the bug got fixed. mMccStr = null; log("invalid MCC format: " + mccStr); } if (mncStr == null || mncStr.matches("^[0-9]{2,3}$")) { mMncStr = mncStr; } else if (mncStr.isEmpty() || mncStr.equals(String.valueOf(Integer.MAX_VALUE))) { // If the mncStr is empty or unknown, set it as null. mMncStr = null; } else { // TODO: b/69384059 Should throw IllegalArgumentException for the invalid MNC format // after the bug got fixed. mMncStr = null; log("invalid MNC format: " + mncStr); } mAlphaLong = alphal; mAlphaShort = alphas; } Loading Loading @@ -237,6 +205,7 @@ public final class CellIdentityGsm implements Parcelable { /** * @deprecated Primary Scrambling Code is not applicable to GSM. * @return Integer.MAX_VALUE, undefined for GSM */ @Deprecated Loading @@ -260,58 +229,54 @@ public final class CellIdentityGsm implements Parcelable { } CellIdentityGsm o = (CellIdentityGsm) other; return mLac == o.mLac && mCid == o.mCid && mArfcn == o.mArfcn && mBsic == o.mBsic && TextUtils.equals(mMccStr, o.mMccStr) && TextUtils.equals(mMncStr, o.mMncStr) && TextUtils.equals(mAlphaLong, o.mAlphaLong) && TextUtils.equals(mAlphaShort, o.mAlphaShort); return mLac == o.mLac && mCid == o.mCid && mArfcn == o.mArfcn && 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(" 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(); } /** Implement the Parcelable interface */ @Override public int describeContents() { return 0; return new StringBuilder(TAG) .append(":{ mLac=").append(mLac) .append(" mCid=").append(mCid) .append(" mArfcn=").append(mArfcn) .append(" mBsic=").append("0x").append(Integer.toHexString(mBsic)) .append(" mMcc=").append(mMccStr) .append(" mMnc=").append(mMncStr) .append(" mAlphaLong=").append(mAlphaLong) .append(" mAlphaShort=").append(mAlphaShort) .append("}").toString(); } /** Implement the Parcelable interface */ @Override public void writeToParcel(Parcel dest, int flags) { if (DBG) log("writeToParcel(Parcel, int): " + toString()); super.writeToParcel(dest, TYPE_GSM); 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) { this(in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readString(), in.readString(), in.readString(), in.readString()); super(TAG, TYPE_GSM, in); mLac = in.readInt(); mCid = in.readInt(); mArfcn = in.readInt(); mBsic = in.readInt(); mAlphaLong = in.readString(); mAlphaShort = in.readString(); if (DBG) log("CellIdentityGsm(Parcel): " + toString()); if (DBG) log(toString()); } /** Implement the Parcelable interface */ Loading @@ -320,7 +285,8 @@ public final class CellIdentityGsm implements Parcelable { new Creator<CellIdentityGsm>() { @Override public CellIdentityGsm createFromParcel(Parcel in) { return new CellIdentityGsm(in); in.readInt(); // skip return createFromParcelBody(in); } @Override Loading @@ -329,10 +295,8 @@ public final class CellIdentityGsm implements Parcelable { } }; /** * log */ private static void log(String s) { Rlog.w(LOG_TAG, s); /** @hide */ protected static CellIdentityGsm createFromParcelBody(Parcel in) { return new CellIdentityGsm(in); } }