Search in sources :

Example 1 with Indexable

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;
}
Also used : SearchIndexableData(com.android.settingslib.search.SearchIndexableData) ArrayList(java.util.ArrayList) Indexable(com.android.settingslib.search.Indexable)

Aggregations

Indexable (com.android.settingslib.search.Indexable)1 SearchIndexableData (com.android.settingslib.search.SearchIndexableData)1 ArrayList (java.util.ArrayList)1