use of com.android.settingslib.search.Indexable in project android_packages_apps_Settings by omnirom.
the class SettingsSearchIndexablesProvider method getNonIndexableKeysFromProvider.
private List<String> getNonIndexableKeysFromProvider(Context context) {
final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(context).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
final List<String> nonIndexableKeys = new ArrayList<>();
for (SearchIndexableData bundle : bundles) {
final long startTime = System.currentTimeMillis();
Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
List<String> providerNonIndexableKeys;
try {
providerNonIndexableKeys = provider.getNonIndexableKeys(context);
} catch (Exception e) {
// non-indexable keys, but we can still find specific crashes in development.
if (System.getProperty(SYSPROP_CRASH_ON_ERROR) != null) {
throw new RuntimeException(e);
}
Log.e(TAG, "Error trying to get non-indexable keys from: " + bundle.getTargetClass().getName(), e);
continue;
}
if (providerNonIndexableKeys == null || providerNonIndexableKeys.isEmpty()) {
if (DEBUG) {
final long totalTime = System.currentTimeMillis() - startTime;
Log.d(TAG, "No indexable, total time " + totalTime);
}
continue;
}
if (providerNonIndexableKeys.removeAll(INVALID_KEYS)) {
Log.v(TAG, provider + " tried to add an empty non-indexable key");
}
if (DEBUG) {
final long totalTime = System.currentTimeMillis() - startTime;
Log.d(TAG, "Non-indexables " + providerNonIndexableKeys.size() + ", total time " + totalTime);
}
nonIndexableKeys.addAll(providerNonIndexableKeys);
}
return nonIndexableKeys;
}
Aggregations