| 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 ffda922ec24d691f382fd8672f41dbe3d2f51619..67bf2f24ee38a6cf562ac71894782e70a7a25feb 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
|
| @@ -40,12 +40,10 @@ import org.chromium.chrome.browser.init.EmptyBrowserParts;
|
| import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBridge;
|
| import org.chromium.chrome.browser.util.IntentUtils;
|
|
|
| -import java.text.NumberFormat;
|
| import java.util.ArrayList;
|
| import java.util.HashSet;
|
| import java.util.Iterator;
|
| import java.util.List;
|
| -import java.util.Locale;
|
| import java.util.Set;
|
|
|
| /**
|
| @@ -115,11 +113,11 @@ public class DownloadNotificationService extends Service {
|
| // activity should be pause the notification.
|
| if (tasks.size() > 0) return;
|
| }
|
| - mStopPostingProgressNotifications = true;
|
| // This funcion is called when Chrome is swiped away from the recent apps
|
| // drawer. So it doesn't catch all scenarios that chrome can get killed.
|
| // This will only help Android 4.4.2.
|
| onBrowserKilled();
|
| + mStopPostingProgressNotifications = true;
|
| }
|
|
|
| @Override
|
| @@ -231,20 +229,19 @@ public class DownloadNotificationService extends Service {
|
| boolean canDownloadWhileMetered, boolean isOfflinePage) {
|
| if (mStopPostingProgressNotifications) return;
|
| boolean indeterminate = percentage == INVALID_DOWNLOAD_PERCENTAGE;
|
| + String contentText = mContext.getResources().getString(
|
| + indeterminate ? R.string.download_notification_pending : R.string.download_started);
|
| NotificationCompat.Builder builder = buildNotification(
|
| - android.R.drawable.stat_sys_download, fileName, null);
|
| + android.R.drawable.stat_sys_download, fileName, contentText);
|
| builder.setOngoing(true).setProgress(100, percentage, indeterminate);
|
| builder.setPriority(Notification.PRIORITY_HIGH);
|
| if (!indeterminate) {
|
| - NumberFormat formatter = NumberFormat.getPercentInstance(Locale.getDefault());
|
| - String percentText = formatter.format(percentage / 100.0);
|
| String duration = formatRemainingTime(mContext, timeRemainingInMillis);
|
| - builder.setContentText(duration);
|
| if (Build.VERSION.CODENAME.equals("N")
|
| || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
| - builder.setSubText(percentText);
|
| + builder.setSubText(duration);
|
| } else {
|
| - builder.setContentInfo(percentText);
|
| + builder.setContentInfo(duration);
|
| }
|
| }
|
| int notificationId = getNotificationId(downloadGuid);
|
| @@ -305,9 +302,18 @@ public class DownloadNotificationService extends Service {
|
| notifyDownloadFailed(downloadGuid, entry.fileName);
|
| return;
|
| }
|
| + // If download is interrupted due to network disconnection, show download pending state.
|
| + if (isAutoResumable) {
|
| + notifyDownloadProgress(entry.downloadGuid, entry.fileName, INVALID_DOWNLOAD_PERCENTAGE,
|
| + 0, 0, entry.isOffTheRecord, entry.canDownloadWhileMetered,
|
| + entry.isOfflinePage());
|
| + mDownloadsInProgress.remove(downloadGuid);
|
| + return;
|
| + }
|
| + String contentText = mContext.getResources().getString(
|
| + R.string.download_notification_paused);
|
| NotificationCompat.Builder builder = buildNotification(
|
| - android.R.drawable.ic_media_pause, entry.fileName,
|
| - mContext.getResources().getString(R.string.download_notification_paused));
|
| + android.R.drawable.ic_media_pause, entry.fileName, contentText);
|
| Intent cancelIntent = buildActionIntent(
|
| ACTION_DOWNLOAD_CANCEL, entry.notificationId, entry.downloadGuid, entry.fileName,
|
| entry.isOfflinePage());
|
| @@ -328,7 +334,7 @@ public class DownloadNotificationService extends Service {
|
| // If download is not auto resumable, there is no need to keep it in SharedPreferences.
|
| // Keep off the record downloads in SharedPreferences so we can cancel it when browser is
|
| // killed.
|
| - if (!isAutoResumable && !entry.isOffTheRecord) {
|
| + if (!entry.isOffTheRecord) {
|
| removeSharedPreferenceEntry(downloadGuid);
|
| }
|
| mDownloadsInProgress.remove(downloadGuid);
|
|
|