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.
This commit is contained in:
parent
5c4d23d2d6
commit
0967b79763
@ -226,10 +226,8 @@ public class InstallManagerService extends Service {
|
|||||||
Apk apk = ACTIVE_APKS.remove(urlString);
|
Apk apk = ACTIVE_APKS.remove(urlString);
|
||||||
ACTIVE_APPS.remove(apk.packageName);
|
ACTIVE_APPS.remove(apk.packageName);
|
||||||
unregisterDownloaderReceivers(urlString);
|
unregisterDownloaderReceivers(urlString);
|
||||||
if (AppDetails.isAppVisible(apk.packageName)) {
|
|
||||||
cancelNotification(urlString);
|
cancelNotification(urlString);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
localBroadcastManager.registerReceiver(startedReceiver,
|
localBroadcastManager.registerReceiver(startedReceiver,
|
||||||
DownloaderService.getIntentFilter(urlString, Downloader.ACTION_STARTED));
|
DownloaderService.getIntentFilter(urlString, Downloader.ACTION_STARTED));
|
||||||
|
@ -89,6 +89,7 @@ public class DownloaderService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
Utils.debugLog(TAG, "Handling download message with ID of " + msg.what);
|
||||||
handleIntent((Intent) msg.obj);
|
handleIntent((Intent) msg.obj);
|
||||||
stopSelf(msg.arg1);
|
stopSelf(msg.arg1);
|
||||||
}
|
}
|
||||||
@ -120,12 +121,13 @@ public class DownloaderService extends Service {
|
|||||||
Utils.debugLog(TAG, "Cancelling download of " + uriString);
|
Utils.debugLog(TAG, "Cancelling download of " + uriString);
|
||||||
Integer whatToRemove = uriString.hashCode();
|
Integer whatToRemove = uriString.hashCode();
|
||||||
if (serviceHandler.hasMessages(whatToRemove)) {
|
if (serviceHandler.hasMessages(whatToRemove)) {
|
||||||
|
Utils.debugLog(TAG, "Removing download with ID of " + whatToRemove + " from service handler, then sending interrupted event.");
|
||||||
serviceHandler.removeMessages(whatToRemove);
|
serviceHandler.removeMessages(whatToRemove);
|
||||||
sendBroadcast(intent.getData(), Downloader.ACTION_INTERRUPTED);
|
sendBroadcast(intent.getData(), Downloader.ACTION_INTERRUPTED);
|
||||||
} else if (isActive(uriString)) {
|
} else if (isActive(uriString)) {
|
||||||
downloader.cancelDownload();
|
downloader.cancelDownload();
|
||||||
} else {
|
} 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())) {
|
} else if (ACTION_QUEUE.equals(intent.getAction())) {
|
||||||
Message msg = serviceHandler.obtainMessage();
|
Message msg = serviceHandler.obtainMessage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user