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

Commit c9fd5be4 authored by Annie Meng's avatar Annie Meng Committed by android-build-merger
Browse files

Merge "Fix NPE in ComponentNameValidator" into pi-dev

am: b1059130

Change-Id: I9725217151634a66d7cd3dc0e80acb5f78f15c39
parents f08646f1 b1059130
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public class SettingsValidators {
    public static final Validator COMPONENT_NAME_VALIDATOR = new Validator() {
        @Override
        public boolean validate(String value) {
            return ComponentName.unflattenFromString(value) != null;
            return value != null && ComponentName.unflattenFromString(value) != null;
        }
    };

+6 −1
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@

package android.provider;

import static org.junit.Assert.fail;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import android.platform.test.annotations.Presubmit;
import android.provider.SettingsValidators.Validator;
@@ -62,6 +62,11 @@ public class SettingsValidatorsTest {
        assertFalse(SettingsValidators.COMPONENT_NAME_VALIDATOR.validate("rectangle"));
    }

    @Test
    public void testComponentNameValidator_onNullValue_doesNotThrow() {
        assertFalse(SettingsValidators.COMPONENT_NAME_VALIDATOR.validate(null));
    }

    @Test
    public void testLocaleValidator() {
        assertTrue(SettingsValidators.LOCALE_VALIDATOR.validate("en_US"));