Merge "Prevent empty non-Indexable keys from being added" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d51b94b042
@@ -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);
|
||||
|
@@ -426,6 +426,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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user