Add default URL bar resource id for autofill compat mode.
These ids used to be defined at the manifest but now are defined on settings, so we need to provide default values until the settings are fixed. Test: atest FrameworksServicesTests:AutofillManagerServiceTest Bug: 74445943 Change-Id: I050a96d73cb9e008179865381c6abc3041e82844
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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,8 +42,16 @@ public class AutofillManagerServiceTest {
|
||||
|
||||
@Test
|
||||
public void testGetWhitelistedCompatModePackages_onePackageNoUrls() {
|
||||
assertThat(getWhitelistedCompatModePackages("one_is_the_loniest_package"))
|
||||
.containsExactly("one_is_the_loniest_package", null);
|
||||
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
|
||||
@@ -70,7 +80,12 @@ public class AutofillManagerServiceTest {
|
||||
public void testGetWhitelistedCompatModePackages_multiplePackagesOneInvalid() {
|
||||
final Map<String, String[]> result = getWhitelistedCompatModePackages("one:two[");
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get("one")).isNull();
|
||||
if (ADDS_DEFAULT_BUTTON) {
|
||||
assertThat(result.get("one")).asList()
|
||||
.containsExactly("url_bar", "location_bar_edit_text");
|
||||
} else {
|
||||
assertThat(result.get("one")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -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");
|
||||
assertThat(result.get("p2")).isNull();
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user