diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-11-28 15:13:12 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-11-28 15:13:12 -0800 |
commit | e495c97a17e9387d92e369a52b1212e6f908a8de (patch) | |
tree | f3e67013dcfd7213df70dfb7eb76f7ebfe41d9ef /src/com/android/providers/downloads/DownloadNotifier.java | |
parent | 8ec8bdebaefcecb8b3e6b9f724aba7b25406db21 (diff) | |
parent | fec5f50a85e1bfc7bb4fa12d04ffa7526c79fad7 (diff) | |
download | android_packages_providers_DownloadProvider-e495c97a17e9387d92e369a52b1212e6f908a8de.tar.gz android_packages_providers_DownloadProvider-e495c97a17e9387d92e369a52b1212e6f908a8de.tar.bz2 android_packages_providers_DownloadProvider-e495c97a17e9387d92e369a52b1212e6f908a8de.zip |
Merge "Improve download remaining time calculation." into jb-mr1.1-dev
Diffstat (limited to 'src/com/android/providers/downloads/DownloadNotifier.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadNotifier.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java index f6e7a2ee..f89d2d02 100644 --- a/src/com/android/providers/downloads/DownloadNotifier.java +++ b/src/com/android/providers/downloads/DownloadNotifier.java @@ -163,23 +163,24 @@ public class DownloadNotifier { long current = 0; long total = 0; - long remainingMillis = -1; + long speed = 0; for (DownloadInfo info : cluster) { if (info.mTotalBytes != -1) { current += info.mCurrentBytes; total += info.mTotalBytes; - remainingMillis = Math.max( - handler.getRemainingMillis(info.mId), remainingMillis); + speed += handler.getCurrentSpeed(info.mId); } } if (total > 0) { final int percent = (int) ((current * 100) / total); - if (remainingMillis != -1) { + percentText = res.getString(R.string.download_percent, percent); + + if (speed > 0) { + final long remainingMillis = ((total - current) * 1000) / speed; remainingText = res.getString(R.string.download_remaining, DateUtils.formatDuration(remainingMillis)); } - percentText = res.getString(R.string.download_percent, percent); builder.setProgress(100, percent, false); } else { |