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
This commit is contained in:
parent
78c0416c84
commit
62295b72b4
@ -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);
|
||||
if (file != null) {
|
||||
intent.putExtra(Downloader.EXTRA_DOWNLOAD_PATH, file.getAbsolutePath());
|
||||
}
|
||||
if (!TextUtils.isEmpty(errorMessage)) {
|
||||
intent.putExtra(Downloader.EXTRA_ERROR_MESSAGE, errorMessage);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user