Close cursor in DownloadManager.

Not closing the cursor crashes the demo app when in run in StrictMode.

PiperOrigin-RevId: 240768493
This commit is contained in:
tonihei 2019-03-28 14:23:20 +00:00 committed by Toni
parent b1a13f9651
commit bb48dc9916

View file

@ -601,8 +601,9 @@ public final class DownloadManager {
fileIOHandler.post(
() -> {
DownloadState[] loadedStates;
DownloadStateCursor cursor = null;
try {
DownloadStateCursor cursor =
cursor =
downloadIndex.getDownloadStates(
STATE_QUEUED,
STATE_STOPPED,
@ -618,6 +619,10 @@ public final class DownloadManager {
} catch (Throwable e) {
Log.e(TAG, "Download state loading failed.", e);
loadedStates = new DownloadState[0];
} finally {
if (cursor != null) {
cursor.close();
}
}
final DownloadState[] states = loadedStates;
handler.post(