diff options
Diffstat (limited to 'src/com/android/providers/downloads/DownloadThread.java')
-rwxr-xr-x[-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 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 + "-"); } |