summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prameet Shah <phshah@google.com> 2020-06-08 16:49:33 -0700
committer Prameet Shah <phshah@google.com> 2020-06-12 15:08:23 -0700
commite2bb347ef353a77be4e2ac1d866d2238bf02ceed (patch)
tree92680151af11cd0d58c19950e1ad4b2e4db03e88
parentf3e7dfe156660afda023be4d4d49bb8ec75a3efe (diff)
Catch SqlLiteException if database query throws an exception in CalendarTracker.java
Bug: 149756348 Test: Successfully build crosshatch-eng Change-Id: I548c5c5f2f06bed2595702da88f34f1eb6495117 (cherry picked from commit aad87b9198bfa9f9fe35ca102021bf5d23a0c470)
-rw-r--r--services/core/java/com/android/server/notification/CalendarTracker.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/notification/CalendarTracker.java b/services/core/java/com/android/server/notification/CalendarTracker.java
index 3829b6580c59..cfcf6ebf9540 100644
--- a/services/core/java/com/android/server/notification/CalendarTracker.java
+++ b/services/core/java/com/android/server/notification/CalendarTracker.java
@@ -21,6 +21,7 @@ import android.content.ContentUris;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
+import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.provider.CalendarContract.Attendees;
import android.provider.CalendarContract.Calendars;
@@ -102,6 +103,8 @@ public class CalendarTracker {
while (cursor != null && cursor.moveToNext()) {
rt.add(cursor.getLong(0));
}
+ } catch (SQLiteException e) {
+ Slog.w(TAG, "error querying calendar content provider", e);
} finally {
if (cursor != null) {
cursor.close();
@@ -118,11 +121,12 @@ public class CalendarTracker {
ContentUris.appendId(uriBuilder, time);
ContentUris.appendId(uriBuilder, time + EVENT_CHECK_LOOKAHEAD);
final Uri uri = uriBuilder.build();
- final Cursor cursor = mUserContext.getContentResolver().query(uri, INSTANCE_PROJECTION,
- null, null, INSTANCE_ORDER_BY);
+ Cursor cursor = null;
final CheckEventResult result = new CheckEventResult();
result.recheckAt = time + EVENT_CHECK_LOOKAHEAD;
try {
+ cursor = mUserContext.getContentResolver().query(uri, INSTANCE_PROJECTION,
+ null, null, INSTANCE_ORDER_BY);
final ArraySet<Long> calendars = getCalendarsWithAccess();
while (cursor != null && cursor.moveToNext()) {
final long begin = cursor.getLong(0);
@@ -183,9 +187,10 @@ public class CalendarTracker {
selection = null;
selectionArgs = null;
}
- final Cursor cursor = mUserContext.getContentResolver().query(Attendees.CONTENT_URI,
- ATTENDEE_PROJECTION, selection, selectionArgs, null);
+ Cursor cursor = null;
try {
+ cursor = mUserContext.getContentResolver().query(Attendees.CONTENT_URI,
+ ATTENDEE_PROJECTION, selection, selectionArgs, null);
if (cursor == null || cursor.getCount() == 0) {
if (DEBUG) Log.d(TAG, "No attendees found");
return true;
@@ -205,6 +210,9 @@ public class CalendarTracker {
rt |= eventMeets;
}
return rt;
+ } catch (SQLiteException e) {
+ Slog.w(TAG, "error querying attendees content provider", e);
+ return false;
} finally {
if (cursor != null) {
cursor.close();