Loading services/autofill/java/com/android/server/autofill/AutofillManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading services/tests/servicestests/src/com/android/server/autofill/AutofillManagerServiceTest.java +24 −4 Original line number Diff line number Diff line Loading @@ -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() { Loading @@ -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() { Loading Loading @@ -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() { Loading @@ -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"); } Loading Loading
services/autofill/java/com/android/server/autofill/AutofillManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading
services/tests/servicestests/src/com/android/server/autofill/AutofillManagerServiceTest.java +24 −4 Original line number Diff line number Diff line Loading @@ -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() { Loading @@ -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() { Loading Loading @@ -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() { Loading @@ -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"); } Loading