Remove locale checking for indexing.
Remove the the indexing check for the index data's locale to match the locale of the device. We don't require locale for indexables, and we reindex on locale change. It had introduced a bug where when locale changed, the default us-en results would not be added to the db. Change-Id: I43a4284f5c23bc51ee3efdfcabe511eac2d3317d Fixes: 66916397 Fixes: 68380443 Test: robotests
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_ID;
|
||||
import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
|
||||
import static com.android.settings.search.DatabaseResultLoader
|
||||
.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
|
||||
import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_KEY;
|
||||
import static com.android.settings.search.DatabaseResultLoader.SELECT_COLUMNS;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.CLASS_NAME;
|
||||
@@ -26,7 +27,8 @@ import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEYWORDS;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEY_REF;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON_NORMALIZED;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns
|
||||
.DATA_SUMMARY_ON_NORMALIZED;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE_NORMALIZED;
|
||||
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DOCID;
|
||||
@@ -132,7 +134,7 @@ public class DatabaseIndexingManager {
|
||||
PreIndexData indexData = getIndexDataFromProviders(providers, isFullIndex);
|
||||
|
||||
final long updateDatabaseStartTime = System.currentTimeMillis();
|
||||
updateDatabase(indexData, isFullIndex, localeStr);
|
||||
updateDatabase(indexData, isFullIndex);
|
||||
if (SettingsSearchIndexablesProvider.DEBUG) {
|
||||
final long updateDatabaseTime = System.currentTimeMillis() - updateDatabaseStartTime;
|
||||
Log.d(LOG_TAG, "performIndexing updateDatabase took time: " + updateDatabaseTime);
|
||||
@@ -197,10 +199,9 @@ public class DatabaseIndexingManager {
|
||||
* Finally, we record that the locale has been indexed.
|
||||
*
|
||||
* @param needsReindexing true the database needs to be rebuilt.
|
||||
* @param localeStr the default locale for the device.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void updateDatabase(PreIndexData preIndexData, boolean needsReindexing, String localeStr) {
|
||||
void updateDatabase(PreIndexData preIndexData, boolean needsReindexing) {
|
||||
final Map<String, Set<String>> nonIndexableKeys = preIndexData.nonIndexableKeys;
|
||||
|
||||
final SQLiteDatabase database = getWritableDatabase();
|
||||
@@ -213,7 +214,7 @@ public class DatabaseIndexingManager {
|
||||
database.beginTransaction();
|
||||
|
||||
// Convert all Pre-index data to Index data.
|
||||
List<IndexData> indexData = getIndexData(localeStr, preIndexData);
|
||||
List<IndexData> indexData = getIndexData(preIndexData);
|
||||
insertIndexData(database, indexData);
|
||||
|
||||
// Only check for non-indexable key updates after initial index.
|
||||
@@ -229,9 +230,9 @@ public class DatabaseIndexingManager {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
List<IndexData> getIndexData(String locale, PreIndexData data) {
|
||||
List<IndexData> getIndexData(PreIndexData data) {
|
||||
if (mConverter == null) {
|
||||
mConverter = new IndexDataConverter(mContext, locale);
|
||||
mConverter = new IndexDataConverter(mContext);
|
||||
}
|
||||
return mConverter.convertPreIndexDataToIndexData(data);
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ public class IndexData {
|
||||
= Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
|
||||
|
||||
private IndexData(Builder builder) {
|
||||
locale = builder.mLocale;
|
||||
locale = Locale.getDefault().toString();
|
||||
updatedTitle = normalizeHyphen(builder.mTitle);
|
||||
updatedSummaryOn = normalizeHyphen(builder.mSummaryOn);
|
||||
if (Locale.JAPAN.toString().equalsIgnoreCase(locale)) {
|
||||
@@ -158,7 +158,6 @@ public class IndexData {
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String mLocale;
|
||||
private String mTitle;
|
||||
private String mSummaryOn;
|
||||
private String mEntries;
|
||||
@@ -177,11 +176,6 @@ public class IndexData {
|
||||
private int mPayloadType;
|
||||
private ResultPayload mPayload;
|
||||
|
||||
public Builder setLocale(String locale) {
|
||||
mLocale = locale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setTitle(String title) {
|
||||
mTitle = title;
|
||||
return this;
|
||||
|
@@ -59,11 +59,8 @@ public class IndexDataConverter {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private String mLocale;
|
||||
|
||||
public IndexDataConverter(Context context, String locale) {
|
||||
public IndexDataConverter(Context context) {
|
||||
mContext = context;
|
||||
mLocale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +70,6 @@ public class IndexDataConverter {
|
||||
* {@link SearchIndexableRaw} and non-indexable keys.
|
||||
*/
|
||||
public List<IndexData> convertPreIndexDataToIndexData(PreIndexData preIndexData) {
|
||||
|
||||
final long current = System.currentTimeMillis();
|
||||
final List<SearchIndexableData> indexableData = preIndexData.dataToUpdate;
|
||||
final Map<String, Set<String>> nonIndexableKeys = preIndexData.nonIndexableKeys;
|
||||
@@ -125,18 +121,12 @@ public class IndexDataConverter {
|
||||
*/
|
||||
@Nullable
|
||||
private IndexData.Builder convertRaw(SearchIndexableRaw raw, Set<String> nonIndexableKeys) {
|
||||
// Should be the same locale as the one we are processing
|
||||
if (!raw.locale.toString().equalsIgnoreCase(mLocale)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// A row is enabled if it does not show up as an nonIndexableKey
|
||||
boolean enabled = !(nonIndexableKeys != null && nonIndexableKeys.contains(raw.key));
|
||||
|
||||
IndexData.Builder builder = new IndexData.Builder();
|
||||
builder.setTitle(raw.title)
|
||||
.setSummaryOn(raw.summaryOn)
|
||||
.setLocale(mLocale)
|
||||
.setEntries(raw.entries)
|
||||
.setKeywords(raw.keywords)
|
||||
.setClassName(raw.className)
|
||||
@@ -219,7 +209,6 @@ public class IndexDataConverter {
|
||||
headerBuilder.setTitle(headerTitle)
|
||||
.setSummaryOn(headerSummary)
|
||||
.setKeywords(headerKeywords)
|
||||
.setLocale(mLocale)
|
||||
.setClassName(fragmentName)
|
||||
.setScreenTitle(screenTitle)
|
||||
.setIntentAction(intentAction)
|
||||
@@ -253,7 +242,6 @@ public class IndexDataConverter {
|
||||
|
||||
builder = new IndexData.Builder();
|
||||
builder.setTitle(title)
|
||||
.setLocale(mLocale)
|
||||
.setKeywords(keywords)
|
||||
.setClassName(fragmentName)
|
||||
.setScreenTitle(screenTitle)
|
||||
@@ -352,11 +340,6 @@ public class IndexDataConverter {
|
||||
|
||||
if (resList != null) {
|
||||
for (SearchIndexableResource item : resList) {
|
||||
// Should be the same locale as the one we are processing
|
||||
if (!item.locale.toString().equalsIgnoreCase(mLocale)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
item.className = TextUtils.isEmpty(item.className)
|
||||
? className
|
||||
: item.className;
|
||||
|
Reference in New Issue
Block a user