diff options
author | qqzhou <qqzhou@codeaurora.org> | 2013-12-17 14:18:55 +0800 |
---|---|---|
committer | Michael Bestas <mikeioannina@cyanogenmod.org> | 2016-01-24 03:26:04 +0200 |
commit | ecd609e7017b8a69688bbae25c17d878ea305f19 (patch) | |
tree | b7679063f5f42dc3070468483eab2da480f9f0c9 /src/com/android/providers/downloads/DownloadThread.java | |
parent | b37c8b79760ab1d82fd662f7de30de9ec3c09460 (diff) | |
download | android_packages_providers_DownloadProvider-ecd609e7017b8a69688bbae25c17d878ea305f19.tar.gz android_packages_providers_DownloadProvider-ecd609e7017b8a69688bbae25c17d878ea305f19.tar.bz2 android_packages_providers_DownloadProvider-ecd609e7017b8a69688bbae25c17d878ea305f19.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 manually 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')
-rw-r--r-- | src/com/android/providers/downloads/DownloadThread.java | 18 |
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 325b4eee..c905e25a 100644 --- a/src/com/android/providers/downloads/DownloadThread.java +++ b/src/com/android/providers/downloads/DownloadThread.java @@ -116,6 +116,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"; + /** * Local changes to {@link DownloadInfo}. These are kept local to avoid * racing with the thread that updates based on change notifications. @@ -686,6 +691,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 @@ -767,6 +777,10 @@ public class DownloadThread implements Runnable { mInfoDelta.mETag = conn.getHeaderField("ETag"); + if (mInfoDelta.mETag == null) { + mInfoDelta.mETag = QRD_ETAG; + } + mInfoDelta.writeToDatabaseOrThrow(); // Check connectivity again now that we know the total size @@ -812,7 +826,9 @@ public class DownloadThread implements Runnable { if (resuming) { if (mInfoDelta.mETag != null) { - conn.addRequestProperty("If-Match", mInfoDelta.mETag); + if (!mInfoDelta.mETag.equals(QRD_ETAG)) { + conn.addRequestProperty("If-Match", mInfoDelta.mETag); + } } conn.addRequestProperty("Range", "bytes=" + mInfoDelta.mCurrentBytes + "-"); } |