Make downloads visible by default.

Change-Id: I8f8b325658d8afc964bddd3f1c03ed20e6bd10aa
diff --git a/api/current.xml b/api/current.xml
index f7afc5a..197e2cd 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -96558,19 +96558,6 @@
 <parameter name="value" type="java.lang.String">
 </parameter>
 </method>
-<method name="setShowNotification"
- return="android.net.DownloadManager.Request"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="flags" type="int">
-</parameter>
-</method>
 <method name="setTitle"
  return="android.net.DownloadManager.Request"
  abstract="false"
@@ -96617,17 +96604,6 @@
  visibility="public"
 >
 </field>
-<field name="NOTIFICATION_WHEN_RUNNING"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="LocalServerSocket"
  extends="java.lang.Object"
diff --git a/core/java/android/net/DownloadManager.java b/core/java/android/net/DownloadManager.java
index 1d88c18..e69c324 100644
--- a/core/java/android/net/DownloadManager.java
+++ b/core/java/android/net/DownloadManager.java
@@ -241,12 +241,6 @@
      */
     public static class Request {
         /**
-         * Bit flag for {@link #setShowNotification} indicating a notification should be created
-         * while the download is running.
-         */
-        public static final int NOTIFICATION_WHEN_RUNNING = 1;
-
-        /**
          * Bit flag for {@link #setAllowedNetworkTypes} corresponding to
          * {@link ConnectivityManager#TYPE_MOBILE}.
          */
@@ -269,7 +263,7 @@
         private Map<String, String> mRequestHeaders = new HashMap<String, String>();
         private String mTitle;
         private String mDescription;
-        private int mNotificationFlags = 0;
+        private boolean mShowNotification = true;
         private String mMediaType;
         private boolean mRoamingAllowed = true;
         private int mAllowedNetworkTypes = ~0; // default to all network types allowed
@@ -344,15 +338,20 @@
         }
 
         /**
-         * Control system notifications posted by the download manager for this download.  If
-         * enabled, the download manager posts notifications about downloads through the system
-         * {@link android.app.NotificationManager}. By default, no notification is shown.
+         * Control whether a system notification is posted by the download manager while this
+         * download is running. If enabled, the download manager posts notifications about downloads
+         * through the system {@link android.app.NotificationManager}. By default, a notification is
+         * shown.
          *
-         * @param flags any combination of the NOTIFICATION_* bit flags
+         * If set to false, this requires the permission
+         * android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.
+         *
+         * @param show whether the download manager should show a notification for this download.
          * @return this object
+         * @hide
          */
-        public Request setShowNotification(int flags) {
-            mNotificationFlags = flags;
+        public Request setShowRunningNotification(boolean show) {
+            mShowNotification = show;
             return this;
         }
 
@@ -404,11 +403,9 @@
             putIfNonNull(values, Downloads.COLUMN_DESCRIPTION, mDescription);
             putIfNonNull(values, Downloads.COLUMN_MIME_TYPE, mMediaType);
 
-            int visibility = Downloads.VISIBILITY_HIDDEN;
-            if ((mNotificationFlags & NOTIFICATION_WHEN_RUNNING) != 0) {
-                visibility = Downloads.VISIBILITY_VISIBLE;
-            }
-            values.put(Downloads.COLUMN_VISIBILITY, visibility);
+            values.put(Downloads.COLUMN_VISIBILITY,
+                    mShowNotification ? Downloads.VISIBILITY_VISIBLE
+                            : Downloads.VISIBILITY_HIDDEN);
 
             values.put(Downloads.Impl.COLUMN_ALLOWED_NETWORK_TYPES, mAllowedNetworkTypes);
             values.put(Downloads.Impl.COLUMN_ALLOW_ROAMING, mRoamingAllowed);
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index 1b37107..c9b5512 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -624,13 +624,19 @@
                 "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS";
 
         /**
-         * The permission to downloads files to the cache partition that won't be automatically
+         * The permission to download files to the cache partition that won't be automatically
          * purged when space is needed.
          */
         public static final String PERMISSION_CACHE_NON_PURGEABLE =
                 "android.permission.DOWNLOAD_CACHE_NON_PURGEABLE";
 
         /**
+         * The permission to download files without any system notification being shown.
+         */
+        public static final String PERMISSION_NO_NOTIFICATION =
+                "android.permission.DOWNLOAD_WITHOUT_NOTIFICATION";
+
+        /**
          * The content:// URI for the data table in the provider
          */
         public static final Uri CONTENT_URI =