Index everything into the database and disable invalid ones
Change-Id: I7eb931009b722c10487f6212113a8993463b7bce Fixes: 34142852 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -516,10 +516,7 @@ public class DatabaseIndexingManager {
|
||||
nonIndexableKeys.addAll(resNonIndxableKeys);
|
||||
}
|
||||
|
||||
indexFromResource(sir.context, database, localeStr,
|
||||
sir.xmlResId, sir.className, sir.iconResId, sir.rank,
|
||||
sir.intentAction, sir.intentTargetPackage, sir.intentTargetClass,
|
||||
nonIndexableKeys);
|
||||
indexFromResource(database, localeStr, sir, nonIndexableKeys);
|
||||
} else {
|
||||
if (TextUtils.isEmpty(sir.className)) {
|
||||
Log.w(LOG_TAG, "Cannot index an empty Search Provider name!");
|
||||
@@ -543,20 +540,17 @@ public class DatabaseIndexingManager {
|
||||
nonIndexableKeys.addAll(providerNonIndexableKeys);
|
||||
}
|
||||
|
||||
indexFromProvider(mContext, database, localeStr, provider, sir.className,
|
||||
sir.iconResId, sir.rank, sir.enabled, nonIndexableKeys);
|
||||
indexFromProvider(database, localeStr, provider, sir, nonIndexableKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void indexFromResource(Context context, SQLiteDatabase database, String localeStr,
|
||||
int xmlResId, String fragmentName, int iconResId, int rank,
|
||||
String intentAction, String intentTargetPackage, String intentTargetClass,
|
||||
List<String> nonIndexableKeys) {
|
||||
|
||||
private void indexFromResource(SQLiteDatabase database, String localeStr,
|
||||
SearchIndexableResource sir, List<String> nonIndexableKeys) {
|
||||
final Context context = sir.context;
|
||||
XmlResourceParser parser = null;
|
||||
try {
|
||||
parser = context.getResources().getXml(xmlResId);
|
||||
parser = context.getResources().getXml(sir.xmlResId);
|
||||
|
||||
int type;
|
||||
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
|
||||
@@ -583,6 +577,13 @@ public class DatabaseIndexingManager {
|
||||
String keywords;
|
||||
String childFragment;
|
||||
ResultPayload payload;
|
||||
boolean enabled;
|
||||
final String fragmentName = sir.className;
|
||||
final int iconResId = sir.iconResId;
|
||||
final int rank = sir.rank;
|
||||
final String intentAction = sir.intentAction;
|
||||
final String intentTargetPackage = sir.intentTargetPackage;
|
||||
final String intentTargetClass = sir.intentTargetClass;
|
||||
|
||||
Map<String, PreferenceController> controllerUriMap = null;
|
||||
|
||||
@@ -593,28 +594,28 @@ public class DatabaseIndexingManager {
|
||||
|
||||
// Insert rows for the main PreferenceScreen node. Rewrite the data for removing
|
||||
// hyphens.
|
||||
if (!nonIndexableKeys.contains(key)) {
|
||||
title = XmlParserUtils.getDataTitle(context, attrs);
|
||||
summary = XmlParserUtils.getDataSummary(context, attrs);
|
||||
keywords = XmlParserUtils.getDataKeywords(context, attrs);
|
||||
|
||||
DatabaseRow.Builder builder = new DatabaseRow.Builder();
|
||||
builder.setLocale(localeStr)
|
||||
.setEntries(null)
|
||||
.setClassName(fragmentName)
|
||||
.setScreenTitle(screenTitle)
|
||||
.setIconResId(iconResId)
|
||||
.setRank(rank)
|
||||
.setIntentAction(intentAction)
|
||||
.setIntentTargetPackage(intentTargetPackage)
|
||||
.setIntentTargetClass(intentTargetClass)
|
||||
.setEnabled(true)
|
||||
.setKey(key)
|
||||
.setUserId(-1 /* default user id */);
|
||||
title = XmlParserUtils.getDataTitle(context, attrs);
|
||||
summary = XmlParserUtils.getDataSummary(context, attrs);
|
||||
keywords = XmlParserUtils.getDataKeywords(context, attrs);
|
||||
enabled = !nonIndexableKeys.contains(key);
|
||||
|
||||
updateOneRowWithFilteredData(database, builder, title, summary,
|
||||
null /* summary off */, keywords);
|
||||
}
|
||||
DatabaseRow.Builder builder = new DatabaseRow.Builder();
|
||||
builder.setLocale(localeStr)
|
||||
.setEntries(null)
|
||||
.setClassName(fragmentName)
|
||||
.setScreenTitle(screenTitle)
|
||||
.setIconResId(iconResId)
|
||||
.setRank(rank)
|
||||
.setIntentAction(intentAction)
|
||||
.setIntentTargetPackage(intentTargetPackage)
|
||||
.setIntentTargetClass(intentTargetClass)
|
||||
.setEnabled(enabled)
|
||||
.setKey(key)
|
||||
.setUserId(-1 /* default user id */);
|
||||
|
||||
updateOneRowWithFilteredData(database, builder, title, summary,
|
||||
null /* summary off */, keywords);
|
||||
|
||||
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
|
||||
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
|
||||
@@ -625,14 +626,11 @@ public class DatabaseIndexingManager {
|
||||
nodeName = parser.getName();
|
||||
|
||||
key = XmlParserUtils.getDataKey(context, attrs);
|
||||
if (nonIndexableKeys.contains(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
enabled = ! nonIndexableKeys.contains(key);
|
||||
title = XmlParserUtils.getDataTitle(context, attrs);
|
||||
keywords = XmlParserUtils.getDataKeywords(context, attrs);
|
||||
|
||||
DatabaseRow.Builder builder = new DatabaseRow.Builder();
|
||||
builder = new DatabaseRow.Builder();
|
||||
builder.setLocale(localeStr)
|
||||
.setClassName(fragmentName)
|
||||
.setScreenTitle(screenTitle)
|
||||
@@ -641,7 +639,7 @@ public class DatabaseIndexingManager {
|
||||
.setIntentAction(intentAction)
|
||||
.setIntentTargetPackage(intentTargetPackage)
|
||||
.setIntentTargetClass(intentTargetClass)
|
||||
.setEnabled(true)
|
||||
.setEnabled(enabled)
|
||||
.setKey(key)
|
||||
.setUserId(-1 /* default user id */);
|
||||
|
||||
@@ -685,16 +683,21 @@ public class DatabaseIndexingManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void indexFromProvider(Context context, SQLiteDatabase database, String localeStr,
|
||||
Indexable.SearchIndexProvider provider, String className, int iconResId, int rank,
|
||||
boolean enabled, List<String> nonIndexableKeys) {
|
||||
private void indexFromProvider(SQLiteDatabase database, String localeStr,
|
||||
Indexable.SearchIndexProvider provider, SearchIndexableResource sir,
|
||||
List<String> nonIndexableKeys) {
|
||||
|
||||
final String className = sir.className;
|
||||
final int iconResId = sir.iconResId;
|
||||
final int rank = sir.rank;
|
||||
|
||||
if (provider == null) {
|
||||
Log.w(LOG_TAG, "Cannot find provider: " + className);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<SearchIndexableRaw> rawList = provider.getRawDataToIndex(context, enabled);
|
||||
final List<SearchIndexableRaw> rawList = provider.getRawDataToIndex(mContext,
|
||||
true /* enabled */);
|
||||
|
||||
if (rawList != null) {
|
||||
|
||||
@@ -706,10 +709,7 @@ public class DatabaseIndexingManager {
|
||||
if (!raw.locale.toString().equalsIgnoreCase(localeStr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nonIndexableKeys.contains(raw.key)) {
|
||||
continue;
|
||||
}
|
||||
boolean enabled = !nonIndexableKeys.contains(raw.key);
|
||||
|
||||
DatabaseRow.Builder builder = new DatabaseRow.Builder();
|
||||
builder.setLocale(localeStr)
|
||||
@@ -721,7 +721,7 @@ public class DatabaseIndexingManager {
|
||||
.setIntentAction(raw.intentAction)
|
||||
.setIntentTargetPackage(raw.intentTargetPackage)
|
||||
.setIntentTargetClass(raw.intentTargetClass)
|
||||
.setEnabled(raw.enabled)
|
||||
.setEnabled(enabled)
|
||||
.setKey(raw.key)
|
||||
.setUserId(raw.userId);
|
||||
|
||||
@@ -731,7 +731,7 @@ public class DatabaseIndexingManager {
|
||||
}
|
||||
|
||||
final List<SearchIndexableResource> resList =
|
||||
provider.getXmlResourcesToIndex(context, enabled);
|
||||
provider.getXmlResourcesToIndex(mContext, true);
|
||||
if (resList != null) {
|
||||
final int resSize = resList.size();
|
||||
for (int i = 0; i < resSize; i++) {
|
||||
@@ -742,15 +742,10 @@ public class DatabaseIndexingManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
final int itemIconResId = (item.iconResId == 0) ? iconResId : item.iconResId;
|
||||
final int itemRank = (item.rank == 0) ? rank : item.rank;
|
||||
String itemClassName = (TextUtils.isEmpty(item.className))
|
||||
? className : item.className;
|
||||
item.iconResId = (item.iconResId == 0) ? iconResId : item.iconResId;
|
||||
item.className = (TextUtils.isEmpty(item.className)) ? className : item.className;
|
||||
|
||||
indexFromResource(context, database, localeStr,
|
||||
item.xmlResId, itemClassName, itemIconResId, itemRank,
|
||||
item.intentAction, item.intentTargetPackage,
|
||||
item.intentTargetClass, nonIndexableKeys);
|
||||
indexFromResource(database, localeStr, item, nonIndexableKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1164,4 +1159,4 @@ public class DatabaseIndexingManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user