use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class SearchIndexableResourcesTest method testIndexHasWifiSettings.
@Test
public void testIndexHasWifiSettings() {
boolean hasWifi = false;
for (SearchIndexableData bundle : mSearchProvider.getSearchIndexableResources().getProviderValues()) {
if (bundle.getTargetClass().getName().equals(WifiSettings.class.getName())) {
hasWifi = true;
break;
}
}
assertThat(hasWifi).isTrue();
}
use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class SliceDataConverter method getSliceData.
/**
* @return a list of {@link SliceData} to be indexed and later referenced as a Slice.
*
* The collection works as follows:
* - Collects a list of Fragments from
* {@link FeatureFactory#getSearchFeatureProvider()}.
* - From each fragment, grab a {@link SearchIndexProvider}.
* - For each provider, collect XML resource layout and a list of
* {@link com.android.settings.core.BasePreferenceController}.
*/
public List<SliceData> getSliceData() {
List<SliceData> sliceData = new ArrayList<>();
final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
for (SearchIndexableData bundle : bundles) {
final String fragmentName = bundle.getTargetClass().getName();
final SearchIndexProvider provider = bundle.getSearchIndexProvider();
// CodeInspection test guards against the null check. Keep check in case of bad actors.
if (provider == null) {
Log.e(TAG, fragmentName + " dose not implement Search Index Provider");
continue;
}
final List<SliceData> providerSliceData = getSliceDataFromProvider(provider, fragmentName);
sliceData.addAll(providerSliceData);
}
final List<SliceData> a11ySliceData = getAccessibilitySliceData();
sliceData.addAll(a11ySliceData);
return sliceData;
}
use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class XmlControllerAttributeTest method getIndexableXml.
private Set<Integer> getIndexableXml() {
Set<Integer> xmlResSet = new HashSet<>();
Collection<SearchIndexableData> SearchIndexableDatas = mSearchProvider.getSearchIndexableResources().getProviderValues();
for (SearchIndexableData bundle : SearchIndexableDatas) {
Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
if (provider == null) {
continue;
}
List<SearchIndexableResource> resources = provider.getXmlResourcesToIndex(mContext, true);
if (resources == null) {
continue;
}
for (SearchIndexableResource resource : resources) {
// Add '0's anyway. It won't break the test.
xmlResSet.add(resource.xmlResId);
}
}
return xmlResSet;
}
use of com.android.settingslib.search.SearchIndexableData 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;
}
use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class SettingsSearchIndexablesProvider method getSearchIndexableRawFromProvider.
private List<SearchIndexableRaw> getSearchIndexableRawFromProvider(Context context) {
final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(context).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
final List<SearchIndexableRaw> rawList = new ArrayList<>();
for (SearchIndexableData bundle : bundles) {
Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
final List<SearchIndexableRaw> providerRaws = provider.getRawDataToIndex(context, true);
if (providerRaws == null) {
continue;
}
for (SearchIndexableRaw raw : providerRaws) {
// The classname and intent information comes from the PreIndexData
// This will be more clear when provider conversion is done at PreIndex time.
raw.className = bundle.getTargetClass().getName();
}
rawList.addAll(providerRaws);
}
return rawList;
}
Aggregations