Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not remove downloads on main thread
Removing a download involves on disk reading/writing operations. Those are blocking operations that should not happen in the main thread. Use the recently added disk executor to carry on the task. This fixes this report: D StrictMode policy violation; ~duration=102 ms: android.os.strictmode.DiskReadViolation at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1659) at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74) at libcore.io.ForwardingOs.access(ForwardingOs.java:131) at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:7795) at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:281) at java.io.File.exists(File.java:813) at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:751) at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:742) at android.app.ContextImpl.getFilesDir(ContextImpl.java:787) at com.android.providers.downloads.Helpers.isFilenameValid(Helpers.java:665) at com.android.providers.downloads.Helpers.isFilenameValid(Helpers.java:527) at com.android.providers.downloads.DownloadProvider.delete(DownloadProvider.java:1629) at android.content.ContentProvider.delete(ContentProvider.java:1785) at android.content.ContentProvider$Transport.delete(ContentProvider.java:430) at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:215) at android.os.Binder.execTransactInternal(Binder.java:1179) at android.os.Binder.execTransact(Binder.java:1143) at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:2497) at android.os.Parcel.readExceptionCode(Parcel.java:2371) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:139) at android.content.ContentProviderProxy.delete(ContentProviderNative.java:629) at android.content.ContentResolver.delete(ContentResolver.java:2333) at android.content.ContentResolver.delete(ContentResolver.java:2299) at android.app.DownloadManager.markRowDeleted(DownloadManager.java:1138) at android.app.DownloadManager.remove(DownloadManager.java:1150) at com.igalia.wolvic.downloads.DownloadsManager.removeDownload(DownloadsManager.java:250) at com.igalia.wolvic.utils.EnvironmentsManager$1.onUnzipFinish(EnvironmentsManager.java:193) at com.igalia.wolvic.utils.zip.UnzipResultReceiver.lambda$onReceiveResult$0(UnzipResultReceiver.java:59) at com.igalia.wolvic.utils.zip.UnzipResultReceiver$$ExternalSyntheticLambda0.accept(D8$$SyntheticClass:0) at java.util.ArrayList.forEach(ArrayList.java:1262) at com.igalia.wolvic.utils.zip.UnzipResultReceiver.onReceiveResult(UnzipResultReceiver.java:50) at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:50) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:214) at android.os.Looper.loop(Looper.java:304) at android.app.ActivityThread.main(ActivityThread.java:7918) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1010)
- Loading branch information