Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1165)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java

Issue 2053523002: Fix a bug that in progress notification can change when auto resumption starts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove redundant call Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
index a049b680e2432d4f210e83b7fd83643878688971..f60d0d8d3c7814fa23f875b5f22fc0a892cccd0d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
@@ -63,6 +63,7 @@ public class DownloadNotificationService extends Service {
private final IBinder mBinder = new LocalBinder();
private final List<DownloadSharedPreferenceEntry> mDownloadSharedPreferenceEntries =
new ArrayList<DownloadSharedPreferenceEntry>();
+ private final List<String> mDownloadsInProgress = new ArrayList<String>();
private NotificationManager mNotificationManager;
private SharedPreferences mSharedPrefs;
private Context mContext;
@@ -170,6 +171,9 @@ public class DownloadNotificationService extends Service {
fileName));
}
updateNotification(notificationId, builder.build());
+ if (!mDownloadsInProgress.contains(downloadGuid)) {
+ mDownloadsInProgress.add(downloadGuid);
+ }
}
/**
@@ -191,6 +195,7 @@ public class DownloadNotificationService extends Service {
void cancelNotification(int notificaitonId, String downloadGuid) {
mNotificationManager.cancel(NOTIFICATION_NAMESPACE, notificaitonId);
removeSharedPreferenceEntry(downloadGuid);
+ mDownloadsInProgress.remove(downloadGuid);
}
/**
@@ -232,6 +237,7 @@ public class DownloadNotificationService extends Service {
if (!entry.isResumable || !isAutoResumable) {
removeSharedPreferenceEntry(downloadGuid);
}
+ mDownloadsInProgress.remove(downloadGuid);
}
/**
@@ -253,6 +259,7 @@ public class DownloadNotificationService extends Service {
}
updateNotification(notificationId, builder.build());
removeSharedPreferenceEntry(downloadGuid);
+ mDownloadsInProgress.remove(downloadGuid);
return notificationId;
}
@@ -276,6 +283,7 @@ public class DownloadNotificationService extends Service {
mContext.getResources().getString(R.string.download_notification_failed));
updateNotification(notificationId, builder.build());
removeSharedPreferenceEntry(downloadGuid);
+ mDownloadsInProgress.remove(downloadGuid);
}
/**
@@ -478,7 +486,8 @@ public class DownloadNotificationService extends Service {
}
/**
- * Resumes all pending downloads from |mDownloadSharedPreferenceEntries|.
+ * Resumes all pending downloads from |mDownloadSharedPreferenceEntries|. If a download is
+ * already in progress, do nothing.
*/
public void resumeAllPendingDownloads() {
boolean isNetworkMetered = DownloadManagerService.isActiveNetworkMetered(mContext);
@@ -488,8 +497,9 @@ public class DownloadNotificationService extends Service {
for (int i = 0; i < mDownloadSharedPreferenceEntries.size(); ++i) {
DownloadSharedPreferenceEntry entry = mDownloadSharedPreferenceEntries.get(i);
if (!entry.canDownloadWhileMetered && isNetworkMetered) continue;
- notifyDownloadProgress(entry.downloadGuid, entry.fileName, INVALID_DOWNLOAD_PERCENTAGE,
- 0, 0, true, entry.canDownloadWhileMetered);
+ if (mDownloadsInProgress.contains(entry.downloadGuid)) continue;
+ notifyDownloadProgress(entry.downloadGuid, entry.fileName,
+ INVALID_DOWNLOAD_PERCENTAGE, 0, 0, true, entry.canDownloadWhileMetered);
service.resumeDownload(entry.buildDownloadItem(), false);
}
}
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698