summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java19
-rw-r--r--tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastSearchIndexableProviderTest.java1
2 files changed, 20 insertions, 0 deletions
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);
+ }
}
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastSearchIndexableProviderTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastSearchIndexableProviderTest.java
index eda18545e..7cb633cbb 100644
--- a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastSearchIndexableProviderTest.java
+++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastSearchIndexableProviderTest.java
@@ -39,6 +39,7 @@ public class CellBroadcastSearchIndexableProviderTest extends CellBroadcastTest
super.setUp(getClass().getSimpleName());
mSearchIndexableProvider = spy(new CellBroadcastSearchIndexableProvider());
doReturn(mContext).when(mSearchIndexableProvider).getContextMethod();
+ doReturn(false).when(mSearchIndexableProvider).isAutomotive();
doReturn("testPackageName").when(mContext).getPackageName();
doReturn(mResources).when(mSearchIndexableProvider).getResourcesMethod();
doReturn("testString").when(mResources).getString(anyInt());