Merge "Catch SqlLiteException if database query throws an exception in CalendarTracker.java" into rvc-dev am: c4568caf2c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11811067

Change-Id: I89eb3c5b6413e49f2dd1ac1aea1bf3d6819ae6c3
This commit is contained in:
TreeHugger Robot
2020-06-15 17:48:28 +00:00
committed by Automerger Merge Worker

View File

@@ -21,6 +21,7 @@ import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.net.Uri; import android.net.Uri;
import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Attendees;
import android.provider.CalendarContract.Calendars; import android.provider.CalendarContract.Calendars;
@@ -102,6 +103,8 @@ public class CalendarTracker {
while (cursor != null && cursor.moveToNext()) { while (cursor != null && cursor.moveToNext()) {
rt.add(cursor.getLong(0)); rt.add(cursor.getLong(0));
} }
} catch (SQLiteException e) {
Slog.w(TAG, "error querying calendar content provider", e);
} finally { } finally {
if (cursor != null) { if (cursor != null) {
cursor.close(); cursor.close();
@@ -118,11 +121,12 @@ public class CalendarTracker {
ContentUris.appendId(uriBuilder, time); ContentUris.appendId(uriBuilder, time);
ContentUris.appendId(uriBuilder, time + EVENT_CHECK_LOOKAHEAD); ContentUris.appendId(uriBuilder, time + EVENT_CHECK_LOOKAHEAD);
final Uri uri = uriBuilder.build(); final Uri uri = uriBuilder.build();
final Cursor cursor = mUserContext.getContentResolver().query(uri, INSTANCE_PROJECTION, Cursor cursor = null;
null, null, INSTANCE_ORDER_BY);
final CheckEventResult result = new CheckEventResult(); final CheckEventResult result = new CheckEventResult();
result.recheckAt = time + EVENT_CHECK_LOOKAHEAD; result.recheckAt = time + EVENT_CHECK_LOOKAHEAD;
try { try {
cursor = mUserContext.getContentResolver().query(uri, INSTANCE_PROJECTION,
null, null, INSTANCE_ORDER_BY);
final ArraySet<Long> calendars = getCalendarsWithAccess(); final ArraySet<Long> calendars = getCalendarsWithAccess();
while (cursor != null && cursor.moveToNext()) { while (cursor != null && cursor.moveToNext()) {
final long begin = cursor.getLong(0); final long begin = cursor.getLong(0);
@@ -183,9 +187,10 @@ public class CalendarTracker {
selection = null; selection = null;
selectionArgs = null; selectionArgs = null;
} }
final Cursor cursor = mUserContext.getContentResolver().query(Attendees.CONTENT_URI, Cursor cursor = null;
ATTENDEE_PROJECTION, selection, selectionArgs, null);
try { try {
cursor = mUserContext.getContentResolver().query(Attendees.CONTENT_URI,
ATTENDEE_PROJECTION, selection, selectionArgs, null);
if (cursor == null || cursor.getCount() == 0) { if (cursor == null || cursor.getCount() == 0) {
if (DEBUG) Log.d(TAG, "No attendees found"); if (DEBUG) Log.d(TAG, "No attendees found");
return true; return true;
@@ -205,6 +210,9 @@ public class CalendarTracker {
rt |= eventMeets; rt |= eventMeets;
} }
return rt; return rt;
} catch (SQLiteException e) {
Slog.w(TAG, "error querying attendees content provider", e);
return false;
} finally { } finally {
if (cursor != null) { if (cursor != null) {
cursor.close(); cursor.close();