mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-07 22:31:17 -04:00
Fixed: Input dispatching timed out at DownloadMonitorService.cancelDownload
.
* Moved the cancel download logic to the IO thread, ensuring that download-related tasks are performed on the IO thread while keeping the main thread free. * Also moved the functionality to the IO thread for checking the status when we receive the ACTION_DOWNLOAD_COMPLETE broadcast from DownloadManager, to determine if the download was successful or canceled. This ensures it doesn't block the main thread, as cancelDownload is currently causing a blockage.
This commit is contained in:
parent
4d3c878aee
commit
7edb65656f
@ -100,7 +100,11 @@ class DownloadMonitorService : Service() {
|
|||||||
ACTION_PAUSE -> pauseDownload(downloadId.toLong())
|
ACTION_PAUSE -> pauseDownload(downloadId.toLong())
|
||||||
ACTION_RESUME -> resumeDownload(downloadId.toLong())
|
ACTION_RESUME -> resumeDownload(downloadId.toLong())
|
||||||
ACTION_CANCEL -> cancelDownload(downloadId.toLong())
|
ACTION_CANCEL -> cancelDownload(downloadId.toLong())
|
||||||
ACTION_QUERY_DOWNLOAD_STATUS -> queryDownloadStatus(downloadId.toLong())
|
ACTION_QUERY_DOWNLOAD_STATUS -> {
|
||||||
|
updater.onNext {
|
||||||
|
queryDownloadStatus(downloadId.toLong())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
@ -569,8 +573,11 @@ class DownloadMonitorService : Service() {
|
|||||||
|
|
||||||
private fun cancelDownload(downloadId: Long) {
|
private fun cancelDownload(downloadId: Long) {
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
downloadManager.remove(downloadId)
|
updater.onNext {
|
||||||
handleCancelledDownload(downloadId)
|
// Remove the download from DownloadManager on IO thread.
|
||||||
|
downloadManager.remove(downloadId)
|
||||||
|
handleCancelledDownload(downloadId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user