Bug 1243558 - Safely close Cursor in ScreenshotObserver. r=ahunt

MozReview-Commit-ID: L2R51jt34oS

--HG--
extra : rebase_source : 21b0515c238752734706939f653e9637ce8d5e48
This commit is contained in:
Michael Comella 2016-02-22 16:26:40 -08:00
Родитель b900750aa2
Коммит cb1f901dc0
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -106,8 +106,8 @@ public class ScreenshotObserver {
@Override
public void run() {
// Find the most recent image added to the MediaStore and see if it's a screenshot.
final Cursor cursor = cr.query(uri, mediaProjections, null, null, MediaStore.Images.ImageColumns.DATE_ADDED + " DESC LIMIT 1");
try {
Cursor cursor = cr.query(uri, mediaProjections, null, null, MediaStore.Images.ImageColumns.DATE_ADDED + " DESC LIMIT 1");
if (cursor == null) {
return;
}
@ -129,9 +129,12 @@ public class ScreenshotObserver {
}
}
}
cursor.close();
} catch (Exception e) {
Log.e(LOGTAG, "Failure to process media change: ", e);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
});