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

Commit c9d74306 authored by Hall Liu's avatar Hall Liu
Browse files

Allow requestNetworkScan to return sanitized info

If an app doesn't have location permissions or if the system location
switch is off, allow requestNetworkScan to still function, but sanitize
the returned CellInfo objects first and disallow certain input arguments

Bug: 126779616
Test: CTS
Change-Id: Ic9c44043bd30d402f128bf0723f2b0bf6c420e3e
parent dedc2714
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -109,6 +109,22 @@ public abstract class CellIdentity implements Parcelable {
        return mType;
    }

    /**
     * @return MCC or null for CDMA
     * @hide
     */
    public String getMccString() {
        return mMccStr;
    }

    /**
     * @return MNC or null for CDMA
     * @hide
     */
    public String getMncString() {
        return mMncStr;
    }

    /**
     * Returns the channel number of the cell identity.
     *
+7 −0
Original line number Diff line number Diff line
@@ -109,6 +109,13 @@ public final class CellIdentityCdma extends CellIdentity {
        return new CellIdentityCdma(this);
    }

    /** @hide */
    public CellIdentityCdma sanitizeLocationInfo() {
        return new CellIdentityCdma(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                mAlphaLong, mAlphaShort);
    }

    /**
     * Take the latitude and longitude in 1/4 seconds and see if
     * the reported location is on Null Island.
+6 −0
Original line number Diff line number Diff line
@@ -97,6 +97,12 @@ public final class CellIdentityGsm extends CellIdentity {
        return new CellIdentityGsm(this);
    }

    /** @hide */
    public CellIdentityGsm sanitizeLocationInfo() {
        return new CellIdentityGsm(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort);
    }

    /**
     * @return 3-digit Mobile Country Code, 0..999,
     *         {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
+7 −0
Original line number Diff line number Diff line
@@ -113,6 +113,13 @@ public final class CellIdentityLte extends CellIdentity {
                cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort);
    }

    /** @hide */
    public CellIdentityLte sanitizeLocationInfo() {
        return new CellIdentityLte(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                mMccStr, mMncStr, mAlphaLong, mAlphaShort);
    }

    CellIdentityLte copy() {
        return new CellIdentityLte(this);
    }
+7 −1
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@ public final class CellIdentityNr extends CellIdentity {
        mNci = nci;
    }

    /** @hide */
    public CellIdentityNr sanitizeLocationInfo() {
        return new CellIdentityNr(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                mMccStr, mMncStr, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort);
    }

    /**
     * @return a CellLocation object for this CellIdentity.
     * @hide
Loading