use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class SliceDataConverterTest method testFakeProvider_convertsFakeData.
@Test
@Config(qualifiers = "mcc999")
public void testFakeProvider_convertsFakeData() {
mSearchFeatureProvider.getSearchIndexableResources().getProviderValues().clear();
mSearchFeatureProvider.getSearchIndexableResources().getProviderValues().add(new SearchIndexableData(FakeIndexProvider.class, FakeIndexProvider.SEARCH_INDEX_DATA_PROVIDER));
doReturn(getFakeService()).when(mSliceDataConverter).getAccessibilityServiceInfoList();
List<SliceData> sliceDataList = mSliceDataConverter.getSliceData();
assertThat(sliceDataList).hasSize(2);
SliceData fakeSlice0 = sliceDataList.get(0);
SliceData fakeSlice1 = sliceDataList.get(1);
// Should not assume the order of the data list.
if (TextUtils.equals(fakeSlice0.getKey(), FAKE_KEY)) {
assertFakeSlice(fakeSlice0);
assertFakeA11ySlice(fakeSlice1);
} else {
assertFakeSlice(fakeSlice1);
assertFakeA11ySlice(fakeSlice0);
}
}
use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class SliceControllerInXmlCodeInspector method getIndexableXml.
private List<Integer> getIndexableXml() {
final List<Integer> xmlResSet = new ArrayList<>();
final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
for (SearchIndexableData bundle : bundles) {
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 queryDynamicRawData.
/**
* Gets a Cursor of dynamic Raw data similar to queryRawData. We use those data in search query
* time
*/
@Nullable
@Override
public Cursor queryDynamicRawData(String[] projection) {
final Context context = getContext();
final List<SearchIndexableRaw> rawList = new ArrayList<>();
final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(context).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
for (SearchIndexableData bundle : bundles) {
rawList.addAll(getDynamicSearchIndexableRawData(context, bundle));
// Refresh the search enabled state for indexing injection raw data
final Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
if (provider instanceof BaseSearchIndexProvider) {
refreshSearchEnabledState(context, (BaseSearchIndexProvider) provider);
}
}
rawList.addAll(getInjectionIndexableRawData(context));
final MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
for (SearchIndexableRaw raw : rawList) {
cursor.addRow(createIndexableRawColumnObjects(raw));
}
return cursor;
}
use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class SettingsSearchIndexablesProviderTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mProvider = spy(new SettingsSearchIndexablesProvider());
ProviderInfo info = new ProviderInfo();
info.exported = true;
info.grantUriPermissions = true;
info.authority = PACKAGE_NAME;
info.readPermission = Manifest.permission.READ_SEARCH_INDEXABLES;
mProvider.attachInfo(RuntimeEnvironment.application, info);
final SearchFeatureProvider featureProvider = new SearchFeatureProviderImpl();
featureProvider.getSearchIndexableResources().getProviderValues().clear();
featureProvider.getSearchIndexableResources().getProviderValues().add(new SearchIndexableData(FakeSettingsFragment.class, FakeSettingsFragment.SEARCH_INDEX_DATA_PROVIDER));
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mFakeFeatureFactory.searchFeatureProvider = featureProvider;
final ActivityInfo activityInfo = new ActivityInfo();
activityInfo.packageName = "pkg";
activityInfo.name = "class";
activityInfo.metaData = new Bundle();
activityInfo.metaData.putString(META_DATA_PREFERENCE_TITLE, "title");
final DashboardCategory category = new DashboardCategory("key");
when(mFakeFeatureFactory.dashboardFeatureProvider.getAllCategories()).thenReturn(Arrays.asList(category));
category.addTile(new ActivityTile(activityInfo, category.key));
ShadowCategoryManager.setDashboardCategory(category);
}
use of com.android.settingslib.search.SearchIndexableData in project android_packages_apps_Settings by omnirom.
the class SlicesDatabaseAccessorTest method getSliceKeys_indexesDatabase.
@Test
@Config(qualifiers = "mcc999")
public void getSliceKeys_indexesDatabase() {
// Force new indexing
Locale.setDefault(new Locale("ca"));
final SearchFeatureProvider provider = new SearchFeatureProviderImpl();
final SlicesFeatureProvider sliceProvider = new SlicesFeatureProviderImpl();
final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest();
factory.searchFeatureProvider = provider;
factory.slicesFeatureProvider = sliceProvider;
// Fake the indexable list.
provider.getSearchIndexableResources().getProviderValues().clear();
provider.getSearchIndexableResources().getProviderValues().add(new SearchIndexableData(FakeIndexProvider.class, FakeIndexProvider.SEARCH_INDEX_DATA_PROVIDER));
final SlicesDatabaseAccessor accessor = new SlicesDatabaseAccessor(mContext);
final List<Uri> keys = accessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY, true);
assertThat(keys).isNotEmpty();
}
Aggregations