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

Commit bf003b77 authored by Rambo Wang's avatar Rambo Wang Committed by Gerrit Code Review
Browse files

Merge "Add Nullability Annotations and verification to CellIdentity"

parents 3c57a25b c6c0ca61
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.telephony;

import com.android.telephony.Rlog;

import android.annotation.CallSuper;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -71,8 +69,8 @@ public abstract class CellIdentity implements Parcelable {
    protected String mAlphaShort;

    /** @hide */
    protected CellIdentity(String tag, int type, String mcc, String mnc, String alphal,
                           String alphas) {
    protected CellIdentity(@Nullable String tag, int type, @Nullable String mcc,
            @Nullable String mnc, @Nullable String alphal, @Nullable String alphas) {
        mTag = tag;
        mType = type;

+7 −6
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.telephony;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.telephony.cdma.CdmaCellLocation;

@@ -90,8 +91,8 @@ public final class CellIdentityCdma extends CellIdentity {
     *
     * @hide
     */
    public CellIdentityCdma(
            int nid, int sid, int bid, int lon, int lat, String alphal, String alphas) {
    public CellIdentityCdma(int nid, int sid, int bid, int lon, int lat,
            @Nullable String alphal, @Nullable String alphas) {
        super(TAG, CellInfo.TYPE_CDMA, null, null, alphal, alphas);
        mNetworkId = inRangeOrUnavailable(nid, 0, NETWORK_ID_MAX);
        mSystemId = inRangeOrUnavailable(sid, 0, SYSTEM_ID_MAX);
@@ -108,22 +109,22 @@ public final class CellIdentityCdma extends CellIdentity {
    }

    /** @hide */
    public CellIdentityCdma(android.hardware.radio.V1_0.CellIdentityCdma cid) {
    public CellIdentityCdma(@NonNull android.hardware.radio.V1_0.CellIdentityCdma cid) {
        this(cid.networkId, cid.systemId, cid.baseStationId, cid.longitude, cid.latitude, "", "");
    }

    /** @hide */
    public CellIdentityCdma(android.hardware.radio.V1_2.CellIdentityCdma cid) {
    public CellIdentityCdma(@NonNull android.hardware.radio.V1_2.CellIdentityCdma cid) {
        this(cid.base.networkId, cid.base.systemId, cid.base.baseStationId, cid.base.longitude,
                cid.base.latitude, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort);
    }

    private CellIdentityCdma(CellIdentityCdma cid) {
    private CellIdentityCdma(@NonNull CellIdentityCdma cid) {
        this(cid.mNetworkId, cid.mSystemId, cid.mBasestationId, cid.mLongitude, cid.mLatitude,
                cid.mAlphaLong, cid.mAlphaShort);
    }

    CellIdentityCdma copy() {
    @NonNull CellIdentityCdma copy() {
        return new CellIdentityCdma(this);
    }

+15 −9
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.Parcel;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -78,26 +79,31 @@ public final class CellIdentityGsm extends CellIdentity {
     *
     * @hide
     */
    public CellIdentityGsm(int lac, int cid, int arfcn, int bsic, String mccStr,
                            String mncStr, String alphal, String alphas,
                            List<String> additionalPlmns) {
    public CellIdentityGsm(int lac, int cid, int arfcn, int bsic, @Nullable String mccStr,
            @Nullable String mncStr, @Nullable String alphal, @Nullable String alphas,
            @NonNull List<String> additionalPlmns) {
        super(TAG, CellInfo.TYPE_GSM, mccStr, mncStr, alphal, alphas);
        mLac = inRangeOrUnavailable(lac, 0, MAX_LAC);
        mCid = inRangeOrUnavailable(cid, 0, MAX_CID);
        mArfcn = inRangeOrUnavailable(arfcn, 0, MAX_ARFCN);
        mBsic = inRangeOrUnavailable(bsic, 0, MAX_BSIC);
        mAdditionalPlmns = additionalPlmns;
        mAdditionalPlmns = new ArrayList<>(additionalPlmns.size());
        for (String plmn : additionalPlmns) {
            if (isValidPlmn(plmn)) {
                mAdditionalPlmns.add(plmn);
            }
        }
    }

    /** @hide */
    public CellIdentityGsm(android.hardware.radio.V1_0.CellIdentityGsm cid) {
    public CellIdentityGsm(@NonNull android.hardware.radio.V1_0.CellIdentityGsm cid) {
        this(cid.lac, cid.cid, cid.arfcn,
                cid.bsic == (byte) 0xFF ? CellInfo.UNAVAILABLE : cid.bsic,
                cid.mcc, cid.mnc, "", "", Collections.emptyList());
    }

    /** @hide */
    public CellIdentityGsm(android.hardware.radio.V1_2.CellIdentityGsm cid) {
    public CellIdentityGsm(@NonNull android.hardware.radio.V1_2.CellIdentityGsm cid) {
        this(cid.base.lac, cid.base.cid, cid.base.arfcn,
                cid.base.bsic == (byte) 0xFF ? CellInfo.UNAVAILABLE : cid.base.bsic, cid.base.mcc,
                cid.base.mnc, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort,
@@ -105,7 +111,7 @@ public final class CellIdentityGsm extends CellIdentity {
    }

    /** @hide */
    public CellIdentityGsm(android.hardware.radio.V1_5.CellIdentityGsm cid) {
    public CellIdentityGsm(@NonNull android.hardware.radio.V1_5.CellIdentityGsm cid) {
        this(cid.base.base.lac, cid.base.base.cid, cid.base.base.arfcn,
                cid.base.base.bsic == (byte) 0xFF ? CellInfo.UNAVAILABLE
                        : cid.base.base.bsic, cid.base.base.mcc,
@@ -113,12 +119,12 @@ public final class CellIdentityGsm extends CellIdentity {
                cid.base.operatorNames.alphaShort, cid.additionalPlmns);
    }

    private CellIdentityGsm(CellIdentityGsm cid) {
    private CellIdentityGsm(@NonNull CellIdentityGsm cid) {
        this(cid.mLac, cid.mCid, cid.mArfcn, cid.mBsic, cid.mMccStr,
                cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort, cid.mAdditionalPlmns);
    }

    CellIdentityGsm copy() {
    @NonNull CellIdentityGsm copy() {
        return new CellIdentityGsm(this);
    }

+16 −9
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Parcel;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -104,34 +105,40 @@ public final class CellIdentityLte extends CellIdentity {
     *
     * @hide
     */
    public CellIdentityLte(int ci, int pci, int tac, int earfcn, int bandwidth, String mccStr,
            String mncStr, String alphal, String alphas, List<String> additionalPlmns,
            ClosedSubscriberGroupInfo csgInfo) {
    public CellIdentityLte(int ci, int pci, int tac, int earfcn, int bandwidth,
            @Nullable String mccStr, @Nullable String mncStr, @Nullable String alphal,
            @Nullable String alphas, @NonNull List<String> additionalPlmns,
            @Nullable ClosedSubscriberGroupInfo csgInfo) {
        super(TAG, CellInfo.TYPE_LTE, mccStr, mncStr, alphal, alphas);
        mCi = inRangeOrUnavailable(ci, 0, MAX_CI);
        mPci = inRangeOrUnavailable(pci, 0, MAX_PCI);
        mTac = inRangeOrUnavailable(tac, 0, MAX_TAC);
        mEarfcn = inRangeOrUnavailable(earfcn, 0, MAX_EARFCN);
        mBandwidth = inRangeOrUnavailable(bandwidth, 0, MAX_BANDWIDTH);
        mAdditionalPlmns = additionalPlmns;
        mAdditionalPlmns = new ArrayList<>(additionalPlmns.size());
        for (String plmn : additionalPlmns) {
            if (isValidPlmn(plmn)) {
                mAdditionalPlmns.add(plmn);
            }
        }
        mCsgInfo = csgInfo;
    }

    /** @hide */
    public CellIdentityLte(android.hardware.radio.V1_0.CellIdentityLte cid) {
    public CellIdentityLte(@NonNull android.hardware.radio.V1_0.CellIdentityLte cid) {
        this(cid.ci, cid.pci, cid.tac, cid.earfcn,
                CellInfo.UNAVAILABLE, cid.mcc, cid.mnc, "", "", Collections.emptyList(), null);
    }

    /** @hide */
    public CellIdentityLte(android.hardware.radio.V1_2.CellIdentityLte cid) {
    public CellIdentityLte(@NonNull android.hardware.radio.V1_2.CellIdentityLte cid) {
        this(cid.base.ci, cid.base.pci, cid.base.tac, cid.base.earfcn, cid.bandwidth,
                cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong,
                cid.operatorNames.alphaShort, Collections.emptyList(), null);
    }

    /** @hide */
    public CellIdentityLte(android.hardware.radio.V1_5.CellIdentityLte cid) {
    public CellIdentityLte(@NonNull android.hardware.radio.V1_5.CellIdentityLte cid) {
        this(cid.base.base.ci, cid.base.base.pci, cid.base.base.tac, cid.base.base.earfcn,
                cid.base.bandwidth, cid.base.base.mcc, cid.base.base.mnc,
                cid.base.operatorNames.alphaLong, cid.base.operatorNames.alphaShort,
@@ -139,7 +146,7 @@ public final class CellIdentityLte extends CellIdentity {
                        ? new ClosedSubscriberGroupInfo(cid.optionalCsgInfo.csgInfo()) : null);
    }

    private CellIdentityLte(CellIdentityLte cid) {
    private CellIdentityLte(@NonNull CellIdentityLte cid) {
        this(cid.mCi, cid.mPci, cid.mTac, cid.mEarfcn, cid.mBandwidth, cid.mMccStr,
                cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort, cid.mAdditionalPlmns, cid.mCsgInfo);
    }
@@ -152,7 +159,7 @@ public final class CellIdentityLte extends CellIdentity {
                mMccStr, mMncStr, mAlphaLong, mAlphaShort, mAdditionalPlmns, null);
    }

    CellIdentityLte copy() {
    @NonNull CellIdentityLte copy() {
        return new CellIdentityLte(this);
    }

+11 −5
Original line number Diff line number Diff line
@@ -64,26 +64,32 @@ public final class CellIdentityNr extends CellIdentity {
     * @hide
     */
    public CellIdentityNr(int pci, int tac, int nrArfcn, @NgranBand List<Integer> bands,
                          String mccStr, String mncStr, long nci, String alphal, String alphas,
                          List<String> additionalPlmns) {
                          @Nullable String mccStr, @Nullable String mncStr, long nci,
                          @Nullable String alphal, @Nullable String alphas,
                          @NonNull List<String> additionalPlmns) {
        super(TAG, CellInfo.TYPE_NR, mccStr, mncStr, alphal, alphas);
        mPci = inRangeOrUnavailable(pci, 0, MAX_PCI);
        mTac = inRangeOrUnavailable(tac, 0, MAX_TAC);
        mNrArfcn = inRangeOrUnavailable(nrArfcn, 0, MAX_NRARFCN);
        mBands = new ArrayList<>(bands);
        mNci = inRangeOrUnavailable(nci, 0, MAX_NCI);
        mAdditionalPlmns = new ArrayList<>(additionalPlmns);
        mAdditionalPlmns = new ArrayList<>(additionalPlmns.size());
        for (String plmn : additionalPlmns) {
            if (isValidPlmn(plmn)) {
                mAdditionalPlmns.add(plmn);
            }
        }
    }

    /** @hide */
    public CellIdentityNr(android.hardware.radio.V1_4.CellIdentityNr cid) {
    public CellIdentityNr(@NonNull android.hardware.radio.V1_4.CellIdentityNr cid) {
        this(cid.pci, cid.tac, cid.nrarfcn, Collections.emptyList(), cid.mcc, cid.mnc, cid.nci,
                cid.operatorNames.alphaLong, cid.operatorNames.alphaShort,
                Collections.emptyList());
    }

    /** @hide */
    public CellIdentityNr(android.hardware.radio.V1_5.CellIdentityNr cid) {
    public CellIdentityNr(@NonNull android.hardware.radio.V1_5.CellIdentityNr cid) {
        this(cid.base.pci, cid.base.tac, cid.base.nrarfcn, cid.bands, cid.base.mcc, cid.base.mnc,
                cid.base.nci, cid.base.operatorNames.alphaLong,
                cid.base.operatorNames.alphaShort, cid.additionalPlmns);
Loading