summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadThread.java
diff options
context:
space:
mode:
authorqqzhou <qqzhou@codeaurora.org>2013-12-17 14:18:55 +0800
committerSteve Kondik <shade@chemlab.org>2014-05-03 23:42:37 +0000
commitded2da137ce7c2c71ded2e6d163217ef95267ebb (patch)
tree01be38f32387964cc71b45efb5897bfc6ba7edcf /src/com/android/providers/downloads/DownloadThread.java
parent341aed6f2793c65874117b928a95947eb3b4b513 (diff)
downloadandroid_packages_providers_DownloadProvider-ded2da137ce7c2c71ded2e6d163217ef95267ebb.tar.gz
android_packages_providers_DownloadProvider-ded2da137ce7c2c71ded2e6d163217ef95267ebb.tar.bz2
android_packages_providers_DownloadProvider-ded2da137ce7c2c71ded2e6d163217ef95267ebb.zip
DownloadProvider: add to support pause/resume download by manual
This feature contains below points: 1. add to pause running download by manual. 2. add to resume manuallly paused download by manual. 3. add to show proper contents in notification and download-list for manually paused status. 4. add to support download breakpoint continuing when HTTP server doesn't contain etag in response header. Android baseline only supports this when etag is not null. 5. add to show proper contents in notification and download-list for status of waiting-for-network. Change-Id: I433cdee2de8b3add0248bbb0a9d02f8da4e5bb38
Diffstat (limited to 'src/com/android/providers/downloads/DownloadThread.java')
-rwxr-xr-x[-rw-r--r--]src/com/android/providers/downloads/DownloadThread.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index 93f8d650..9d5274c4 100644..100755
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -92,6 +92,11 @@ public class DownloadThread implements Runnable {
private volatile boolean mPolicyDirty;
+ // Add for carrier feature - download breakpoint continuing.
+ // Support continuing download after the download is broken
+ // although HTTP Server doesn't contain etag in its response.
+ private final static String QRD_ETAG = "qrd_magic_etag";
+
public DownloadThread(Context context, SystemFacade systemFacade, DownloadInfo info,
StorageManager storageManager, DownloadNotifier notifier) {
mContext = context;
@@ -522,6 +527,11 @@ public class DownloadThread implements Runnable {
if (mInfo.mStatus == Downloads.Impl.STATUS_CANCELED || mInfo.mDeleted) {
throw new StopRequestException(Downloads.Impl.STATUS_CANCELED, "download canceled");
}
+
+ if (mInfo.mStatus == Downloads.Impl.STATUS_PAUSED_BY_MANUAL) {
+ // user pauses the download by manual, here send exception and stop data transfer.
+ throw new StopRequestException(Downloads.Impl.STATUS_PAUSED_BY_MANUAL, "download paused by manual");
+ }
}
// if policy has been changed, trigger connectivity check
@@ -711,6 +721,10 @@ public class DownloadThread implements Runnable {
state.mHeaderETag = conn.getHeaderField("ETag");
+ if (state.mHeaderETag == null) {
+ state.mHeaderETag = QRD_ETAG;
+ }
+
final String transferEncoding = conn.getHeaderField("Transfer-Encoding");
if (transferEncoding == null) {
state.mContentLength = getHeaderFieldLong(conn, "Content-Length", -1);
@@ -831,7 +845,9 @@ public class DownloadThread implements Runnable {
if (state.mContinuingDownload) {
if (state.mHeaderETag != null) {
- conn.addRequestProperty("If-Match", state.mHeaderETag);
+ if (!state.mHeaderETag.equals(QRD_ETAG)) {
+ conn.addRequestProperty("If-Match", state.mHeaderETag);
+ }
}
conn.addRequestProperty("Range", "bytes=" + state.mCurrentBytes + "-");
}