From 0967b797631df270b2e9412162b201daeecc508e Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Thu, 12 May 2016 15:04:41 +1000 Subject: [PATCH] Remove notification correctly upon cancellation of download. The check was set up to only cancel when the `AppDetails` for that app was shown. This is the correct behaviour for the 'complete' event, but not the cancel. The cancel event should always result in the relevant notification being removed. --- .../org/fdroid/fdroid/installer/InstallManagerService.java | 4 +--- .../main/java/org/fdroid/fdroid/net/DownloaderService.java | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java b/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java index f9fb4e4a1..c6a5e2272 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java @@ -226,9 +226,7 @@ public class InstallManagerService extends Service { Apk apk = ACTIVE_APKS.remove(urlString); ACTIVE_APPS.remove(apk.packageName); unregisterDownloaderReceivers(urlString); - if (AppDetails.isAppVisible(apk.packageName)) { - cancelNotification(urlString); - } + cancelNotification(urlString); } }; localBroadcastManager.registerReceiver(startedReceiver, 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 7e5961d95..a85d311ab 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java +++ b/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java @@ -89,6 +89,7 @@ public class DownloaderService extends Service { @Override public void handleMessage(Message msg) { + Utils.debugLog(TAG, "Handling download message with ID of " + msg.what); handleIntent((Intent) msg.obj); stopSelf(msg.arg1); } @@ -120,12 +121,13 @@ public class DownloaderService extends Service { Utils.debugLog(TAG, "Cancelling download of " + uriString); Integer whatToRemove = uriString.hashCode(); if (serviceHandler.hasMessages(whatToRemove)) { + Utils.debugLog(TAG, "Removing download with ID of " + whatToRemove + " from service handler, then sending interrupted event."); serviceHandler.removeMessages(whatToRemove); sendBroadcast(intent.getData(), Downloader.ACTION_INTERRUPTED); } else if (isActive(uriString)) { downloader.cancelDownload(); } else { - Log.e(TAG, "ACTION_CANCEL called on something not queued or running"); + Log.e(TAG, "ACTION_CANCEL called on something not queued or running (expected to find message with ID of " + whatToRemove + " in queue)."); } } else if (ACTION_QUEUE.equals(intent.getAction())) { Message msg = serviceHandler.obtainMessage();