summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2022-02-08 22:25:15 +0100
committerGitHub <noreply@github.com>2022-02-08 22:25:15 +0100
commita61c8567f51586d39323672d7cc9a807082cdf76 (patch)
tree8e51d64e6254f0fca5bb1ff8c729844720761a45
parentb26df9036cf6b13f41f8961d185f9eb0cfb8a27f (diff)
parent86eccb4893d35c3f923c6fd6fc7bf00d9c804ed1 (diff)
downloadantennapod-a61c8567f51586d39323672d7cc9a807082cdf76.zip
Merge pull request #5705 from ByteHamster/shutdown-download-service
Shutdown download executors properly
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java19
1 files changed, 7 insertions, 12 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
index 982800b1c..1973c626b 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
@@ -7,7 +7,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.text.TextUtils;
@@ -88,18 +87,11 @@ public class DownloadService extends Service {
private ScheduledFuture<?> downloadPostFuture;
private final ScheduledThreadPoolExecutor notificationUpdateExecutor;
private static DownloaderFactory downloaderFactory = new DefaultDownloaderFactory();
- private final IBinder binder = new LocalBinder();
private ConnectionStateMonitor connectionMonitor;
- private class LocalBinder extends Binder {
- public DownloadService getService() {
- return DownloadService.this;
- }
- }
-
@Override
public IBinder onBind(Intent intent) {
- return binder;
+ return null;
}
public DownloadService() {
@@ -264,9 +256,9 @@ public class DownloadService extends Service {
EventBus.getDefault().postSticky(DownloadEvent.refresh(Collections.emptyList()));
cancelNotificationUpdater();
- downloadHandleExecutor.shutdown();
- downloadEnqueueExecutor.shutdown();
- notificationUpdateExecutor.shutdown();
+ downloadEnqueueExecutor.shutdownNow();
+ downloadHandleExecutor.shutdownNow();
+ notificationUpdateExecutor.shutdownNow();
if (downloadPostFuture != null) {
downloadPostFuture.cancel(true);
}
@@ -401,6 +393,9 @@ public class DownloadService extends Service {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "cancelDownloadReceiver: " + intent.getAction());
+ if (!isRunning) {
+ return;
+ }
if (TextUtils.equals(intent.getAction(), ACTION_CANCEL_DOWNLOAD)) {
String url = intent.getStringExtra(EXTRA_DOWNLOAD_URL);
if (url == null) {