Instantiate pref controllers from xml if it's defined.

- If a <preference> tag also defines a controller, we will try to
  instantiate it before displaying the UI. The same logic is shared by
  BaseSearchIndexProvider so it also drives search suppression.

- If user also defines a list of controllers programatically, the
  programatically created ones takes precedence.

Bug: 73668763
Test: WIP
Change-Id: I7aecec270bcd3af261e012ef1f6995d2a523cfa1
This commit is contained in:
Fan Zhang
2018-02-21 15:22:25 -08:00
parent fc520ee38a
commit 917f101899
28 changed files with 496 additions and 267 deletions

View File

@@ -77,8 +77,7 @@ public class DatabaseIndexingUtils {
* @return A map between {@link Uri}s and {@link PreferenceControllerMixin}s to get the payload
* types for Settings.
*/
public static Map<String, ResultPayload> getPayloadKeyMap(
String className, Context context) {
public static Map<String, ResultPayload> getPayloadKeyMap(String className, Context context) {
ArrayMap<String, ResultPayload> map = new ArrayMap<>();
if (context == null) {
return map;
@@ -96,8 +95,8 @@ public class DatabaseIndexingUtils {
// SEARCH_INDEX_DATA_PROVIDER field
final Indexable.SearchIndexProvider provider = getSearchIndexProvider(clazz);
List<AbstractPreferenceController> controllers =
provider.getPreferenceControllers(context);
final List<AbstractPreferenceController> controllers =
provider.getAllPreferenceControllers(context);
if (controllers == null) {
return map;