Merge "Merge "Merge "Merge "Merge "Make CTS test testQuery more flexible" into marshmallow-cts-dev am: 9990dedab5" into nougat-cts-dev am: 625c8ca8e9" into nougat-mr1-cts-dev am: e89422ac54" into oreo-cts-dev am: 628ef43532" into oreo-mr1-cts-dev
am: 0366056a0e

Change-Id: I41ae73e191436548bdd33d9626605e54943b35a5
diff --git a/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java b/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
index e771461..5cfd532 100644
--- a/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
@@ -17,14 +17,13 @@
 package android.content.cts;
 
 import android.database.Cursor;
+import android.database.CursorWindowAllocationException;
 import android.database.sqlite.SQLiteException;
 import android.net.Uri;
 import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 import android.util.Log;
 
-import java.io.IOException;
-
 /**
  * Test {@link CursorWindowContentProvider} .
  */
@@ -32,11 +31,20 @@
 public class ContentProviderCursorWindowTest extends AndroidTestCase {
     private static final String TAG = "ContentProviderCursorWindowTest";
 
-    public void testQuery() throws IOException {
-        Cursor cursor = getContext().getContentResolver().query(
-                Uri.parse("content://cursorwindow.provider/hello"),
-                null, null, null, null
-        );
+    public void testQuery() {
+        // First check if the system has a patch for enforcing protected Parcel data
+        Cursor cursor;
+        try {
+            cursor = getContext().getContentResolver().query(
+                    Uri.parse("content://cursorwindow.provider/hello"),
+                    null, null, null, null);
+        } catch (CursorWindowAllocationException expected) {
+            Log.i(TAG, "Expected exception: " + expected);
+            return;
+        }
+
+        // If the system has no patch for protected Parcel data,
+        // it should still fail while reading from the cursor
         try {
             cursor.moveToFirst();