Merge "Don't ignore COLUMN_MEDIA_SCANNED values from caller."
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index acc7094..fde1d29e 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -26,7 +26,6 @@
 import android.content.ContentUris;
 import android.content.ContentValues;
 import android.content.Context;
-import android.content.Intent;
 import android.database.Cursor;
 import android.database.CursorWrapper;
 import android.net.ConnectivityManager;
@@ -37,7 +36,6 @@
 import android.os.FileUtils;
 import android.os.ParcelFileDescriptor;
 import android.provider.Downloads;
-import android.provider.MediaStore.Images;
 import android.provider.Settings;
 import android.provider.Settings.SettingNotFoundException;
 import android.text.TextUtils;
@@ -399,14 +397,14 @@
         /** if a file is designated as a MediaScanner scannable file, the following value is
          * stored in the database column {@link Downloads.Impl#COLUMN_MEDIA_SCANNED}.
          */
-        private static final int SCANNABLE_VALUE_YES = 0;
+        private static final int SCANNABLE_VALUE_YES = Downloads.Impl.MEDIA_NOT_SCANNED;
         // value of 1 is stored in the above column by DownloadProvider after it is scanned by
         // MediaScanner
         /** if a file is designated as a file that should not be scanned by MediaScanner,
          * the following value is stored in the database column
          * {@link Downloads.Impl#COLUMN_MEDIA_SCANNED}.
          */
-        private static final int SCANNABLE_VALUE_NO = 2;
+        private static final int SCANNABLE_VALUE_NO = Downloads.Impl.MEDIA_NOT_SCANNABLE;
 
         /**
          * This download is visible but only shows in the notifications
@@ -1264,19 +1262,6 @@
             throw new IllegalStateException("Failed to rename to " + after);
         }
 
-        // Update MediaProvider if necessary
-        if (mimeType.startsWith("image/")) {
-            context.getContentResolver().delete(Images.Media.EXTERNAL_CONTENT_URI,
-                    Images.Media.DATA + "=?",
-                    new String[] {
-                            before.getAbsolutePath()
-                    });
-
-            Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
-            intent.setData(Uri.fromFile(after));
-            context.sendBroadcast(intent);
-        }
-
         ContentValues values = new ContentValues();
         values.put(Downloads.Impl.COLUMN_TITLE, displayName);
         values.put(Downloads.Impl._DATA, after.toString());
@@ -1329,8 +1314,7 @@
      * @param description the description that would appear for this file in Downloads App.
      * @param isMediaScannerScannable true if the file is to be scanned by MediaScanner. Files
      * scanned by MediaScanner appear in the applications used to view media (for example,
-     * Gallery app). Starting from {@link android.os.Build.VERSION_CODES#Q}, this argument is
-     * ignored and the file is always scanned by MediaScanner.
+     * Gallery app).
      * @param mimeType mimetype of the file.
      * @param path absolute pathname to the file. The file should be world-readable, so that it can
      * be managed by the Downloads App and any other app that is used to read it (for example,
@@ -1359,8 +1343,7 @@
      * @param description the description that would appear for this file in Downloads App.
      * @param isMediaScannerScannable true if the file is to be scanned by MediaScanner. Files
      * scanned by MediaScanner appear in the applications used to view media (for example,
-     * Gallery app). Starting from {@link android.os.Build.VERSION_CODES#Q}, this argument is
-     * ignored and the file is always scanned by MediaScanner.
+     * Gallery app).
      * @param mimeType mimetype of the file.
      * @param path absolute pathname to the file. The file should be world-readable, so that it can
      * be managed by the Downloads App and any other app that is used to read it (for example,
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index 63bbb9c..89d1c44 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -419,12 +419,20 @@
 
         /**
          * The column that is used to remember whether the media scanner was invoked.
-         * It can take the values: null or 0(not scanned), 1(scanned), 2 (not scannable).
+         * It can take the values: {@link #MEDIA_NOT_SCANNED}, {@link #MEDIA_SCANNED} or
+         * {@link #MEDIA_NOT_SCANNABLE} or {@code null}. If it's value is {@code null}, it will be
+         * treated as {@link #MEDIA_NOT_SCANNED}.
+         *
          * <P>Type: TEXT</P>
          */
         @UnsupportedAppUsage
         public static final String COLUMN_MEDIA_SCANNED = "scanned";
 
+        /** Possible values for column {@link #COLUMN_MEDIA_SCANNED} */
+        public static final int MEDIA_NOT_SCANNED = 0;
+        public static final int MEDIA_SCANNED = 1;
+        public static final int MEDIA_NOT_SCANNABLE = 2;
+
         /**
          * The column with errorMsg for a failed downloaded.
          * Used only for debugging purposes.