From 62295b72b414194128b13c78f81e871afb91285a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 11 May 2016 19:53:01 +0200 Subject: [PATCH] send ACTION_INTERRUPTED when APK is canceled from queue If an APK was queued to download but had not started downloading yet, it was not able to be fully canceled because ACTION_INTERRUPTED was not sent. That meant that the UI never got updated, even though the APK was removed from the queue. #652 https://gitlab.com/fdroid/fdroidclient/issues/652 --- .../java/org/fdroid/fdroid/net/DownloaderService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java b/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java index 54d61bd41..b43a5ff53 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java +++ b/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java @@ -121,6 +121,7 @@ public class DownloaderService extends Service { Integer whatToRemove = uriString.hashCode(); if (serviceHandler.hasMessages(whatToRemove)) { serviceHandler.removeMessages(whatToRemove); + sendBroadcast(intent.getData(), Downloader.ACTION_INTERRUPTED); } else if (isActive(uriString)) { downloader.cancelDownload(); } else { @@ -218,6 +219,10 @@ public class DownloaderService extends Service { downloader = null; } + private void sendBroadcast(Uri uri, String action) { + sendBroadcast(uri, action, null, null); + } + private void sendBroadcast(Uri uri, String action, File file) { sendBroadcast(uri, action, file, null); } @@ -225,7 +230,9 @@ public class DownloaderService extends Service { private void sendBroadcast(Uri uri, String action, File file, String errorMessage) { Intent intent = new Intent(action); intent.setData(uri); - intent.putExtra(Downloader.EXTRA_DOWNLOAD_PATH, file.getAbsolutePath()); + if (file != null) { + intent.putExtra(Downloader.EXTRA_DOWNLOAD_PATH, file.getAbsolutePath()); + } if (!TextUtils.isEmpty(errorMessage)) { intent.putExtra(Downloader.EXTRA_ERROR_MESSAGE, errorMessage); }