Commit bb48dc99 by tonihei Committed by Toni

Close cursor in DownloadManager.

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

PiperOrigin-RevId: 240768493
parent b1a13f96
...@@ -601,8 +601,9 @@ public final class DownloadManager { ...@@ -601,8 +601,9 @@ public final class DownloadManager {
fileIOHandler.post( fileIOHandler.post(
() -> { () -> {
DownloadState[] loadedStates; DownloadState[] loadedStates;
DownloadStateCursor cursor = null;
try { try {
DownloadStateCursor cursor = cursor =
downloadIndex.getDownloadStates( downloadIndex.getDownloadStates(
STATE_QUEUED, STATE_QUEUED,
STATE_STOPPED, STATE_STOPPED,
...@@ -618,6 +619,10 @@ public final class DownloadManager { ...@@ -618,6 +619,10 @@ public final class DownloadManager {
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Download state loading failed.", e); Log.e(TAG, "Download state loading failed.", e);
loadedStates = new DownloadState[0]; loadedStates = new DownloadState[0];
} finally {
if (cursor != null) {
cursor.close();
}
} }
final DownloadState[] states = loadedStates; final DownloadState[] states = loadedStates;
handler.post( handler.post(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment