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

Commit 2436cff5 authored by Rambo Wang's avatar Rambo Wang
Browse files

Preparation to expose SignalThresholdInfo as public class

Introduce RAN to better associate it with thresholds. Later CL
should be able to further simplify APIs which ask for both RAN and
SignalThresholdInfo.

Validate threshold values during constructing.

Deliberately hide all the public fields and methods, so the following
CL will only need to expose designed properties. Make it easy
for API review.

Bug: 164432835
Test: atest com.android.internal.telephony.SignalThresholdInfoTest
Change-Id: Ib0600c43b90ab0231b29f989976cb090f4b37bf8
parent f0341dc3
Loading
Loading
Loading
Loading
+417 −61
Original line number Original line Diff line number Diff line
@@ -30,99 +30,117 @@ import java.util.Objects;
 * Defines the threshold value of the signal strength.
 * Defines the threshold value of the signal strength.
 * @hide
 * @hide
 */
 */
public class SignalThresholdInfo implements Parcelable {
public final class SignalThresholdInfo implements Parcelable {

    /**
     * Unknown signal measurement type.
     * @hide
     */
    public static final int SIGNAL_MEASUREMENT_TYPE_UNKNOWN = 0;

    /**
    /**
     * Received Signal Strength Indication.
     * Received Signal Strength Indication.
     * Range: -113 dBm and -51 dBm
     * Range: -113 dBm and -51 dBm
     * Used RAN: GERAN, CDMA2000
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#GERAN},
     *           {@link AccessNetworkConstants.AccessNetworkType#CDMA2000}
     * Reference: 3GPP TS 27.007 section 8.5.
     * Reference: 3GPP TS 27.007 section 8.5.
     * @hide
     */
     */
    public static final int SIGNAL_RSSI = 1;
    public static final int SIGNAL_MEASUREMENT_TYPE_RSSI = 1;


    /**
    /**
     * Received Signal Code Power.
     * Received Signal Code Power.
     * Range: -120 dBm to -25 dBm;
     * Range: -120 dBm to -25 dBm;
     * Used RAN: UTRAN
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#UTRAN}
     * Reference: 3GPP TS 25.123, section 9.1.1.1
     * Reference: 3GPP TS 25.123, section 9.1.1.1
     * @hide
     */
     */
    public static final int SIGNAL_RSCP = 2;
    public static final int SIGNAL_MEASUREMENT_TYPE_RSCP = 2;


    /**
    /**
     * Reference Signal Received Power.
     * Reference Signal Received Power.
     * Range: -140 dBm to -44 dBm;
     * Range: -140 dBm to -44 dBm;
     * Used RAN: EUTRAN
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#EUTRAN}
     * Reference: 3GPP TS 36.133 9.1.4
     * Reference: 3GPP TS 36.133 9.1.4
     * @hide
     */
     */
    public static final int SIGNAL_RSRP = 3;
    public static final int SIGNAL_MEASUREMENT_TYPE_RSRP = 3;


    /**
    /**
     * Reference Signal Received Quality
     * Reference Signal Received Quality
     * Range: -20 dB to -3 dB;
     * Range: -34 dB to 3 dB;
     * Used RAN: EUTRAN
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#EUTRAN}
     * Reference: 3GPP TS 36.133 9.1.7
     * Reference: 3GPP TS 36.133 9.1.7
     * @hide
     */
     */
    public static final int SIGNAL_RSRQ = 4;
    public static final int SIGNAL_MEASUREMENT_TYPE_RSRQ = 4;


    /**
    /**
     * Reference Signal Signal to Noise Ratio
     * Reference Signal Signal to Noise Ratio
     * Range: -20 dB to 30 dB;
     * Range: -20 dB to 30 dB;
     * Used RAN: EUTRAN
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#EUTRAN}
     * @hide
     */
     */
    public static final int SIGNAL_RSSNR = 5;
    public static final int SIGNAL_MEASUREMENT_TYPE_RSSNR = 5;


    /**
    /**
     * 5G SS reference signal received power.
     * 5G SS reference signal received power.
     * Range: -140 dBm to -44 dBm.
     * Range: -140 dBm to -44 dBm.
     * Used RAN: NGRAN
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#NGRAN}
     * Reference: 3GPP TS 38.215.
     * Reference: 3GPP TS 38.215.
     * @hide
     */
     */
    public static final int SIGNAL_SSRSRP = 6;
    public static final int SIGNAL_MEASUREMENT_TYPE_SSRSRP = 6;


    /**
    /**
     * 5G SS reference signal received quality.
     * 5G SS reference signal received quality.
     * Range: -20 dB to -3 dB.
     * Range: -43 dB to 20 dB.
     * Used RAN: NGRAN
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#NGRAN}
     * Reference: 3GPP TS 38.215.
     * Reference: 3GPP TS 38.133 section 10.1.11.1.
     * @hide
     */
     */
    public static final int SIGNAL_SSRSRQ = 7;
    public static final int SIGNAL_MEASUREMENT_TYPE_SSRSRQ = 7;


    /**
    /**
     * 5G SS signal-to-noise and interference ratio.
     * 5G SS signal-to-noise and interference ratio.
     * Range: -23 dB to 40 dB
     * Range: -23 dB to 40 dB
     * Used RAN: NGRAN
     * Used RAN: {@link AccessNetworkConstants.AccessNetworkType#NGRAN}
     * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
     * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
     * @hide
     */
     */
    public static final int SIGNAL_SSSINR = 8;
    public static final int SIGNAL_MEASUREMENT_TYPE_SSSINR = 8;


    /** @hide */
    /** @hide */
    @IntDef(prefix = { "SIGNAL_" }, value = {
    @IntDef(prefix = {"SIGNAL_MEASUREMENT_TYPE_"}, value = {
        SIGNAL_RSSI,
            SIGNAL_MEASUREMENT_TYPE_UNKNOWN,
        SIGNAL_RSCP,
            SIGNAL_MEASUREMENT_TYPE_RSSI,
        SIGNAL_RSRP,
            SIGNAL_MEASUREMENT_TYPE_RSCP,
        SIGNAL_RSRQ,
            SIGNAL_MEASUREMENT_TYPE_RSRP,
        SIGNAL_RSSNR,
            SIGNAL_MEASUREMENT_TYPE_RSRQ,
        SIGNAL_SSRSRP,
            SIGNAL_MEASUREMENT_TYPE_RSSNR,
        SIGNAL_SSRSRQ,
            SIGNAL_MEASUREMENT_TYPE_SSRSRP,
        SIGNAL_SSSINR
            SIGNAL_MEASUREMENT_TYPE_SSRSRQ,
            SIGNAL_MEASUREMENT_TYPE_SSSINR
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface SignalMeasurementType {}
    public @interface SignalMeasurementType {
    }


    @SignalMeasurementType
    @SignalMeasurementType
    private int mSignalMeasurement;
    private final int mSignalMeasurementType;


    /**
    /**
     * A hysteresis time in milliseconds to prevent flapping.
     * A hysteresis time in milliseconds to prevent flapping.
     * A value of 0 disables hysteresis
     * A value of 0 disables hysteresis
     */
     */
    private int mHysteresisMs;
    private final int mHysteresisMs;


    /**
    /**
     * An interval in dB defining the required magnitude change between reports.
     * An interval in dB defining the required magnitude change between reports.
     * hysteresisDb must be smaller than the smallest threshold delta.
     * hysteresisDb must be smaller than the smallest threshold delta.
     * An interval value of 0 disables hysteresis.
     * An interval value of 0 disables hysteresis.
     */
     */
    private int mHysteresisDb;
    private final int mHysteresisDb;


    /**
    /**
     * List of threshold values.
     * List of threshold values.
@@ -130,60 +148,323 @@ public class SignalThresholdInfo implements Parcelable {
     * The threshold values for which to apply criteria.
     * The threshold values for which to apply criteria.
     * A vector size of 0 disables the use of thresholds for reporting.
     * A vector size of 0 disables the use of thresholds for reporting.
     */
     */
    private int[] mThresholds = null;
    private final int[] mThresholds;


    /**
    /**
     * {@code true} means modem must trigger the report based on the criteria;
     * {@code true} means modem must trigger the report based on the criteria;
     * {@code false} means modem must not trigger the report based on the criteria.
     * {@code false} means modem must not trigger the report based on the criteria.
     */
     */
    private boolean mIsEnabled = true;
    private final boolean mIsEnabled;

    /**
     * The radio access network type associated with the signal thresholds.
     */
    @AccessNetworkConstants.RadioAccessNetworkType
    private final int mRan;


    /**
    /**
     * Indicates the hysteresisMs is disabled.
     * Indicates the hysteresisMs is disabled.
     *
     * @hide
     */
     */
    public static final int HYSTERESIS_MS_DISABLED = 0;
    public static final int HYSTERESIS_MS_DISABLED = 0;


    /**
    /**
     * Indicates the hysteresisDb is disabled.
     * Indicates the hysteresisDb is disabled.
     *
     * @hide
     */
     */
    public static final int HYSTERESIS_DB_DISABLED = 0;
    public static final int HYSTERESIS_DB_DISABLED = 0;



    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSI}.
     *
     * @hide
     */
    public static final int SIGNAL_RSSI_MIN_VALUE = -113;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSI}.
     *
     * @hide
     */
    public static final int SIGNAL_RSSI_MAX_VALUE = -51;

    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSCP}.
     *
     * @hide
     */
    public static final int SIGNAL_RSCP_MIN_VALUE = -120;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSCP}.
     *
     * @hide
     */
    public static final int SIGNAL_RSCP_MAX_VALUE = -25;

    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRP}.
     *
     * @hide
     */
    public static final int SIGNAL_RSRP_MIN_VALUE = -140;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRP}.
     *
     * @hide
     */
    public static final int SIGNAL_RSRP_MAX_VALUE = -44;

    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRQ}.
     *
     * @hide
     */
    public static final int SIGNAL_RSRQ_MIN_VALUE = -34;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSRQ}.
     *
     * @hide
     */
    public static final int SIGNAL_RSRQ_MAX_VALUE = 3;

    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSNR}.
     *
     * @hide
     */
    public static final int SIGNAL_RSSNR_MIN_VALUE = -20;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_RSSNR}.
     *
     * @hide
     */
    public static final int SIGNAL_RSSNR_MAX_VALUE = 30;

    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRP}.
     *
     * @hide
     */
    public static final int SIGNAL_SSRSRP_MIN_VALUE = -140;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRP}.
     *
     * @hide
     */
    public static final int SIGNAL_SSRSRP_MAX_VALUE = -44;

    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRQ}.
     *
     * @hide
     */
    public static final int SIGNAL_SSRSRQ_MIN_VALUE = -43;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSRSRQ}.
     *
     * @hide
     */
    public static final int SIGNAL_SSRSRQ_MAX_VALUE = 20;

    /**
     * Minimum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSSINR}.
     *
     * @hide
     */
    public static final int SIGNAL_SSSINR_MIN_VALUE = -23;

    /**
     * Maximum valid value for {@link #SIGNAL_MEASUREMENT_TYPE_SSSINR}.
     *
     * @hide
     */
    public static final int SIGNAL_SSSINR_MAX_VALUE = 40;

    /**
    /**
     * Constructor
     * Constructor
     *
     *
     * @param signalMeasurement Signal Measurement Type
     * @param ran               Radio Access Network type
     * @param signalMeasurementType Signal Measurement Type
     * @param hysteresisMs      hysteresisMs
     * @param hysteresisMs      hysteresisMs
     * @param hysteresisDb      hysteresisDb
     * @param hysteresisDb      hysteresisDb
     * @param thresholds        threshold value
     * @param thresholds        threshold value
     * @param isEnabled         isEnabled
     * @param isEnabled         isEnabled
     */
     */
    public SignalThresholdInfo(@SignalMeasurementType int signalMeasurement,
    private SignalThresholdInfo(@AccessNetworkConstants.RadioAccessNetworkType int ran,
            int hysteresisMs, int hysteresisDb, @NonNull int [] thresholds, boolean isEnabled) {
            @SignalMeasurementType int signalMeasurementType, int hysteresisMs, int hysteresisDb,
        mSignalMeasurement = signalMeasurement;
            @NonNull int[] thresholds, boolean isEnabled) {
        Objects.requireNonNull(thresholds, "thresholds must not be null");
        validateRanWithMeasurementType(ran, signalMeasurementType);
        validateThresholdRange(signalMeasurementType, thresholds);

        mRan = ran;
        mSignalMeasurementType = signalMeasurementType;
        mHysteresisMs = hysteresisMs < 0 ? HYSTERESIS_MS_DISABLED : hysteresisMs;
        mHysteresisMs = hysteresisMs < 0 ? HYSTERESIS_MS_DISABLED : hysteresisMs;
        mHysteresisDb = hysteresisDb < 0 ? HYSTERESIS_DB_DISABLED : hysteresisDb;
        mHysteresisDb = hysteresisDb < 0 ? HYSTERESIS_DB_DISABLED : hysteresisDb;
        mThresholds = thresholds == null ? null : thresholds.clone();
        mThresholds = thresholds;
        mIsEnabled = isEnabled;
        mIsEnabled = isEnabled;
    }
    }


    public @SignalMeasurementType int getSignalMeasurement() {
    /**
        return mSignalMeasurement;
     * Builder class to create {@link SignalThresholdInfo} objects.
     *
     * @hide
     */
    public static final class Builder {
        private int mRan = AccessNetworkConstants.AccessNetworkType.UNKNOWN;
        private int mSignalMeasurementType = SIGNAL_MEASUREMENT_TYPE_UNKNOWN;
        private int mHysteresisMs = HYSTERESIS_MS_DISABLED;
        private int mHysteresisDb = HYSTERESIS_DB_DISABLED;
        private int[] mThresholds = null;
        private boolean mIsEnabled = false;

        /**
         * Set the radio access network type for the builder instance.
         *
         * @param ran The radio access network type
         * @return the builder to facilitate the chaining
         */
        public @NonNull Builder setRadioAccessNetworkType(
                @AccessNetworkConstants.RadioAccessNetworkType int ran) {
            mRan = ran;
            return this;
        }

        /**
         * Set the signal measurement type for the builder instance.
         *
         * @param signalMeasurementType The signal measurement type
         * @return the builder to facilitate the chaining
         */
        public @NonNull Builder setSignalMeasurementType(
                @SignalMeasurementType int signalMeasurementType) {
            mSignalMeasurementType = signalMeasurementType;
            return this;
        }

        /**
         * Set the hysteresis time in milliseconds to prevent flapping. A value of 0 disables
         * hysteresis.
         *
         * @param hysteresisMs the hysteresis time in milliseconds
         * @return the builder to facilitate the chaining
         * @hide
         */
        public @NonNull Builder setHysteresisMs(int hysteresisMs) {
            mHysteresisMs = hysteresisMs;
            return this;
        }

        /**
         * Set the interval in dB defining the required magnitude change between reports. A value of
         * zero disabled dB-based hysteresis restrictions.
         *
         * @param hysteresisDb the interval in dB
         * @return the builder to facilitate the chaining
         * @hide
         */
        public @NonNull Builder setHysteresisDb(int hysteresisDb) {
            mHysteresisDb = hysteresisDb;
            return this;
        }

        /**
         * Set the signal threshold values of the corresponding signal measurement type.
         *
         * The range and unit must reference specific SignalMeasurementType.
         *
         * @param thresholds array of integer as the signal threshold values
         * @return the builder to facilitate the chaining
         */
        public @NonNull Builder setThresholds(@NonNull int[] thresholds) {
            Objects.requireNonNull(thresholds, "thresholds must not be null");
            mThresholds = thresholds.clone();
            Arrays.sort(mThresholds);
            return this;
        }

        /**
         * Set if the modem should trigger the report based on the criteria.
         *
         * @param isEnabled true if the modem should trigger the report based on the criteria
         * @return the builder to facilitate the chaining
         * @hide
         */
        public @NonNull Builder setIsEnabled(boolean isEnabled) {
            mIsEnabled = isEnabled;
            return this;
        }
        }


        /**
         * Build {@link SignalThresholdInfo} object.
         *
         * @return the SignalThresholdInfo object build out
         *
         * @throws IllegalArgumentException if the signal measurement type is invalid, any value in
         * the thresholds is out of range, or the RAN is not allowed to set with the signal
         * measurement type
         */
        public @NonNull SignalThresholdInfo build() {
            return new SignalThresholdInfo(mRan, mSignalMeasurementType, mHysteresisMs,
                    mHysteresisDb, mThresholds, mIsEnabled);
        }
    }

    /**
     * Get the radio access network type.
     *
     * @return radio access network type
     *
     * @hide
     */
    public @AccessNetworkConstants.RadioAccessNetworkType int getRadioAccessNetworkType() {
        return mRan;
    }

    /**
     * Get the signal measurement type.
     *
     * @return the SignalMeasurementType value
     *
     * @hide
     */
    public @SignalMeasurementType int getSignalMeasurementType() {
        return mSignalMeasurementType;
    }

    /** @hide */
    public int getHysteresisMs() {
    public int getHysteresisMs() {
        return mHysteresisMs;
        return mHysteresisMs;
    }
    }


    /** @hide */
    public int getHysteresisDb() {
    public int getHysteresisDb() {
        return mHysteresisDb;
        return mHysteresisDb;
    }
    }


    /** @hide */
    public boolean isEnabled() {
    public boolean isEnabled() {
        return mIsEnabled;
        return mIsEnabled;
    }
    }


    public int[] getThresholds() {
    /**
        return mThresholds == null ? null : mThresholds.clone();
     * Get the signal threshold values.
     *
     * @return array of integer of the signal thresholds
     *
     * @hide
     */
    public @NonNull int[] getThresholds() {
        return mThresholds.clone();
    }
    }


    @Override
    @Override
@@ -192,8 +473,9 @@ public class SignalThresholdInfo implements Parcelable {
    }
    }


    @Override
    @Override
    public void writeToParcel(Parcel out, int flags) {
    public void writeToParcel(@NonNull Parcel out, int flags) {
        out.writeInt(mSignalMeasurement);
        out.writeInt(mRan);
        out.writeInt(mSignalMeasurementType);
        out.writeInt(mHysteresisMs);
        out.writeInt(mHysteresisMs);
        out.writeInt(mHysteresisDb);
        out.writeInt(mHysteresisDb);
        out.writeIntArray(mThresholds);
        out.writeIntArray(mThresholds);
@@ -201,7 +483,8 @@ public class SignalThresholdInfo implements Parcelable {
    }
    }


    private SignalThresholdInfo(Parcel in) {
    private SignalThresholdInfo(Parcel in) {
        mSignalMeasurement = in.readInt();
        mRan = in.readInt();
        mSignalMeasurementType = in.readInt();
        mHysteresisMs = in.readInt();
        mHysteresisMs = in.readInt();
        mHysteresisDb = in.readInt();
        mHysteresisDb = in.readInt();
        mThresholds = in.createIntArray();
        mThresholds = in.createIntArray();
@@ -217,7 +500,8 @@ public class SignalThresholdInfo implements Parcelable {
        }
        }


        SignalThresholdInfo other = (SignalThresholdInfo) o;
        SignalThresholdInfo other = (SignalThresholdInfo) o;
        return mSignalMeasurement == other.mSignalMeasurement
        return mRan == other.mRan
                && mSignalMeasurementType == other.mSignalMeasurementType
                && mHysteresisMs == other.mHysteresisMs
                && mHysteresisMs == other.mHysteresisMs
                && mHysteresisDb == other.mHysteresisDb
                && mHysteresisDb == other.mHysteresisDb
                && Arrays.equals(mThresholds, other.mThresholds)
                && Arrays.equals(mThresholds, other.mThresholds)
@@ -226,8 +510,8 @@ public class SignalThresholdInfo implements Parcelable {


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(
        return Objects.hash(mRan, mSignalMeasurementType, mHysteresisMs, mHysteresisDb, mThresholds,
                mSignalMeasurement, mHysteresisMs, mHysteresisDb, mThresholds, mIsEnabled);
                mIsEnabled);
    }
    }


    public static final @NonNull Parcelable.Creator<SignalThresholdInfo> CREATOR =
    public static final @NonNull Parcelable.Creator<SignalThresholdInfo> CREATOR =
@@ -246,11 +530,83 @@ public class SignalThresholdInfo implements Parcelable {
    @Override
    @Override
    public String toString() {
    public String toString() {
        return new StringBuilder("SignalThresholdInfo{")
        return new StringBuilder("SignalThresholdInfo{")
            .append("mSignalMeasurement=").append(mSignalMeasurement)
                .append("mRan=").append(mRan)
            .append("mHysteresisMs=").append(mSignalMeasurement)
                .append(" mSignalMeasurementType=").append(mSignalMeasurementType)
                .append(" mHysteresisMs=").append(mHysteresisMs)
                .append(" mHysteresisDb=").append(mHysteresisDb)
                .append(" mHysteresisDb=").append(mHysteresisDb)
                .append(" mThresholds=").append(Arrays.toString(mThresholds))
                .append(" mThresholds=").append(Arrays.toString(mThresholds))
                .append(" mIsEnabled=").append(mIsEnabled)
                .append(" mIsEnabled=").append(mIsEnabled)
                .append("}").toString();
                .append("}").toString();
    }
    }

    /**
     * Return true if signal measurement type is valid and the threshold value is in range.
     */
    private static boolean isValidThreshold(@SignalMeasurementType int type, int threshold) {
        switch (type) {
            case SIGNAL_MEASUREMENT_TYPE_RSSI:
                return threshold >= SIGNAL_RSSI_MIN_VALUE && threshold <= SIGNAL_RSSI_MAX_VALUE;
            case SIGNAL_MEASUREMENT_TYPE_RSCP:
                return threshold >= SIGNAL_RSCP_MIN_VALUE && threshold <= SIGNAL_RSCP_MAX_VALUE;
            case SIGNAL_MEASUREMENT_TYPE_RSRP:
                return threshold >= SIGNAL_RSRP_MIN_VALUE && threshold <= SIGNAL_RSRP_MAX_VALUE;
            case SIGNAL_MEASUREMENT_TYPE_RSRQ:
                return threshold >= SIGNAL_RSRQ_MIN_VALUE && threshold <= SIGNAL_RSRQ_MAX_VALUE;
            case SIGNAL_MEASUREMENT_TYPE_RSSNR:
                return threshold >= SIGNAL_RSSNR_MIN_VALUE && threshold <= SIGNAL_RSSNR_MAX_VALUE;
            case SIGNAL_MEASUREMENT_TYPE_SSRSRP:
                return threshold >= SIGNAL_SSRSRP_MIN_VALUE && threshold <= SIGNAL_SSRSRP_MAX_VALUE;
            case SIGNAL_MEASUREMENT_TYPE_SSRSRQ:
                return threshold >= SIGNAL_SSRSRQ_MIN_VALUE && threshold <= SIGNAL_SSRSRQ_MAX_VALUE;
            case SIGNAL_MEASUREMENT_TYPE_SSSINR:
                return threshold >= SIGNAL_SSSINR_MIN_VALUE && threshold <= SIGNAL_SSSINR_MAX_VALUE;
            default:
                return false;
        }
    }

    /**
     * Return true if the radio access type is allowed to set with the measurement type.
     */
    private static boolean isValidRanWithMeasurementType(
            @AccessNetworkConstants.RadioAccessNetworkType int ran,
            @SignalMeasurementType int type) {
        switch (type) {
            case SIGNAL_MEASUREMENT_TYPE_RSSI:
                return ran == AccessNetworkConstants.AccessNetworkType.GERAN
                        || ran == AccessNetworkConstants.AccessNetworkType.CDMA2000;
            case SIGNAL_MEASUREMENT_TYPE_RSCP:
                return ran == AccessNetworkConstants.AccessNetworkType.UTRAN;
            case SIGNAL_MEASUREMENT_TYPE_RSRP:
            case SIGNAL_MEASUREMENT_TYPE_RSRQ:
            case SIGNAL_MEASUREMENT_TYPE_RSSNR:
                return ran == AccessNetworkConstants.AccessNetworkType.EUTRAN;
            case SIGNAL_MEASUREMENT_TYPE_SSRSRP:
            case SIGNAL_MEASUREMENT_TYPE_SSRSRQ:
            case SIGNAL_MEASUREMENT_TYPE_SSSINR:
                return ran == AccessNetworkConstants.AccessNetworkType.NGRAN;
            default:
                return false;
        }
    }

    private void validateRanWithMeasurementType(
            @AccessNetworkConstants.RadioAccessNetworkType int ran,
            @SignalMeasurementType int signalMeasurement) {
        if (!isValidRanWithMeasurementType(ran, signalMeasurement)) {
            throw new IllegalArgumentException(
                    "invalid RAN: " + ran + " with signal measurement type: " + signalMeasurement);
        }
    }

    private void validateThresholdRange(@SignalMeasurementType int signalMeasurement,
            int[] thresholds) {
        for (int threshold : thresholds) {
            if (!isValidThreshold(signalMeasurement, threshold)) {
                throw new IllegalArgumentException(
                        "invalid signal measurement type: " + signalMeasurement
                                + " with threshold: " + threshold);
            }
        }
    }
}
}