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.java27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index 8a8a0da6..b2353e16 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -16,12 +16,10 @@
package com.android.providers.downloads;
-import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.drm.mobile1.DrmRawContent;
-import android.net.Uri;
import android.net.http.AndroidHttpClient;
import android.os.FileUtils;
import android.os.PowerManager;
@@ -85,14 +83,12 @@ public class DownloadThread extends Thread {
public int mRetryAfter = 0;
public int mRedirectCount = 0;
public String mNewUri;
- public Uri mContentUri;
public boolean mGotData = false;
public String mRequestUri;
public State(DownloadInfo info) {
mMimeType = sanitizeMimeType(info.mMimeType);
mRedirectCount = info.mRedirectCount;
- mContentUri = Uri.parse(Downloads.Impl.CONTENT_URI + "/" + info.mId);
mRequestUri = info.mUri;
mFilename = info.mFileName;
}
@@ -405,8 +401,7 @@ public class DownloadThread extends Thread {
> Constants.MIN_PROGRESS_TIME) {
ContentValues values = new ContentValues();
values.put(Downloads.Impl.COLUMN_CURRENT_BYTES, innerState.mBytesSoFar);
- mContext.getContentResolver().update(
- state.mContentUri, values, null, null);
+ mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
innerState.mBytesNotified = innerState.mBytesSoFar;
innerState.mTimeLastNotification = now;
}
@@ -450,7 +445,7 @@ public class DownloadThread extends Thread {
if (innerState.mHeaderContentLength == null) {
values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, innerState.mBytesSoFar);
}
- mContext.getContentResolver().update(state.mContentUri, values, null, null);
+ mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
boolean lengthMismatched = (innerState.mHeaderContentLength != null)
&& (innerState.mBytesSoFar != Integer.parseInt(innerState.mHeaderContentLength));
@@ -488,7 +483,7 @@ public class DownloadThread extends Thread {
logNetworkState();
ContentValues values = new ContentValues();
values.put(Downloads.Impl.COLUMN_CURRENT_BYTES, innerState.mBytesSoFar);
- mContext.getContentResolver().update(state.mContentUri, values, null, null);
+ mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
if (cannotResume(innerState)) {
Log.d(Constants.TAG, "download IOException for download " + mInfo.mId, ex);
Log.d(Constants.TAG, "can't resume interrupted download with no ETag");
@@ -572,7 +567,7 @@ public class DownloadThread extends Thread {
values.put(Downloads.Impl.COLUMN_MIME_TYPE, state.mMimeType);
}
values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, mInfo.mTotalBytes);
- mContext.getContentResolver().update(state.mContentUri, values, null, null);
+ mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
}
/**
@@ -868,7 +863,7 @@ public class DownloadThread extends Thread {
notifyThroughDatabase(
status, countRetry, retryAfter, redirectCount, gotData, filename, uri, mimeType);
if (Downloads.Impl.isStatusCompleted(status)) {
- notifyThroughIntent();
+ mInfo.sendIntentIfRequested();
}
}
@@ -892,17 +887,7 @@ public class DownloadThread extends Thread {
values.put(Constants.FAILED_CONNECTIONS, mInfo.mNumFailed + 1);
}
- mContext.getContentResolver().update(ContentUris.withAppendedId(
- Downloads.Impl.CONTENT_URI, mInfo.mId), values, null, null);
- }
-
- /**
- * Notifies the initiating app if it requested it. That way, it can know that the
- * download completed even if it's not actively watching the cursor.
- */
- private void notifyThroughIntent() {
- Uri uri = Uri.parse(Downloads.Impl.CONTENT_URI + "/" + mInfo.mId);
- mInfo.sendIntentIfRequested(uri);
+ mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
}
/**