Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b81ecdb authored by Mingming Cai's avatar Mingming Cai Committed by Automerger Merge Worker
Browse files

Merge "Add global cell ID to all technologies" into rvc-dev am: dc087115

Change-Id: I108261769e56c37d57913de1e89376776d699130
parents 89c73b0c dc087115
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -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
+12 −0
Original line number Diff line number Diff line
@@ -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.
+14 −0
Original line number Diff line number Diff line
@@ -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.
+14 −0
Original line number Diff line number Diff line
@@ -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.
+12 −0
Original line number Diff line number Diff line
@@ -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
Loading