diff options
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/net/DownloadManager.java | 33 | ||||
-rw-r--r-- | core/java/android/provider/Downloads.java | 8 |
2 files changed, 22 insertions, 19 deletions
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 class DownloadManager { */ 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 @@ public class DownloadManager { 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 @@ public class DownloadManager { } /** - * 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 @@ public class DownloadManager { 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 @@ public final class Downloads { "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 = |