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

Commit 1447bab5 authored by Songchun Fan's avatar Songchun Fan Committed by Android (Google) Code Review
Browse files

Merge "[SettingsProvider] allow null values in validators"

parents f53ae985 9509bcab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,6 +34,6 @@ public final class DiscreteValueValidator implements Validator {

    @Override
    public boolean validate(@Nullable String value) {
        return ArrayUtils.contains(mValues, value);
        return value == null || ArrayUtils.contains(mValues, value);
    }
}
+0 −4
Original line number Diff line number Diff line
@@ -34,10 +34,6 @@ import java.util.Map;
 * Validators for Global settings
 */
public class GlobalSettingsValidators {
    /**
     * All settings in {@link Global.SETTINGS_TO_BACKUP} array *must* have a non-null validator,
     * otherwise they won't be restored.
     */
    public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();

    static {
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ final class InclusiveFloatRangeValidator implements Validator {

    @Override
    public boolean validate(@Nullable String value) {
        if (value == null) {
            return true;
        }
        try {
            final float floatValue = Float.parseFloat(value);
            return floatValue >= mMin && floatValue <= mMax;
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ final class InclusiveIntegerRangeValidator implements Validator {

    @Override
    public boolean validate(@Nullable String value) {
        if (value == null) {
            return true;
        }
        try {
            final int intValue = Integer.parseInt(value);
            return intValue >= mMin && intValue <= mMax;
+0 −5
Original line number Diff line number Diff line
@@ -42,11 +42,6 @@ import java.util.Map;
 * Validators for the Secure Settings.
 */
public class SecureSettingsValidators {
    /**
     * All settings in {@link Secure.SETTINGS_TO_BACKUP} and {@link
     * DeviceSpecificSettings.DEVICE_SPECIFIC_SETTINGS_TO_BACKUP} array *must* have a non-null
     * validator, otherwise they won't be restored.
     */
    public static final Map<String, Validator> VALIDATORS = new ArrayMap<>();

    static {
Loading