Merge "Add searchable metadata attribute for injected tiles." into udc-qpr-dev am: 5bc1e9b38f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24792152
Change-Id: Ib3583d5f3a5b7f1086936d848ca41d7921fbded7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
index d6635a1..b081c7f 100644
--- a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
+++ b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
@@ -454,7 +454,7 @@
// Skip Settings injected items because they should be indexed in the sub-pages.
return false;
}
- return true;
+ return tile.isSearchable();
}
private static Object[] createIndexableRawColumnObjects(SearchIndexableRaw raw) {
diff --git a/tests/robotests/src/com/android/settings/search/SettingsSearchIndexablesProviderTest.java b/tests/robotests/src/com/android/settings/search/SettingsSearchIndexablesProviderTest.java
index c70411c..bee2d99 100644
--- a/tests/robotests/src/com/android/settings/search/SettingsSearchIndexablesProviderTest.java
+++ b/tests/robotests/src/com/android/settings/search/SettingsSearchIndexablesProviderTest.java
@@ -1,5 +1,6 @@
package com.android.settings.search;
+import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SEARCHABLE;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_TITLE;
import static com.google.common.truth.Truth.assertThat;
@@ -207,6 +208,19 @@
assertThat(mProvider.isEligibleForIndexing(PACKAGE_NAME, activityTile)).isTrue();
}
+ @Test
+ public void isEligibleForIndexing_disabledByMetadata_shouldReturnFalse() {
+ final ActivityInfo activityInfo = new ActivityInfo();
+ activityInfo.packageName = PACKAGE_NAME;
+ activityInfo.name = "class";
+ activityInfo.metaData = new Bundle();
+ activityInfo.metaData.putBoolean(META_DATA_PREFERENCE_SEARCHABLE, false);
+ final ActivityTile activityTile = new ActivityTile(activityInfo,
+ CategoryKey.CATEGORY_CONNECT);
+
+ assertThat(mProvider.isEligibleForIndexing(PACKAGE_NAME, activityTile)).isFalse();
+ }
+
@Implements(CategoryManager.class)
public static class ShadowCategoryManager {