Eliminate duplicate keys in pref xmls.

- Remove additional_system_update pref device_info page, we don't need
  it.
- Update keys in xml and Preference controller, and search index
  provider.
- Clean up in ScreenZoomPreference, it's anti-pattern to set fragment in
  constructor.
- Whitelist 2 that are super hard to remove.

Change-Id: Ibab6e2cb074513042a2ae007d9085aa64046eec8
Fixes: 67852637
Test: uniquePreferenceTest
This commit is contained in:
Fan Zhang
2017-10-27 13:33:48 -07:00
parent 34f7b5af59
commit 57ef92a810
20 changed files with 108 additions and 223 deletions

View File

@@ -54,10 +54,19 @@ public class UniquePreferenceTest {
private static final String TAG = "UniquePreferenceTest";
private static final List<String> SUPPORTED_PREF_TYPES = Arrays.asList(
"Preference", "PreferenceCategory", "PreferenceScreen");
private static final List<String> WHITELISTED_DUPLICATE_KEYS = Arrays.asList(
"owner_info_settings", // Lock screen message in security - multiple xml files
// contain this because security page is constructed by
// combining small xml chunks. Eventually the page
// should be formed as one single xml and this entry
// should be removed.
"dashboard_tile_placeholder" // This is the placeholder pref for injecting dynamic
// tiles.
);
private Context mContext;
@Before
public void setUp() {
mContext = InstrumentationRegistry.getTargetContext();
@@ -148,7 +157,7 @@ public class UniquePreferenceTest {
nullKeyClasses.add(page.className);
continue;
}
if (uniqueKeys.contains(key)) {
if (uniqueKeys.contains(key) && !WHITELISTED_DUPLICATE_KEYS.contains(key)) {
Log.e(TAG, "Every preference key must unique; found " + nodeName
+ " in " + page.className
+ " at " + parser.getPositionDescription());