Report MIME type for individual downloads.
Jeff Sharkey [Thu, 19 Apr 2012 17:10:53 +0000 (10:10 -0700)]
Bug: 6358473
Change-Id: Ied4a6c8194d0cbb735e43cf7d7759f4674efe535

src/com/android/providers/downloads/DownloadProvider.java

index 5fbe42a..40ebd2b 100644 (file)
@@ -39,6 +39,7 @@ import android.os.ParcelFileDescriptor;
 import android.os.Process;
 import android.provider.Downloads;
 import android.provider.OpenableColumns;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.google.android.collect.Maps;
@@ -55,7 +56,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-
 /**
  * Allows application to interact with the download manager.
  */
@@ -463,17 +463,20 @@ public final class DownloadProvider extends ContentProvider {
                 return DOWNLOAD_LIST_TYPE;
             }
             case MY_DOWNLOADS_ID:
-            case ALL_DOWNLOADS_ID: {
-                return DOWNLOAD_TYPE;
-            }
+            case ALL_DOWNLOADS_ID:
             case PUBLIC_DOWNLOAD_ID: {
                 // return the mimetype of this id from the database
                 final String id = getDownloadIdFromUri(uri);
                 final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
-                return DatabaseUtils.stringForQuery(db,
+                final String mimeType = DatabaseUtils.stringForQuery(db,
                         "SELECT " + Downloads.Impl.COLUMN_MIME_TYPE + " FROM " + DB_TABLE +
                         " WHERE " + Downloads.Impl._ID + " = ?",
                         new String[]{id});
+                if (TextUtils.isEmpty(mimeType)) {
+                    return DOWNLOAD_TYPE;
+                } else {
+                    return mimeType;
+                }
             }
             default: {
                 if (Constants.LOGV) {