From 5c63453d6d27b68636d67069547d1eab6e1a1cc2 Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Mon, 15 Jun 2020 14:10:46 -0700 Subject: Disable search indexing on auto Android Automotive doesn't currently use this feature so it should not appear in our settings search results Bug: 156388829 Test: manual - gcar_hl_emu_x86 & sdk_gphone_x86 Change-Id: Icd93a961e3661f4865590a9752368ed6eaa8f245 --- .../CellBroadcastSearchIndexableProvider.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java index 3d56f7b05..16dbc2649 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java @@ -38,6 +38,7 @@ import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLU import android.annotation.Nullable; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.content.res.Resources; import android.database.Cursor; import android.database.MatrixCursor; @@ -108,6 +109,10 @@ public class CellBroadcastSearchIndexableProvider extends SearchIndexablesProvid @Override public Cursor queryXmlResources(String[] projection) { + if (isAutomotive()) { + return null; + } + MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS); final int count = INDEXABLE_RES.length; for (int n = 0; n < count; n++) { @@ -126,6 +131,10 @@ public class CellBroadcastSearchIndexableProvider extends SearchIndexablesProvid @Override public Cursor queryRawData(String[] projection) { + if (isAutomotive()) { + return null; + } + MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS); final Resources res = getResourcesMethod(); @@ -255,4 +264,14 @@ public class CellBroadcastSearchIndexableProvider extends SearchIndexablesProvid return cursor; } + + /** + * Whether or not this is an Android Automotive platform. + * @return true if the current platform is automotive + */ + @VisibleForTesting + public boolean isAutomotive() { + return getContextMethod().getPackageManager().hasSystemFeature( + PackageManager.FEATURE_AUTOMOTIVE); + } } -- cgit v1.2.3