summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/search
diff options
context:
space:
mode:
authorYanting Yang <yantingyang@google.com>2020-03-13 21:47:06 +0800
committerYanting Yang <yantingyang@google.com>2020-03-17 17:55:49 +0800
commit298a7fe2e53124297b85128d47443b16f8352d55 (patch)
treef8de196d9b1bdbd220406dbff6741fafc7389e3d /src/com/android/settings/search
parent3a18ee5c79fa0913aa5b87aa6b16e93d81f34371 (diff)
downloadpackages_apps_Settings-298a7fe2e53124297b85128d47443b16f8352d55.tar.gz
packages_apps_Settings-298a7fe2e53124297b85128d47443b16f8352d55.tar.bz2
packages_apps_Settings-298a7fe2e53124297b85128d47443b16f8352d55.zip
Remove the index of the homepage category tiles
Do not index the tiles of homepage category since we would like to index their target activity for search. Fixes: 151418948 Test: visual Change-Id: I693534de006b4dbcaf192858e6f7d031bad78fef
Diffstat (limited to 'src/com/android/settings/search')
-rw-r--r--src/com/android/settings/search/SettingsSearchIndexablesProvider.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
index 237e58f526..bb3c76264e 100644
--- a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
+++ b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
@@ -61,12 +61,14 @@ import android.util.Log;
import androidx.annotation.Nullable;
import androidx.slice.SliceViewManager;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.slices.SettingsSliceProvider;
import com.android.settingslib.drawer.ActivityTile;
+import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.search.Indexable;
@@ -379,9 +381,7 @@ public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
final String currentPackageName = context.getPackageName();
for (DashboardCategory category : dashboardFeatureProvider.getAllCategories()) {
for (Tile tile : category.getTiles()) {
- if (currentPackageName.equals(tile.getPackageName())
- && tile instanceof ActivityTile) {
- // Skip Settings injected items because they should be indexed in the sub-pages.
+ if (!isEligibleForIndexing(currentPackageName, tile)) {
continue;
}
final SearchIndexableRaw raw = new SearchIndexableRaw(context);
@@ -402,6 +402,20 @@ public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
return rawList;
}
+ @VisibleForTesting
+ boolean isEligibleForIndexing(String packageName, Tile tile) {
+ if (TextUtils.equals(packageName, tile.getPackageName())
+ && tile instanceof ActivityTile) {
+ // Skip Settings injected items because they should be indexed in the sub-pages.
+ return false;
+ }
+ if (TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
+ // Skip homepage injected items since we would like to index their target activity.
+ return false;
+ }
+ return true;
+ }
+
private static Object[] createIndexableRawColumnObjects(SearchIndexableRaw raw) {
final Object[] ref = new Object[INDEXABLES_RAW_COLUMNS.length];
ref[COLUMN_INDEX_RAW_TITLE] = raw.title;