diff options
| author | 2020-03-30 15:33:10 +0000 | |
|---|---|---|
| committer | 2020-03-30 15:33:10 +0000 | |
| commit | dc087115c88016c7986a445485827f4d9d4420a4 (patch) | |
| tree | 1de801eb0f0d85fc2f5f8caae6d09c7918e752c1 | |
| parent | 66041721d7c6bf4713169f7f421d6907aa342057 (diff) | |
| parent | c78abaad354cc780d48f5774eb427ade58a2c411 (diff) | |
Merge "Add global cell ID to all technologies" into rvc-dev
7 files changed, 116 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java index 0c2f1f325793..390a79ab1b88 100644 --- a/telephony/java/android/telephony/CellIdentity.java +++ b/telephony/java/android/telephony/CellIdentity.java @@ -68,6 +68,12 @@ public abstract class CellIdentity implements Parcelable { /** @hide */ protected String mAlphaShort; + // For GSM, WCDMA, TDSCDMA, LTE and NR, Cell Global ID is defined in 3GPP TS 23.003. + // For CDMA, its defined as System Id + Network Id + Basestation Id. + /** @hide */ + protected String mGlobalCellId; + + /** @hide */ protected CellIdentity(@Nullable String tag, int type, @Nullable String mcc, @Nullable String mnc, @Nullable String alphal, @Nullable String alphas) { @@ -182,6 +188,36 @@ public abstract class CellIdentity implements Parcelable { } /** + * @return Global Cell ID + * @hide + */ + @Nullable + public String getGlobalCellId() { + return mGlobalCellId; + } + + /** + * @param ci a CellIdentity to compare to the current CellIdentity. + * @return true if ci has the same technology and Global Cell ID; false, otherwise. + * @hide + */ + public boolean isSameCell(@Nullable CellIdentity ci) { + if (ci == null) return false; + if (this.getClass() != ci.getClass()) return false; + if (this.getGlobalCellId() == null || ci.getGlobalCellId() == null) return false; + return TextUtils.equals(this.getGlobalCellId(), ci.getGlobalCellId()); + } + + /** @hide */ + protected String getPlmn() { + if (mMccStr == null || mMncStr == null) return null; + return mMccStr + mMncStr; + } + + /** @hide */ + protected abstract void updateGlobalCellId(); + + /** * @return a CellLocation object for this CellIdentity * @hide */ diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java index e220b07d703a..f21277cdd83c 100644 --- a/telephony/java/android/telephony/CellIdentityCdma.java +++ b/telephony/java/android/telephony/CellIdentityCdma.java @@ -75,6 +75,7 @@ public final class CellIdentityCdma extends CellIdentity { mBasestationId = CellInfo.UNAVAILABLE; mLongitude = CellInfo.UNAVAILABLE; mLatitude = CellInfo.UNAVAILABLE; + mGlobalCellId = null; } /** @@ -106,6 +107,7 @@ public final class CellIdentityCdma extends CellIdentity { } else { mLongitude = mLatitude = CellInfo.UNAVAILABLE; } + updateGlobalCellId(); } /** @hide */ @@ -136,6 +138,16 @@ public final class CellIdentityCdma extends CellIdentity { mAlphaLong, mAlphaShort); } + /** @hide */ + @Override + protected void updateGlobalCellId() { + mGlobalCellId = null; + if (mNetworkId == CellInfo.UNAVAILABLE || mSystemId == CellInfo.UNAVAILABLE + || mBasestationId == CellInfo.UNAVAILABLE) return; + + mGlobalCellId = String.format("%04x%04x%04x", mSystemId, mNetworkId, mBasestationId); + } + /** * Take the latitude and longitude in 1/4 seconds and see if * the reported location is on Null Island. diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index 203047fb111d..1a913105db2e 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -64,6 +64,7 @@ public final class CellIdentityGsm extends CellIdentity { mArfcn = CellInfo.UNAVAILABLE; mBsic = CellInfo.UNAVAILABLE; mAdditionalPlmns = new ArraySet<>(); + mGlobalCellId = null; } /** @@ -94,6 +95,7 @@ public final class CellIdentityGsm extends CellIdentity { mAdditionalPlmns.add(plmn); } } + updateGlobalCellId(); } /** @hide */ @@ -136,6 +138,18 @@ public final class CellIdentityGsm extends CellIdentity { CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort, mAdditionalPlmns); } + /** @hide */ + @Override + protected void updateGlobalCellId() { + mGlobalCellId = null; + String plmn = getPlmn(); + if (plmn == null) return; + + if (mLac == CellInfo.UNAVAILABLE || mCid == CellInfo.UNAVAILABLE) return; + + mGlobalCellId = plmn + String.format("%04x%04x", mLac, mCid); + } + /** * @return 3-digit Mobile Country Code, 0..999, * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index b4ce162274fb..c37735c729a2 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -76,6 +76,7 @@ public final class CellIdentityLte extends CellIdentity { mBandwidth = CellInfo.UNAVAILABLE; mAdditionalPlmns = new ArraySet<>(); mCsgInfo = null; + mGlobalCellId = null; } /** @@ -130,6 +131,7 @@ public final class CellIdentityLte extends CellIdentity { } } mCsgInfo = csgInfo; + updateGlobalCellId(); } /** @hide */ @@ -172,6 +174,18 @@ public final class CellIdentityLte extends CellIdentity { return new CellIdentityLte(this); } + /** @hide */ + @Override + protected void updateGlobalCellId() { + mGlobalCellId = null; + String plmn = getPlmn(); + if (plmn == null) return; + + if (mCi == CellInfo.UNAVAILABLE) return; + + mGlobalCellId = plmn + String.format("%07x", mCi); + } + /** * @return 3-digit Mobile Country Code, 0..999, * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java index 69cf7e7d4814..f0d878001bf4 100644 --- a/telephony/java/android/telephony/CellIdentityNr.java +++ b/telephony/java/android/telephony/CellIdentityNr.java @@ -82,6 +82,7 @@ public final class CellIdentityNr extends CellIdentity { mAdditionalPlmns.add(plmn); } } + updateGlobalCellId(); } /** @hide */ @@ -107,6 +108,17 @@ public final class CellIdentityNr extends CellIdentity { mAdditionalPlmns); } + /** @hide */ + protected void updateGlobalCellId() { + mGlobalCellId = null; + String plmn = getPlmn(); + if (plmn == null) return; + + if (mNci == CellInfo.UNAVAILABLE_LONG) return; + + mGlobalCellId = plmn + String.format("%09x", mNci); + } + /** * @return a CellLocation object for this CellIdentity. * @hide diff --git a/telephony/java/android/telephony/CellIdentityTdscdma.java b/telephony/java/android/telephony/CellIdentityTdscdma.java index 30f98bc57458..3f95596a076e 100644 --- a/telephony/java/android/telephony/CellIdentityTdscdma.java +++ b/telephony/java/android/telephony/CellIdentityTdscdma.java @@ -66,6 +66,7 @@ public final class CellIdentityTdscdma extends CellIdentity { mUarfcn = CellInfo.UNAVAILABLE; mAdditionalPlmns = new ArraySet<>(); mCsgInfo = null; + mGlobalCellId = null; } /** @@ -100,6 +101,7 @@ public final class CellIdentityTdscdma extends CellIdentity { } } mCsgInfo = csgInfo; + updateGlobalCellId(); } private CellIdentityTdscdma(@NonNull CellIdentityTdscdma cid) { @@ -142,6 +144,18 @@ public final class CellIdentityTdscdma extends CellIdentity { return new CellIdentityTdscdma(this); } + /** @hide */ + @Override + protected void updateGlobalCellId() { + mGlobalCellId = null; + String plmn = getPlmn(); + if (plmn == null) return; + + if (mLac == CellInfo.UNAVAILABLE || mCid == CellInfo.UNAVAILABLE) return; + + mGlobalCellId = plmn + String.format("%04x%04x", mLac, mCid); + } + /** * Get Mobile Country Code in string format * @return Mobile Country Code in string format, null if unknown diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index 9d2cb74bac23..38c4ed482e14 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -68,6 +68,7 @@ public final class CellIdentityWcdma extends CellIdentity { mUarfcn = CellInfo.UNAVAILABLE; mAdditionalPlmns = new ArraySet<>(); mCsgInfo = null; + mGlobalCellId = null; } /** @@ -101,6 +102,7 @@ public final class CellIdentityWcdma extends CellIdentity { } } mCsgInfo = csgInfo; + updateGlobalCellId(); } /** @hide */ @@ -142,6 +144,18 @@ public final class CellIdentityWcdma extends CellIdentity { return new CellIdentityWcdma(this); } + /** @hide */ + @Override + protected void updateGlobalCellId() { + mGlobalCellId = null; + String plmn = getPlmn(); + if (plmn == null) return; + + if (mLac == CellInfo.UNAVAILABLE || mCid == CellInfo.UNAVAILABLE) return; + + mGlobalCellId = plmn + String.format("%04x%04x", mLac, mCid); + } + /** * @return 3-digit Mobile Country Code, 0..999, * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable. |