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

Commit eff2a6c2 authored by Andrew Sapperstein's avatar Andrew Sapperstein Committed by Android (Google) Code Review
Browse files

Merge "Add missing validation in data classes" into udc-dev

parents 4e6148bb d53c4190
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ public final class HotspotNetwork implements Parcelable {
        }
    }

    private static void validate(long deviceId, int networkType, String networkName) {
    private static void validate(long deviceId, @NetworkType int networkType, String networkName) {
        if (deviceId < 0) {
            throw new IllegalArgumentException("DeviceId must be set");
        }
+17 −2
Original line number Diff line number Diff line
@@ -163,9 +163,24 @@ public final class HotspotNetworkConnectionStatus implements Parcelable {
        }
    }

    private static void validate(@ConnectionStatus int status) {
        if (status != CONNECTION_STATUS_UNKNOWN
                && status != CONNECTION_STATUS_ENABLING_HOTSPOT
                && status != CONNECTION_STATUS_UNKNOWN_ERROR
                && status != CONNECTION_STATUS_PROVISIONING_FAILED
                && status != CONNECTION_STATUS_TETHERING_TIMEOUT
                && status != CONNECTION_STATUS_TETHERING_UNSUPPORTED
                && status != CONNECTION_STATUS_NO_CELL_DATA
                && status != CONNECTION_STATUS_ENABLING_HOTSPOT_FAILED
                && status != CONNECTION_STATUS_ENABLING_HOTSPOT_TIMEOUT
                && status != CONNECTION_STATUS_CONNECT_TO_HOTSPOT_FAILED) {
            throw new IllegalArgumentException("Illegal connection status");
        }
    }

    private HotspotNetworkConnectionStatus(@ConnectionStatus int status,
            HotspotNetwork hotspotNetwork,
            Bundle extras) {
            HotspotNetwork hotspotNetwork, Bundle extras) {
        validate(status);
        mStatus = status;
        mHotspotNetwork = hotspotNetwork;
        mExtras = extras;
+12 −6
Original line number Diff line number Diff line
@@ -64,20 +64,25 @@ public final class KnownNetwork implements Parcelable {
            NETWORK_SOURCE_NEARBY_SELF,
            NETWORK_SOURCE_CLOUD_SELF
    })
    public @interface NetworkSource {}
    public @interface NetworkSource {
    }

    @NetworkSource private final int mNetworkSource;
    @NetworkSource
    private final int mNetworkSource;
    private final String mSsid;
    @SecurityType private final ArraySet<Integer> mSecurityTypes;
    @SecurityType
    private final ArraySet<Integer> mSecurityTypes;
    private final NetworkProviderInfo mNetworkProviderInfo;

    /**
     * Builder class for {@link KnownNetwork}.
     */
    public static final class Builder {
        @NetworkSource private int mNetworkSource = -1;
        @NetworkSource
        private int mNetworkSource = -1;
        private String mSsid;
        @SecurityType private final ArraySet<Integer> mSecurityTypes = new ArraySet<>();
        @SecurityType
        private final ArraySet<Integer> mSecurityTypes = new ArraySet<>();
        private NetworkProviderInfo mNetworkProviderInfo;

        /**
@@ -144,7 +149,8 @@ public final class KnownNetwork implements Parcelable {
        }
    }

    private static void validate(int networkSource, String ssid, Set<Integer> securityTypes,
    private static void validate(@NetworkSource int networkSource, String ssid,
            @SecurityType Set<Integer> securityTypes,
            NetworkProviderInfo networkProviderInfo) {
        if (networkSource != NETWORK_SOURCE_UNKNOWN
                && networkSource != NETWORK_SOURCE_CLOUD_SELF
+8 −0
Original line number Diff line number Diff line
@@ -120,8 +120,16 @@ public final class KnownNetworkConnectionStatus implements Parcelable {
        }
    }

    private static void validate(@ConnectionStatus int status) {
        if (status != CONNECTION_STATUS_UNKNOWN && status != CONNECTION_STATUS_SAVED
                && status != CONNECTION_STATUS_SAVE_FAILED) {
            throw new IllegalArgumentException("Illegal connection status");
        }
    }

    private KnownNetworkConnectionStatus(@ConnectionStatus int status, KnownNetwork knownNetwork,
            Bundle extras) {
        validate(status);
        mStatus = status;
        mKnownNetwork = knownNetwork;
        mExtras = extras;
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public final class NetworkProviderInfo implements Parcelable {
        }
    }

    private static void validate(int deviceType, String deviceName, String modelName,
    private static void validate(@DeviceType int deviceType, String deviceName, String modelName,
            int batteryPercentage, int connectionStrength) {
        if (deviceType != DEVICE_TYPE_UNKNOWN && deviceType != DEVICE_TYPE_PHONE
                && deviceType != DEVICE_TYPE_TABLET && deviceType != DEVICE_TYPE_LAPTOP