Be consistent with exceptions thrown from ContentResolverCompat.query()

On JB+, the framework query() can throw it's own exception.
This CL catches that exception and then throws it's so to maintain
consistency.

BUG: 23203532
Change-Id: I422658dbdaf1cfde7abeac1468b118907e7df705
diff --git a/v4/java/android/support/v4/content/ContentResolverCompat.java b/v4/java/android/support/v4/content/ContentResolverCompat.java
index 3b5f01c..3c7f4de 100644
--- a/v4/java/android/support/v4/content/ContentResolverCompat.java
+++ b/v4/java/android/support/v4/content/ContentResolverCompat.java
@@ -53,10 +53,21 @@
         public Cursor query(ContentResolver resolver, Uri uri, String[] projection,
                 String selection, String[] selectionArgs, String sortOrder,
                 CancellationSignal cancellationSignal) {
-            return ContentResolverCompatJellybean.query(resolver,
-                    uri, projection, selection, selectionArgs, sortOrder,
-                    cancellationSignal != null ?
-                            cancellationSignal.getCancellationSignalObject() : null);
+            try {
+                return ContentResolverCompatJellybean.query(resolver,
+                        uri, projection, selection, selectionArgs, sortOrder,
+                        cancellationSignal != null ?
+                                cancellationSignal.getCancellationSignalObject() : null);
+            } catch (Exception e) {
+                if (ContentResolverCompatJellybean.isFrameworkOperationCanceledException(e)) {
+                    // query() can throw a framework OperationCanceledException if it has been
+                    // canceled. We catch that and throw the support version instead.
+                    throw new OperationCanceledException();
+                } else {
+                    // If it's not a framework OperationCanceledException, re-throw the exception
+                    throw e;
+                }
+            }
         }
     }
 
diff --git a/v4/jellybean/android/support/v4/content/ContentResolverCompatJellybean.java b/v4/jellybean/android/support/v4/content/ContentResolverCompatJellybean.java
index ef05746..dcd695e 100644
--- a/v4/jellybean/android/support/v4/content/ContentResolverCompatJellybean.java
+++ b/v4/jellybean/android/support/v4/content/ContentResolverCompatJellybean.java
@@ -19,12 +19,18 @@
 import android.content.ContentResolver;
 import android.database.Cursor;
 import android.net.Uri;
+import android.os.OperationCanceledException;
 
 class ContentResolverCompatJellybean {
+
     public static Cursor query(ContentResolver resolver, Uri uri, String[] projection,
             String selection, String[] selectionArgs, String sortOrder,
             Object cancellationSignalObj) {
         return resolver.query(uri, projection, selection, selectionArgs, sortOrder,
                 (android.os.CancellationSignal)cancellationSignalObj);
     }
+
+    static boolean isFrameworkOperationCanceledException(Exception e) {
+        return e instanceof OperationCanceledException;
+    }
 }