Merge pull request #4689 from ByteHamster/stop-foreground-before-stop

Stop foreground in DownloadService before calling stop
This commit is contained in:
ByteHamster 2020-11-15 12:28:12 +01:00 committed by GitHub
commit 02def17f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -168,6 +168,7 @@ public class DownloadService extends Service {
startForeground(R.id.notification_downloading, notification);
syncExecutor.execute(() -> onDownloadQueued(intent));
} else if (numberOfDownloads.get() == 0) {
stopForeground(true);
stopSelf();
} else {
Log.d(TAG, "onStartCommand: Unknown intent");
@ -553,6 +554,7 @@ public class DownloadService extends Service {
if (numberOfDownloads.get() <= 0 && DownloadRequester.getInstance().hasNoDownloads()) {
Log.d(TAG, "Number of downloads is " + numberOfDownloads.get() + ", attempting shutdown");
stopForeground(true);
stopSelf();
if (notificationUpdater != null) {
notificationUpdater.run();