Downloads database cursor not closed.
The DownloadsActivity, through exoplayer’s DownloadService accesses a local database. The database iterator is not closed, leading to the following StrictMode report:
2022-06-17 16:57:39.590 20399-20412/audio.funkwhale.ffa.dev D/StrictMode: StrictMode policy violation: android.os.strictmode.LeakedClosableViolation:
A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1987)
at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:345)
at android.database.CursorWindow.finalize(CursorWindow.java:181)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
at java.lang.Daemons$Daemon.run(Daemons.java:139)
at java.lang.Thread.run(Thread.java:920)
Caused by: java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:295)
at dalvik.system.CloseGuard.open(CloseGuard.java:263)
at android.database.CursorWindow.<init>(CursorWindow.java:145)
at android.database.CursorWindow.<init>(CursorWindow.java:122)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:203)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:139)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:238)
at com.google.android.exoplayer2.offline.DefaultDownloadIndex$DownloadCursorImpl.moveToPosition(DefaultDownloadIndex.java:565)
at com.google.android.exoplayer2.offline.DownloadCursor.moveToNext(DownloadCursor.java:82)
at audio.funkwhale.ffa.activities.DownloadsActivity.refreshProgress(DownloadsActivity.kt:106)
at audio.funkwhale.ffa.activities.DownloadsActivity.access$refreshProgress(DownloadsActivity.kt:22)
at audio.funkwhale.ffa.activities.DownloadsActivity$onCreate$2.invokeSuspend(DownloadsActivity.kt:47)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)