Commit 837dc664 authored by Candice Sy's avatar Candice Sy Committed by Commit Bot

Undo check of download pending before attempting to pause

Undoing the reordering from
https://chromium-review.googlesource.com/969925 because this change
created bugs related to starting/stopping the foreground service.

Correct usage of notifyDownloadPaused() with isAutoResumable true
and of notifyDownloadInterrupted() is to mark downloads as pending if
they are not already paused.

Bug: 812576,825113,825163
Change-Id: I6c33e035ec501c418c93acff916b7852f2b66cbd
Reviewed-on: https://chromium-review.googlesource.com/978612Reviewed-by: default avatarJoy Ming <jming@chromium.org>
Commit-Queue: Candice Sy <cmsy@google.com>
Cr-Commit-Position: refs/heads/master@{#545595}
parent 478645b4
......@@ -885,6 +885,12 @@ public class DownloadNotificationService extends Service {
notifyDownloadFailed(id, fileName, icon);
return;
}
// Download is already paused.
if (entry != null && !entry.isAutoResumable) {
// Shutdown the service in case it was restarted unnecessarily.
stopTrackingInProgressDownload(id, true);
return;
}
boolean canDownloadWhileMetered = entry == null ? false : entry.canDownloadWhileMetered;
// If download is interrupted due to network disconnection, show download pending state.
if (isAutoResumable) {
......@@ -893,12 +899,6 @@ public class DownloadNotificationService extends Service {
stopTrackingInProgressDownload(id, true);
return;
}
// Download is already paused.
if (entry != null && !entry.isAutoResumable) {
// Shutdown the service in case it was restarted unnecessarily.
stopTrackingInProgressDownload(id, true);
return;
}
String contentText =
mContext.getResources().getString(R.string.download_notification_paused);
......
......@@ -304,6 +304,8 @@ public class DownloadNotificationService2 {
notifyDownloadFailed(id, fileName, icon);
return;
}
// If download is already paused, do nothing.
if (entry != null && !entry.isAutoResumable && !forceRebuild) return;
boolean canDownloadWhileMetered = entry == null ? false : entry.canDownloadWhileMetered;
// If download is interrupted due to network disconnection, show download pending state.
if (isAutoResumable) {
......@@ -312,8 +314,6 @@ public class DownloadNotificationService2 {
stopTrackingInProgressDownload(id);
return;
}
// If download is already paused, do nothing.
if (entry != null && !entry.isAutoResumable && !forceRebuild) return;
int notificationId = entry == null ? getNotificationId(id) : entry.notificationId;
Context context = ContextUtils.getApplicationContext();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment