Merge "Prevent empty non-Indexable keys from being added" into oc-dev am: d51b94b042

am: 68824ba600

Change-Id: I0e8d2965c10947db09832ee7dfd4d1a4bc8aaa17
This commit is contained in:
Matthew Fritze
2017-05-02 19:45:09 +00:00
committed by android-build-merger
4 changed files with 51 additions and 7 deletions

View File

@@ -26,6 +26,7 @@ import android.util.Log;
import com.android.settings.search2.DatabaseIndexingUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -102,12 +103,21 @@ public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
}
List<String> providerNonIndexableKeys = provider.getNonIndexableKeys(context);
if (providerNonIndexableKeys != null && providerNonIndexableKeys.size() > 0) {
values.addAll(providerNonIndexableKeys);
if (providerNonIndexableKeys == null || providerNonIndexableKeys.isEmpty()) {
continue;
}
if (providerNonIndexableKeys.removeAll(Collections.singleton(null))
|| providerNonIndexableKeys.removeAll(Collections.singleton(""))) {
Log.v(TAG, clazz.getName() + " tried to add an empty non-indexable key");
}
values.addAll(providerNonIndexableKeys);
}
for (String nik : values) {
final Object[] ref = new Object[NON_INDEXABLES_KEYS_COLUMNS.length];
ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] = nik;
cursor.addRow(ref);

View File

@@ -428,6 +428,13 @@ public class DatabaseIndexingManager {
if (count > 0) {
while (cursor.moveToNext()) {
final String key = cursor.getString(COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE);
if (TextUtils.isEmpty(key) && Log.isLoggable(LOG_TAG, Log.VERBOSE)) {
Log.v(LOG_TAG, "Empty non-indexable key from: "
+ packageContext.getPackageName());
continue;
}
result.add(key);
}
}