summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/Helpers.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-12-06 15:54:44 -0800
committerJeff Sharkey <jsharkey@android.com>2012-12-13 15:42:32 -0800
commit5cff4ecb10e89e4fb39cd9e39b8753a31efbe3cc (patch)
tree9713a0f3b22fb5e025847acde2accba0a8a3b3fe /src/com/android/providers/downloads/Helpers.java
parent1244a63f799ab689a2d7d94415133be26580ae70 (diff)
downloadandroid_packages_providers_DownloadProvider-5cff4ecb10e89e4fb39cd9e39b8753a31efbe3cc.tar.gz
android_packages_providers_DownloadProvider-5cff4ecb10e89e4fb39cd9e39b8753a31efbe3cc.tar.bz2
android_packages_providers_DownloadProvider-5cff4ecb10e89e4fb39cd9e39b8753a31efbe3cc.zip
Cleaner I/O.
This cleans up writing of downloaded data by always writing through OutputStream interface, which applies DRM if needed. Hands I/O streams along with method calls to give clearer chain of ownership. Only retry writes once after verifying free space. Remove checkCanHandleDownload() check, since most downloads are now using public API. Release DrmManagerClient sessions when finished. Change-Id: I49e479089a8218690b556d31ec65a030930ad368
Diffstat (limited to 'src/com/android/providers/downloads/Helpers.java')
-rw-r--r--src/com/android/providers/downloads/Helpers.java42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java
index 484c9256..225b8d49 100644
--- a/src/com/android/providers/downloads/Helpers.java
+++ b/src/com/android/providers/downloads/Helpers.java
@@ -81,7 +81,6 @@ public class Helpers {
if (contentLength < 0) {
contentLength = 0;
}
- checkCanHandleDownload(context, mimeType, destination, isPublicApi);
String path;
File base = null;
if (destination == Downloads.Impl.DESTINATION_FILE_URI) {
@@ -136,47 +135,6 @@ public class Helpers {
return chooseUniqueFilename(destination, filename, extension, recoveryDir);
}
- private static void checkCanHandleDownload(Context context, String mimeType, int destination,
- boolean isPublicApi) throws StopRequestException {
- if (isPublicApi) {
- return;
- }
-
- if (destination == Downloads.Impl.DESTINATION_EXTERNAL
- || destination == Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE) {
- if (mimeType == null) {
- throw new StopRequestException(Downloads.Impl.STATUS_NOT_ACCEPTABLE,
- "external download with no mime type not allowed");
- }
- if (!DownloadDrmHelper.isDrmMimeType(context, mimeType)) {
- // Check to see if we are allowed to download this file. Only files
- // that can be handled by the platform can be downloaded.
- // special case DRM files, which we should always allow downloading.
- Intent intent = new Intent(Intent.ACTION_VIEW);
-
- // We can provide data as either content: or file: URIs,
- // so allow both. (I think it would be nice if we just did
- // everything as content: URIs)
- // Actually, right now the download manager's UId restrictions
- // prevent use from using content: so it's got to be file: or
- // nothing
-
- PackageManager pm = context.getPackageManager();
- intent.setDataAndType(Uri.fromParts("file", "", null), mimeType);
- ResolveInfo ri = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
- //Log.i(Constants.TAG, "*** FILENAME QUERY " + intent + ": " + list);
-
- if (ri == null) {
- if (Constants.LOGV) {
- Log.v(Constants.TAG, "no handler found for type " + mimeType);
- }
- throw new StopRequestException(Downloads.Impl.STATUS_NOT_ACCEPTABLE,
- "no handler found for this download type");
- }
- }
- }
- }
-
private static String chooseFilename(String url, String hint, String contentDisposition,
String contentLocation, int destination) {
String filename = null;