summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadThread.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/providers/downloads/DownloadThread.java')
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index e7763e4e..d8271a2b 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -195,6 +195,12 @@ http_request_loop:
request.addHeader("Range", "bytes=" + bytesSoFar + "-");
}
+ // check connectivity just before sending
+ if (!mInfo.canUseNetwork()) {
+ finalStatus = Downloads.Impl.STATUS_RUNNING_PAUSED;
+ break http_request_loop;
+ }
+
HttpResponse response;
try {
response = client.execute(request);
@@ -437,8 +443,15 @@ http_request_loop:
if (headerContentLength != null) {
contentLength = Integer.parseInt(headerContentLength);
}
+ mInfo.mTotalBytes = contentLength;
values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, contentLength);
mContext.getContentResolver().update(contentUri, values, null, null);
+ // check connectivity again now that we know the total size
+ if (!mInfo.canUseNetwork()) {
+ finalStatus = Downloads.Impl.STATUS_RUNNING_PAUSED;
+ request.abort();
+ break http_request_loop;
+ }
}
InputStream entityStream;
@@ -772,7 +785,7 @@ http_request_loop:
*/
private void notifyThroughIntent() {
Uri uri = Uri.parse(Downloads.Impl.CONTENT_URI + "/" + mInfo.mId);
- mInfo.sendIntentIfRequested(uri, mContext);
+ mInfo.sendIntentIfRequested(uri);
}
/**