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

Commit c2ecfd97 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add default URL bar resource id for autofill compat mode." into pi-dev

parents cb956d25 86e9405b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ public final class AutofillManagerService extends SystemService {
    private static final char COMPAT_PACKAGE_URL_IDS_BLOCK_BEGIN = '[';
    private static final char COMPAT_PACKAGE_URL_IDS_BLOCK_END = ']';

    // TODO(b/74445943): temporary work around until P Development Preview 3 is branched
    private static final List<String> DEFAULT_BUTTONS = Arrays.asList("url_bar",
            "location_bar_edit_text");

    private final Context mContext;
    private final AutoFillUI mUi;

@@ -596,7 +600,7 @@ public final class AutofillManagerService extends SystemService {
            final List<String> urlBarIds;
            if (urlBlockIndex == -1) {
                packageName = packageBlock;
                urlBarIds = null;
                urlBarIds = DEFAULT_BUTTONS; // TODO(b/74445943): back to null
            } else {
                if (packageBlock.charAt(packageBlock.length() - 1)
                        != COMPAT_PACKAGE_URL_IDS_BLOCK_END) {
+24 −4
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import java.util.Map;

@RunWith(JUnit4.class)
public class AutofillManagerServiceTest {
    // TODO(b/74445943): temporary work around until P Development Preview 3 is branched
    private static final boolean ADDS_DEFAULT_BUTTON = true;

    @Test
    public void testGetWhitelistedCompatModePackages_null() {
@@ -40,9 +42,17 @@ public class AutofillManagerServiceTest {

    @Test
    public void testGetWhitelistedCompatModePackages_onePackageNoUrls() {
        if (ADDS_DEFAULT_BUTTON) {
            final Map<String, String[]> result =
                    getWhitelistedCompatModePackages("one_is_the_loniest_package");
            assertThat(result).hasSize(1);
            assertThat(result.get("one_is_the_loniest_package")).asList()
                    .containsExactly("url_bar", "location_bar_edit_text");
        } else {
            assertThat(getWhitelistedCompatModePackages("one_is_the_loniest_package"))
                    .containsExactly("one_is_the_loniest_package", null);
        }
    }

    @Test
    public void testGetWhitelistedCompatModePackages_onePackageMissingEndDelimiter() {
@@ -70,8 +80,13 @@ public class AutofillManagerServiceTest {
    public void testGetWhitelistedCompatModePackages_multiplePackagesOneInvalid() {
        final Map<String, String[]> result = getWhitelistedCompatModePackages("one:two[");
        assertThat(result).hasSize(1);
        if (ADDS_DEFAULT_BUTTON) {
            assertThat(result.get("one")).asList()
                    .containsExactly("url_bar", "location_bar_edit_text");
        } else {
            assertThat(result.get("one")).isNull();
        }
    }

    @Test
    public void testGetWhitelistedCompatModePackages_multiplePackagesMultipleUrls() {
@@ -79,7 +94,12 @@ public class AutofillManagerServiceTest {
                getWhitelistedCompatModePackages("p1[p1u1]:p2:p3[p3u1,p3u2]");
        assertThat(result).hasSize(3);
        assertThat(result.get("p1")).asList().containsExactly("p1u1");
        if (ADDS_DEFAULT_BUTTON) {
            assertThat(result.get("p2")).asList()
                    .containsExactly("url_bar", "location_bar_edit_text");
        } else {
            assertThat(result.get("p2")).isNull();
        }
        assertThat(result.get("p3")).asList().containsExactly("p3u1", "p3u2");
    }