OSDN Git Service

Catch NullPointerException in PreIndexDataCollector.
authorDoris Ling <dling@google.com>
Thu, 21 Dec 2017 00:38:45 +0000 (16:38 -0800)
committerDoris Ling <dling@google.com>
Thu, 21 Dec 2017 00:38:45 +0000 (16:38 -0800)
Null pointer exception is thrown from ContentProviderNative when we
query the non indexable keys. Added a try-catch block to prevent it from
crashing.

Change-Id: I45c1e34bb81a4739ae2eb5dd19a08781ab7beeb1
Fix: 70900076
Test: manual

src/com/android/settings/search/indexing/PreIndexDataCollector.java

index a4e1131..63000b4 100644 (file)
@@ -287,8 +287,14 @@ public class PreIndexDataCollector {
             String[] projection) {
 
         final ContentResolver resolver = packageContext.getContentResolver();
-        final Cursor cursor = resolver.query(uri, projection, null, null, null);
         final List<String> result = new ArrayList<>();
+        Cursor cursor;
+        try {
+            cursor = resolver.query(uri, projection, null, null, null);
+        } catch (NullPointerException e) {
+            Log.e(TAG, "Exception querying the keys!", e);
+            return result;
+        }
 
         if (cursor == null) {
             Log.w(TAG, "Cannot add index data for Uri: " + uri.toString());