Merge "Add global cell ID to all technologies"
This commit is contained in:
@@ -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) {
|
||||
@@ -181,6 +187,36 @@ public abstract class CellIdentity implements Parcelable {
|
||||
mAlphaShort = alphaShort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user