Use the private Download Manager APIs.
This boils down to using Downloads.Impl instead of Downloads
The APIs that were being used so far are going to disappear
to be replaced by a new set of APIs, but in order for the browser
to be able to continue using the old APIs a new copy of those APIs
was created "on the side" so that the browser doesn't need to
change much.
Bug: 2245521
Change-Id: I33c526331cce006710b1f934a4aeb64cdb95d62e
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 8795594..9b6fb71 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2850,19 +2850,20 @@
String cookies = CookieManager.getInstance().getCookie(url);
ContentValues values = new ContentValues();
- values.put(Downloads.COLUMN_URI, uri.toString());
- values.put(Downloads.COLUMN_COOKIE_DATA, cookies);
- values.put(Downloads.COLUMN_USER_AGENT, userAgent);
- values.put(Downloads.COLUMN_NOTIFICATION_PACKAGE,
+ values.put(Downloads.Impl.COLUMN_URI, uri.toString());
+ values.put(Downloads.Impl.COLUMN_COOKIE_DATA, cookies);
+ values.put(Downloads.Impl.COLUMN_USER_AGENT, userAgent);
+ values.put(Downloads.Impl.COLUMN_NOTIFICATION_PACKAGE,
getPackageName());
- values.put(Downloads.COLUMN_NOTIFICATION_CLASS,
+ values.put(Downloads.Impl.COLUMN_NOTIFICATION_CLASS,
BrowserDownloadPage.class.getCanonicalName());
- values.put(Downloads.COLUMN_VISIBILITY, Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
- values.put(Downloads.COLUMN_MIME_TYPE, mimetype);
- values.put(Downloads.COLUMN_FILE_NAME_HINT, filename);
- values.put(Downloads.COLUMN_DESCRIPTION, uri.getHost());
+ values.put(Downloads.Impl.COLUMN_VISIBILITY,
+ Downloads.Impl.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
+ values.put(Downloads.Impl.COLUMN_MIME_TYPE, mimetype);
+ values.put(Downloads.Impl.COLUMN_FILE_NAME_HINT, filename);
+ values.put(Downloads.Impl.COLUMN_DESCRIPTION, uri.getHost());
if (contentLength > 0) {
- values.put(Downloads.COLUMN_TOTAL_BYTES, contentLength);
+ values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, contentLength);
}
if (mimetype == null) {
// We must have long pressed on a link or image to download it. We
@@ -2870,7 +2871,7 @@
new FetchUrlMimeType(this).execute(values);
} else {
final Uri contentUri =
- getContentResolver().insert(Downloads.CONTENT_URI, values);
+ getContentResolver().insert(Downloads.Impl.CONTENT_URI, values);
viewDownloads(contentUri);
}