Move Index provider conversion into Settings provider

Pre-patch, settings search provider would push all of its
fragments into to search via SearchIndexableResources with
an implicit contract of if the resource's xml == 0, then
it was a settings fragment with an Index provider.

One, implicit contract is bad. Two, it was messy at indexing time.

So this patch moves htat conversion into the search index provider.
Such that all of the indexables are either real Resources or Raw.

Change-Id: I39f4351c03d123bb9b45edb4df7f924cfaff2b38
Fixes: 65376542
Fixes: 37741509
Test: robotests
This commit is contained in:
Matthew Fritze
2017-11-03 12:03:59 -07:00
parent d9be860ffb
commit 55ce64dcd9
9 changed files with 278 additions and 236 deletions

View File

@@ -16,9 +16,7 @@
package com.android.settings.search;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.XmlRes;
import com.android.settings.DateTimeSettings;
import com.android.settings.DeviceInfoSettings;
@@ -88,22 +86,17 @@ import com.android.settings.wifi.ConfigureWifiSettings;
import com.android.settings.wifi.WifiSettings;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
public final class SearchIndexableResources {
@XmlRes
public static final int NO_RES_ID = 0;
@VisibleForTesting
static final HashMap<String, SearchIndexableResource> sResMap = new HashMap<>();
static final Set<Class> sProviders = new HashSet<>();
@VisibleForTesting
static void addIndex(Class<?> indexClass) {
String className = indexClass.getName();
SearchIndexableResource resource = new SearchIndexableResource(
0 /* rank */, NO_RES_ID, className, NO_RES_ID);
sResMap.put(className, resource);
static void addIndex(Class indexClass) {
sProviders.add(indexClass);
}
static {
@@ -178,15 +171,5 @@ public final class SearchIndexableResources {
private SearchIndexableResources() {
}
public static int size() {
return sResMap.size();
}
public static SearchIndexableResource getResourceByName(String className) {
return sResMap.get(className);
}
public static Collection<SearchIndexableResource> values() {
return sResMap.values();
}
public static Collection<Class> providerValues() { return sProviders;}
}