summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadService.java
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-01-22 09:35:34 -0500
committerLeon Scroggins <scroggo@google.com>2010-01-22 09:39:07 -0500
commit581abbbbeba49e64219e5f11f8a8474760a2f902 (patch)
treeaf303eb84ae79ec25c967c7d843e4e7ccfd50e27 /src/com/android/providers/downloads/DownloadService.java
parent4d3a380d338b1f6ee120fb9de2001f138be398ff (diff)
downloadandroid_packages_providers_DownloadProvider-581abbbbeba49e64219e5f11f8a8474760a2f902.tar.gz
android_packages_providers_DownloadProvider-581abbbbeba49e64219e5f11f8a8474760a2f902.tar.bz2
android_packages_providers_DownloadProvider-581abbbbeba49e64219e5f11f8a8474760a2f902.zip
Revert "Download files even if there is no activity to launch them."
This reverts commit 0f1aae327a9e4c68044d767e9bafbac747b6d985. I misunderstood the bug. We do not want to be able to download files for which there is currently no Activity to launch them.
Diffstat (limited to 'src/com/android/providers/downloads/DownloadService.java')
-rw-r--r--src/com/android/providers/downloads/DownloadService.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java
index 5b56f686..9e890ea0 100644
--- a/src/com/android/providers/downloads/DownloadService.java
+++ b/src/com/android/providers/downloads/DownloadService.java
@@ -27,6 +27,8 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.database.CharArrayBuffer;
import android.database.ContentObserver;
import android.database.Cursor;
@@ -610,6 +612,43 @@ public class DownloadService extends Service {
mDownloads.add(arrayPos, info);
+ if (info.mStatus == 0
+ && (info.mDestination == Downloads.Impl.DESTINATION_EXTERNAL
+ || info.mDestination == Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE)
+ && info.mMimeType != null
+ && !DrmRawContent.DRM_MIMETYPE_MESSAGE_STRING.equalsIgnoreCase(info.mMimeType)) {
+ // 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 mimetypeIntent = 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
+
+ mimetypeIntent.setDataAndType(Uri.fromParts("file", "", null), info.mMimeType);
+ ResolveInfo ri = getPackageManager().resolveActivity(mimetypeIntent,
+ PackageManager.MATCH_DEFAULT_ONLY);
+ //Log.i(Constants.TAG, "*** QUERY " + mimetypeIntent + ": " + list);
+
+ if (ri == null) {
+ if (Config.LOGD) {
+ Log.d(Constants.TAG, "no application to handle MIME type " + info.mMimeType);
+ }
+ info.mStatus = Downloads.Impl.STATUS_NOT_ACCEPTABLE;
+
+ Uri uri = ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, info.mId);
+ ContentValues values = new ContentValues();
+ values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_NOT_ACCEPTABLE);
+ getContentResolver().update(uri, values, null, null);
+ info.sendIntentIfRequested(uri, this);
+ return;
+ }
+ }
+
if (info.canUseNetwork(networkAvailable, networkRoaming)) {
if (info.isReadyToStart(now)) {
if (Constants.LOGV) {