summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatherine Liu <wlcl05@motorola.com>2013-02-05 16:00:50 -0600
committerJeff Sharkey <jsharkey@android.com>2013-03-08 10:09:10 -0800
commitaf909b55fe1ffa78e69cfda862fd5ebce712ac7a (patch)
tree98a378fbbd586f22fe514c176bd4df79b6d2b1ad
parentf918429d0c1927a19d688baa26a07c2c65765580 (diff)
downloadandroid_packages_providers_DownloadProvider-af909b55fe1ffa78e69cfda862fd5ebce712ac7a.tar.gz
android_packages_providers_DownloadProvider-af909b55fe1ffa78e69cfda862fd5ebce712ac7a.tar.bz2
android_packages_providers_DownloadProvider-af909b55fe1ffa78e69cfda862fd5ebce712ac7a.zip
Fix large file download failure issue
The root cause is int overflow as integer can only hold size Integer.MAX_VALUE = 0x7FFFFFFF. It is about 2G. So, when a file size is greater than 2G, it throws a "NumberFormatException", and then mark this download "unsuccessfully". The progress bar in notification for the large file downloading was not correct either. The total file size was converted from long to int value when in builder.setProgress(). Change-Id: Ib038860e26cf8cade2c423403585c207f8b8979b
-rw-r--r--src/com/android/providers/downloads/DownloadNotification.java9
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotification.java b/src/com/android/providers/downloads/DownloadNotification.java
index bbd39f60..efdc08b0 100644
--- a/src/com/android/providers/downloads/DownloadNotification.java
+++ b/src/com/android/providers/downloads/DownloadNotification.java
@@ -190,8 +190,13 @@ class DownloadNotification {
if (hasPausedText) {
builder.setContentText(item.mPausedText);
} else {
- builder.setProgress(
- (int) item.mTotalTotal, (int) item.mTotalCurrent, item.mTotalTotal == -1);
+ long max = item.mTotalTotal;
+ long progress = item.mTotalCurrent;
+ while(max > Integer.MAX_VALUE) {
+ max = max / 1024;
+ progress = progress / 1024;
+ }
+ builder.setProgress((int) max, (int) progress, item.mTotalTotal == -1);
if (hasContentText) {
builder.setContentInfo(
buildPercentageLabel(mContext, item.mTotalTotal, item.mTotalCurrent));
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index bd91eaa1..537a9ea7 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -473,7 +473,7 @@ public class DownloadThread extends Thread {
mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
boolean lengthMismatched = (innerState.mHeaderContentLength != null)
- && (state.mCurrentBytes != Integer.parseInt(innerState.mHeaderContentLength));
+ && (state.mCurrentBytes != Long.parseLong(innerState.mHeaderContentLength));
if (lengthMismatched) {
if (cannotResume(state)) {
throw new StopRequestException(Downloads.Impl.STATUS_CANNOT_RESUME,