Catch NullPointerException in PreIndexDataCollector.

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
This commit is contained in:
Doris Ling
2017-12-20 16:38:45 -08:00
parent 79f4be2e5a
commit 559ac8a72a

View File

@@ -287,8 +287,14 @@ public class PreIndexDataCollector {
String[] projection) { String[] projection) {
final ContentResolver resolver = packageContext.getContentResolver(); final ContentResolver resolver = packageContext.getContentResolver();
final Cursor cursor = resolver.query(uri, projection, null, null, null);
final List<String> result = new ArrayList<>(); 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) { if (cursor == null) {
Log.w(TAG, "Cannot add index data for Uri: " + uri.toString()); Log.w(TAG, "Cannot add index data for Uri: " + uri.toString());