The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.provider; |
| 18 | |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
Vasu Nori | 4c6e5df | 2010-10-26 17:00:16 -0700 | [diff] [blame] | 20 | import android.app.DownloadManager; |
Jeff Sharkey | 948eef8 | 2012-03-20 17:44:42 -0700 | [diff] [blame] | 21 | import android.content.Context; |
Jeff Sharkey | 1a30395 | 2011-06-16 13:04:20 -0700 | [diff] [blame] | 22 | import android.net.NetworkPolicyManager; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
| 24 | |
| 25 | /** |
Jean-Baptiste Queru | e99f41f | 2010-01-14 11:58:14 -0800 | [diff] [blame] | 26 | * The Download Manager |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 27 | * |
Jean-Baptiste Queru | e99f41f | 2010-01-14 11:58:14 -0800 | [diff] [blame] | 28 | * @pending |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 29 | */ |
Jean-Baptiste Queru | 843e897 | 2010-01-14 11:56:11 -0800 | [diff] [blame] | 30 | public final class Downloads { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 31 | private Downloads() {} |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 32 | |
| 33 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 34 | * Implementation details |
Jean-Baptiste Queru | e99f41f | 2010-01-14 11:58:14 -0800 | [diff] [blame] | 35 | * |
| 36 | * Exposes constants used to interact with the download manager's |
| 37 | * content provider. |
| 38 | * The constants URI ... STATUS are the names of columns in the downloads table. |
| 39 | * |
| 40 | * @hide |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 41 | */ |
| 42 | public static final class Impl implements BaseColumns { |
| 43 | private Impl() {} |
| 44 | |
Jeff Sharkey | 0a17db1 | 2016-11-04 11:23:46 -0600 | [diff] [blame] | 45 | public static final String AUTHORITY = "downloads"; |
| 46 | |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 47 | /** |
| 48 | * The permission to access the download manager |
| 49 | */ |
| 50 | public static final String PERMISSION_ACCESS = "android.permission.ACCESS_DOWNLOAD_MANAGER"; |
| 51 | |
| 52 | /** |
| 53 | * The permission to access the download manager's advanced functions |
| 54 | */ |
| 55 | public static final String PERMISSION_ACCESS_ADVANCED = |
| 56 | "android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED"; |
| 57 | |
| 58 | /** |
Kenny Root | 1de2eac | 2010-12-01 11:37:36 -0800 | [diff] [blame] | 59 | * The permission to access the all the downloads in the manager. |
| 60 | */ |
| 61 | public static final String PERMISSION_ACCESS_ALL = |
| 62 | "android.permission.ACCESS_ALL_DOWNLOADS"; |
| 63 | |
| 64 | /** |
| 65 | * The permission to directly access the download manager's cache |
| 66 | * directory |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 67 | */ |
| 68 | public static final String PERMISSION_CACHE = "android.permission.ACCESS_CACHE_FILESYSTEM"; |
| 69 | |
| 70 | /** |
| 71 | * The permission to send broadcasts on download completion |
| 72 | */ |
| 73 | public static final String PERMISSION_SEND_INTENTS = |
| 74 | "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS"; |
| 75 | |
| 76 | /** |
Steve Howard | 8e15afe | 2010-07-28 17:12:40 -0700 | [diff] [blame] | 77 | * The permission to download files to the cache partition that won't be automatically |
Steve Howard | a13a02c | 2010-07-23 14:58:15 -0700 | [diff] [blame] | 78 | * purged when space is needed. |
| 79 | */ |
| 80 | public static final String PERMISSION_CACHE_NON_PURGEABLE = |
| 81 | "android.permission.DOWNLOAD_CACHE_NON_PURGEABLE"; |
| 82 | |
| 83 | /** |
Steve Howard | 8e15afe | 2010-07-28 17:12:40 -0700 | [diff] [blame] | 84 | * The permission to download files without any system notification being shown. |
| 85 | */ |
| 86 | public static final String PERMISSION_NO_NOTIFICATION = |
| 87 | "android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"; |
| 88 | |
| 89 | /** |
Steve Howard | eca77fc | 2010-09-12 18:49:08 -0700 | [diff] [blame] | 90 | * The content:// URI to access downloads owned by the caller's UID. |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 91 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 92 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 93 | public static final Uri CONTENT_URI = |
Steve Howard | eca77fc | 2010-09-12 18:49:08 -0700 | [diff] [blame] | 94 | Uri.parse("content://downloads/my_downloads"); |
| 95 | |
| 96 | /** |
| 97 | * The content URI for accessing all downloads across all UIDs (requires the |
| 98 | * ACCESS_ALL_DOWNLOADS permission). |
| 99 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 100 | @UnsupportedAppUsage |
Steve Howard | eca77fc | 2010-09-12 18:49:08 -0700 | [diff] [blame] | 101 | public static final Uri ALL_DOWNLOADS_CONTENT_URI = |
| 102 | Uri.parse("content://downloads/all_downloads"); |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 103 | |
Vasu Nori | 5be894e | 2010-11-02 21:55:30 -0700 | [diff] [blame] | 104 | /** URI segment to access a publicly accessible downloaded file */ |
| 105 | public static final String PUBLICLY_ACCESSIBLE_DOWNLOADS_URI_SEGMENT = "public_downloads"; |
| 106 | |
| 107 | /** |
| 108 | * The content URI for accessing publicly accessible downloads (i.e., it requires no |
| 109 | * permissions to access this downloaded file) |
| 110 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 111 | @UnsupportedAppUsage |
Vasu Nori | 5be894e | 2010-11-02 21:55:30 -0700 | [diff] [blame] | 112 | public static final Uri PUBLICLY_ACCESSIBLE_DOWNLOADS_URI = |
| 113 | Uri.parse("content://downloads/" + PUBLICLY_ACCESSIBLE_DOWNLOADS_URI_SEGMENT); |
| 114 | |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 115 | /** |
| 116 | * Broadcast Action: this is sent by the download manager to the app |
| 117 | * that had initiated a download when that download completes. The |
| 118 | * download's content: uri is specified in the intent's data. |
| 119 | */ |
| 120 | public static final String ACTION_DOWNLOAD_COMPLETED = |
Jeff Sharkey | 8d5d065 | 2017-04-04 14:38:39 -0600 | [diff] [blame] | 121 | DownloadManager.ACTION_DOWNLOAD_COMPLETED; |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Broadcast Action: this is sent by the download manager to the app |
| 125 | * that had initiated a download when the user selects the notification |
| 126 | * associated with that download. The download's content: uri is specified |
| 127 | * in the intent's data if the click is associated with a single download, |
| 128 | * or Downloads.CONTENT_URI if the notification is associated with |
| 129 | * multiple downloads. |
| 130 | * Note: this is not currently sent for downloads that have completed |
| 131 | * successfully. |
| 132 | */ |
| 133 | public static final String ACTION_NOTIFICATION_CLICKED = |
Jeff Sharkey | 8d5d065 | 2017-04-04 14:38:39 -0600 | [diff] [blame] | 134 | DownloadManager.ACTION_NOTIFICATION_CLICKED; |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * The name of the column containing the URI of the data being downloaded. |
| 138 | * <P>Type: TEXT</P> |
| 139 | * <P>Owner can Init/Read</P> |
| 140 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 141 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 142 | public static final String COLUMN_URI = "uri"; |
| 143 | |
| 144 | /** |
| 145 | * The name of the column containing application-specific data. |
| 146 | * <P>Type: TEXT</P> |
| 147 | * <P>Owner can Init/Read/Write</P> |
| 148 | */ |
| 149 | public static final String COLUMN_APP_DATA = "entity"; |
| 150 | |
| 151 | /** |
| 152 | * The name of the column containing the flags that indicates whether |
| 153 | * the initiating application is capable of verifying the integrity of |
| 154 | * the downloaded file. When this flag is set, the download manager |
| 155 | * performs downloads and reports success even in some situations where |
| 156 | * it can't guarantee that the download has completed (e.g. when doing |
| 157 | * a byte-range request without an ETag, or when it can't determine |
| 158 | * whether a download fully completed). |
| 159 | * <P>Type: BOOLEAN</P> |
| 160 | * <P>Owner can Init</P> |
| 161 | */ |
| 162 | public static final String COLUMN_NO_INTEGRITY = "no_integrity"; |
| 163 | |
| 164 | /** |
| 165 | * The name of the column containing the filename that the initiating |
| 166 | * application recommends. When possible, the download manager will attempt |
| 167 | * to use this filename, or a variation, as the actual name for the file. |
| 168 | * <P>Type: TEXT</P> |
| 169 | * <P>Owner can Init</P> |
| 170 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 171 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 172 | public static final String COLUMN_FILE_NAME_HINT = "hint"; |
| 173 | |
| 174 | /** |
| 175 | * The name of the column containing the filename where the downloaded data |
| 176 | * was actually stored. |
| 177 | * <P>Type: TEXT</P> |
| 178 | * <P>Owner can Read</P> |
| 179 | */ |
| 180 | public static final String _DATA = "_data"; |
| 181 | |
| 182 | /** |
| 183 | * The name of the column containing the MIME type of the downloaded data. |
| 184 | * <P>Type: TEXT</P> |
| 185 | * <P>Owner can Init/Read</P> |
| 186 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 187 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 188 | public static final String COLUMN_MIME_TYPE = "mimetype"; |
| 189 | |
| 190 | /** |
| 191 | * The name of the column containing the flag that controls the destination |
| 192 | * of the download. See the DESTINATION_* constants for a list of legal values. |
| 193 | * <P>Type: INTEGER</P> |
| 194 | * <P>Owner can Init</P> |
| 195 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 196 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 197 | public static final String COLUMN_DESTINATION = "destination"; |
| 198 | |
| 199 | /** |
| 200 | * The name of the column containing the flags that controls whether the |
| 201 | * download is displayed by the UI. See the VISIBILITY_* constants for |
| 202 | * a list of legal values. |
| 203 | * <P>Type: INTEGER</P> |
| 204 | * <P>Owner can Init/Read/Write</P> |
| 205 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 206 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 207 | public static final String COLUMN_VISIBILITY = "visibility"; |
| 208 | |
| 209 | /** |
| 210 | * The name of the column containing the current control state of the download. |
| 211 | * Applications can write to this to control (pause/resume) the download. |
| 212 | * the CONTROL_* constants for a list of legal values. |
| 213 | * <P>Type: INTEGER</P> |
| 214 | * <P>Owner can Read</P> |
| 215 | */ |
| 216 | public static final String COLUMN_CONTROL = "control"; |
| 217 | |
| 218 | /** |
| 219 | * The name of the column containing the current status of the download. |
| 220 | * Applications can read this to follow the progress of each download. See |
| 221 | * the STATUS_* constants for a list of legal values. |
| 222 | * <P>Type: INTEGER</P> |
| 223 | * <P>Owner can Read</P> |
| 224 | */ |
| 225 | public static final String COLUMN_STATUS = "status"; |
| 226 | |
| 227 | /** |
| 228 | * The name of the column containing the date at which some interesting |
| 229 | * status changed in the download. Stored as a System.currentTimeMillis() |
| 230 | * value. |
| 231 | * <P>Type: BIGINT</P> |
| 232 | * <P>Owner can Read</P> |
| 233 | */ |
| 234 | public static final String COLUMN_LAST_MODIFICATION = "lastmod"; |
| 235 | |
| 236 | /** |
| 237 | * The name of the column containing the package name of the application |
| 238 | * that initiating the download. The download manager will send |
| 239 | * notifications to a component in this package when the download completes. |
| 240 | * <P>Type: TEXT</P> |
| 241 | * <P>Owner can Init/Read</P> |
| 242 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 243 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 244 | public static final String COLUMN_NOTIFICATION_PACKAGE = "notificationpackage"; |
| 245 | |
| 246 | /** |
| 247 | * The name of the column containing the component name of the class that |
| 248 | * will receive notifications associated with the download. The |
| 249 | * package/class combination is passed to |
| 250 | * Intent.setClassName(String,String). |
| 251 | * <P>Type: TEXT</P> |
| 252 | * <P>Owner can Init/Read</P> |
| 253 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 254 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 255 | public static final String COLUMN_NOTIFICATION_CLASS = "notificationclass"; |
| 256 | |
| 257 | /** |
| 258 | * If extras are specified when requesting a download they will be provided in the intent that |
| 259 | * is sent to the specified class and package when a download has finished. |
| 260 | * <P>Type: TEXT</P> |
| 261 | * <P>Owner can Init</P> |
| 262 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 263 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 264 | public static final String COLUMN_NOTIFICATION_EXTRAS = "notificationextras"; |
| 265 | |
| 266 | /** |
| 267 | * The name of the column contain the values of the cookie to be used for |
| 268 | * the download. This is used directly as the value for the Cookie: HTTP |
| 269 | * header that gets sent with the request. |
| 270 | * <P>Type: TEXT</P> |
| 271 | * <P>Owner can Init</P> |
| 272 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 273 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 274 | public static final String COLUMN_COOKIE_DATA = "cookiedata"; |
| 275 | |
| 276 | /** |
| 277 | * The name of the column containing the user agent that the initiating |
| 278 | * application wants the download manager to use for this download. |
| 279 | * <P>Type: TEXT</P> |
| 280 | * <P>Owner can Init</P> |
| 281 | */ |
| 282 | public static final String COLUMN_USER_AGENT = "useragent"; |
| 283 | |
| 284 | /** |
| 285 | * The name of the column containing the referer (sic) that the initiating |
| 286 | * application wants the download manager to use for this download. |
| 287 | * <P>Type: TEXT</P> |
| 288 | * <P>Owner can Init</P> |
| 289 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 290 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 291 | public static final String COLUMN_REFERER = "referer"; |
| 292 | |
| 293 | /** |
| 294 | * The name of the column containing the total size of the file being |
| 295 | * downloaded. |
| 296 | * <P>Type: INTEGER</P> |
| 297 | * <P>Owner can Read</P> |
| 298 | */ |
| 299 | public static final String COLUMN_TOTAL_BYTES = "total_bytes"; |
| 300 | |
| 301 | /** |
| 302 | * The name of the column containing the size of the part of the file that |
| 303 | * has been downloaded so far. |
| 304 | * <P>Type: INTEGER</P> |
| 305 | * <P>Owner can Read</P> |
| 306 | */ |
| 307 | public static final String COLUMN_CURRENT_BYTES = "current_bytes"; |
| 308 | |
| 309 | /** |
| 310 | * The name of the column where the initiating application can provide the |
| 311 | * UID of another application that is allowed to access this download. If |
| 312 | * multiple applications share the same UID, all those applications will be |
| 313 | * allowed to access this download. This column can be updated after the |
| 314 | * download is initiated. This requires the permission |
| 315 | * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED. |
| 316 | * <P>Type: INTEGER</P> |
| 317 | * <P>Owner can Init</P> |
| 318 | */ |
| 319 | public static final String COLUMN_OTHER_UID = "otheruid"; |
| 320 | |
| 321 | /** |
| 322 | * The name of the column where the initiating application can provided the |
| 323 | * title of this download. The title will be displayed ito the user in the |
| 324 | * list of downloads. |
| 325 | * <P>Type: TEXT</P> |
| 326 | * <P>Owner can Init/Read/Write</P> |
| 327 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 328 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 329 | public static final String COLUMN_TITLE = "title"; |
| 330 | |
| 331 | /** |
| 332 | * The name of the column where the initiating application can provide the |
| 333 | * description of this download. The description will be displayed to the |
| 334 | * user in the list of downloads. |
| 335 | * <P>Type: TEXT</P> |
| 336 | * <P>Owner can Init/Read/Write</P> |
| 337 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 338 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 339 | public static final String COLUMN_DESCRIPTION = "description"; |
| 340 | |
Steve Howard | b8e07a5 | 2010-07-21 14:53:21 -0700 | [diff] [blame] | 341 | /** |
| 342 | * The name of the column indicating whether the download was requesting through the public |
| 343 | * API. This controls some differences in behavior. |
| 344 | * <P>Type: BOOLEAN</P> |
| 345 | * <P>Owner can Init/Read</P> |
| 346 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 347 | @UnsupportedAppUsage |
Steve Howard | b8e07a5 | 2010-07-21 14:53:21 -0700 | [diff] [blame] | 348 | public static final String COLUMN_IS_PUBLIC_API = "is_public_api"; |
| 349 | |
| 350 | /** |
Jeff Sharkey | 15ec7d6 | 2012-04-17 12:23:40 -0700 | [diff] [blame] | 351 | * The name of the column holding a bitmask of allowed network types. This is only used for |
| 352 | * public API downloads. |
| 353 | * <P>Type: INTEGER</P> |
| 354 | * <P>Owner can Init/Read</P> |
| 355 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 356 | @UnsupportedAppUsage |
Jeff Sharkey | 15ec7d6 | 2012-04-17 12:23:40 -0700 | [diff] [blame] | 357 | public static final String COLUMN_ALLOWED_NETWORK_TYPES = "allowed_network_types"; |
| 358 | |
| 359 | /** |
Steve Howard | b8e07a5 | 2010-07-21 14:53:21 -0700 | [diff] [blame] | 360 | * The name of the column indicating whether roaming connections can be used. This is only |
| 361 | * used for public API downloads. |
| 362 | * <P>Type: BOOLEAN</P> |
| 363 | * <P>Owner can Init/Read</P> |
| 364 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 365 | @UnsupportedAppUsage |
Steve Howard | b8e07a5 | 2010-07-21 14:53:21 -0700 | [diff] [blame] | 366 | public static final String COLUMN_ALLOW_ROAMING = "allow_roaming"; |
| 367 | |
| 368 | /** |
Jeff Sharkey | 15ec7d6 | 2012-04-17 12:23:40 -0700 | [diff] [blame] | 369 | * The name of the column indicating whether metered connections can be used. This is only |
| 370 | * used for public API downloads. |
| 371 | * <P>Type: BOOLEAN</P> |
Steve Howard | b8e07a5 | 2010-07-21 14:53:21 -0700 | [diff] [blame] | 372 | * <P>Owner can Init/Read</P> |
| 373 | */ |
Jeff Sharkey | 15ec7d6 | 2012-04-17 12:23:40 -0700 | [diff] [blame] | 374 | public static final String COLUMN_ALLOW_METERED = "allow_metered"; |
Steve Howard | b8e07a5 | 2010-07-21 14:53:21 -0700 | [diff] [blame] | 375 | |
Steve Howard | 90fb15a | 2010-09-09 16:13:41 -0700 | [diff] [blame] | 376 | /** |
| 377 | * Whether or not this download should be displayed in the system's Downloads UI. Defaults |
| 378 | * to true. |
| 379 | * <P>Type: INTEGER</P> |
| 380 | * <P>Owner can Init/Read</P> |
| 381 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 382 | @UnsupportedAppUsage |
Steve Howard | 90fb15a | 2010-09-09 16:13:41 -0700 | [diff] [blame] | 383 | public static final String COLUMN_IS_VISIBLE_IN_DOWNLOADS_UI = "is_visible_in_downloads_ui"; |
| 384 | |
Steve Howard | f176681 | 2010-09-17 16:46:19 -0700 | [diff] [blame] | 385 | /** |
| 386 | * If true, the user has confirmed that this download can proceed over the mobile network |
| 387 | * even though it exceeds the recommended maximum size. |
| 388 | * <P>Type: BOOLEAN</P> |
| 389 | */ |
| 390 | public static final String COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT = |
| 391 | "bypass_recommended_size_limit"; |
| 392 | |
Vasu Nori | 216fa22 | 2010-10-12 23:08:13 -0700 | [diff] [blame] | 393 | /** |
| 394 | * Set to true if this download is deleted. It is completely removed from the database |
| 395 | * when MediaProvider database also deletes the metadata asociated with this downloaded file. |
| 396 | * <P>Type: BOOLEAN</P> |
| 397 | * <P>Owner can Read</P> |
| 398 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 399 | @UnsupportedAppUsage |
Vasu Nori | 216fa22 | 2010-10-12 23:08:13 -0700 | [diff] [blame] | 400 | public static final String COLUMN_DELETED = "deleted"; |
| 401 | |
| 402 | /** |
| 403 | * The URI to the corresponding entry in MediaProvider for this downloaded entry. It is |
| 404 | * used to delete the entries from MediaProvider database when it is deleted from the |
| 405 | * downloaded list. |
| 406 | * <P>Type: TEXT</P> |
| 407 | * <P>Owner can Read</P> |
| 408 | */ |
| 409 | public static final String COLUMN_MEDIAPROVIDER_URI = "mediaprovider_uri"; |
| 410 | |
Vasu Nori | 5be894e | 2010-11-02 21:55:30 -0700 | [diff] [blame] | 411 | /** |
Sudheer Shanka | fe7668a | 2018-12-16 15:52:33 -0800 | [diff] [blame] | 412 | * Similar to {@link #COLUMN_MEDIAPROVIDER_URI}, except this cannot be updated/queried |
| 413 | * by apps and will be the source of truth when updating/deleting download entries in |
| 414 | * MediaProvider database. |
| 415 | * |
| 416 | * <P>Type: TEXT</P> |
| 417 | */ |
| 418 | public static final String COLUMN_MEDIASTORE_URI = "mediastore_uri"; |
| 419 | |
| 420 | /** |
Vasu Nori | 5be894e | 2010-11-02 21:55:30 -0700 | [diff] [blame] | 421 | * The column that is used to remember whether the media scanner was invoked. |
Sudheer Shanka | 684c02a | 2019-01-29 17:41:15 -0800 | [diff] [blame] | 422 | * It can take the values: {@link #MEDIA_NOT_SCANNED}, {@link #MEDIA_SCANNED} or |
| 423 | * {@link #MEDIA_NOT_SCANNABLE} or {@code null}. If it's value is {@code null}, it will be |
| 424 | * treated as {@link #MEDIA_NOT_SCANNED}. |
| 425 | * |
Vasu Nori | 5be894e | 2010-11-02 21:55:30 -0700 | [diff] [blame] | 426 | * <P>Type: TEXT</P> |
| 427 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 428 | @UnsupportedAppUsage |
Vasu Nori | 5be894e | 2010-11-02 21:55:30 -0700 | [diff] [blame] | 429 | public static final String COLUMN_MEDIA_SCANNED = "scanned"; |
| 430 | |
Sudheer Shanka | 684c02a | 2019-01-29 17:41:15 -0800 | [diff] [blame] | 431 | /** Possible values for column {@link #COLUMN_MEDIA_SCANNED} */ |
| 432 | public static final int MEDIA_NOT_SCANNED = 0; |
| 433 | public static final int MEDIA_SCANNED = 1; |
| 434 | public static final int MEDIA_NOT_SCANNABLE = 2; |
| 435 | |
Vasu Nori | 4015de2 | 2010-11-11 15:19:37 -0800 | [diff] [blame] | 436 | /** |
| 437 | * The column with errorMsg for a failed downloaded. |
| 438 | * Used only for debugging purposes. |
| 439 | * <P>Type: TEXT</P> |
| 440 | */ |
| 441 | public static final String COLUMN_ERROR_MSG = "errorMsg"; |
| 442 | |
Vasu Nori | 8da7a4e | 2010-11-17 17:14:49 -0800 | [diff] [blame] | 443 | /** |
| 444 | * This column stores the source of the last update to this row. |
| 445 | * This column is only for internal use. |
| 446 | * Valid values are indicated by LAST_UPDATESRC_* constants. |
| 447 | * <P>Type: INT</P> |
| 448 | */ |
| 449 | public static final String COLUMN_LAST_UPDATESRC = "lastUpdateSrc"; |
| 450 | |
Jeff Sharkey | 5478120 | 2013-01-17 17:27:33 -0800 | [diff] [blame] | 451 | /** The column that is used to count retries */ |
| 452 | public static final String COLUMN_FAILED_CONNECTIONS = "numfailed"; |
| 453 | |
Jeff Sharkey | b180a65 | 2013-09-23 14:23:41 -0700 | [diff] [blame] | 454 | public static final String COLUMN_ALLOW_WRITE = "allow_write"; |
| 455 | |
Jeff Sharkey | f07c7b9 | 2016-04-22 09:50:16 -0600 | [diff] [blame] | 456 | public static final int FLAG_REQUIRES_CHARGING = 1 << 0; |
| 457 | public static final int FLAG_REQUIRES_DEVICE_IDLE = 1 << 1; |
| 458 | |
| 459 | public static final String COLUMN_FLAGS = "flags"; |
| 460 | |
Vasu Nori | 8da7a4e | 2010-11-17 17:14:49 -0800 | [diff] [blame] | 461 | /** |
| 462 | * default value for {@link #COLUMN_LAST_UPDATESRC}. |
| 463 | * This value is used when this column's value is not relevant. |
| 464 | */ |
| 465 | public static final int LAST_UPDATESRC_NOT_RELEVANT = 0; |
| 466 | |
| 467 | /** |
| 468 | * One of the values taken by {@link #COLUMN_LAST_UPDATESRC}. |
| 469 | * This value is used when the update is NOT to be relayed to the DownloadService |
| 470 | * (and thus spare DownloadService from scanning the database when this change occurs) |
| 471 | */ |
| 472 | public static final int LAST_UPDATESRC_DONT_NOTIFY_DOWNLOADSVC = 1; |
| 473 | |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 474 | /* |
| 475 | * Lists the destinations that an application can specify for a download. |
| 476 | */ |
| 477 | |
| 478 | /** |
| 479 | * This download will be saved to the external storage. This is the |
| 480 | * default behavior, and should be used for any file that the user |
| 481 | * can freely access, copy, delete. Even with that destination, |
| 482 | * unencrypted DRM files are saved in secure internal storage. |
| 483 | * Downloads to the external destination only write files for which |
| 484 | * there is a registered handler. The resulting files are accessible |
| 485 | * by filename to all applications. |
| 486 | */ |
| 487 | public static final int DESTINATION_EXTERNAL = 0; |
| 488 | |
| 489 | /** |
| 490 | * This download will be saved to the download manager's private |
| 491 | * partition. This is the behavior used by applications that want to |
| 492 | * download private files that are used and deleted soon after they |
| 493 | * get downloaded. All file types are allowed, and only the initiating |
| 494 | * application can access the file (indirectly through a content |
| 495 | * provider). This requires the |
| 496 | * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED permission. |
| 497 | */ |
| 498 | public static final int DESTINATION_CACHE_PARTITION = 1; |
| 499 | |
| 500 | /** |
| 501 | * This download will be saved to the download manager's private |
| 502 | * partition and will be purged as necessary to make space. This is |
| 503 | * for private files (similar to CACHE_PARTITION) that aren't deleted |
| 504 | * immediately after they are used, and are kept around by the download |
| 505 | * manager as long as space is available. |
| 506 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 507 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 508 | public static final int DESTINATION_CACHE_PARTITION_PURGEABLE = 2; |
| 509 | |
| 510 | /** |
| 511 | * This download will be saved to the download manager's private |
| 512 | * partition, as with DESTINATION_CACHE_PARTITION, but the download |
| 513 | * will not proceed if the user is on a roaming data connection. |
| 514 | */ |
| 515 | public static final int DESTINATION_CACHE_PARTITION_NOROAMING = 3; |
| 516 | |
| 517 | /** |
Steve Howard | adcb697 | 2010-07-12 17:09:25 -0700 | [diff] [blame] | 518 | * This download will be saved to the location given by the file URI in |
| 519 | * {@link #COLUMN_FILE_NAME_HINT}. |
| 520 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 521 | @UnsupportedAppUsage |
Steve Howard | adcb697 | 2010-07-12 17:09:25 -0700 | [diff] [blame] | 522 | public static final int DESTINATION_FILE_URI = 4; |
| 523 | |
| 524 | /** |
Vasu Nori | f83e6e4 | 2010-12-13 16:28:31 -0800 | [diff] [blame] | 525 | * This download will be saved to the system cache ("/cache") |
| 526 | * partition. This option is only used by system apps and so it requires |
| 527 | * android.permission.ACCESS_CACHE_FILESYSTEM permission. |
| 528 | */ |
Jeff Sharkey | 4233f03 | 2017-07-15 12:58:38 -0600 | [diff] [blame] | 529 | @Deprecated |
Vasu Nori | f83e6e4 | 2010-12-13 16:28:31 -0800 | [diff] [blame] | 530 | public static final int DESTINATION_SYSTEMCACHE_PARTITION = 5; |
| 531 | |
| 532 | /** |
Vasu Nori | c0e5075 | 2011-01-20 17:57:54 -0800 | [diff] [blame] | 533 | * This download was completed by the caller (i.e., NOT downloadmanager) |
| 534 | * and caller wants to have this download displayed in Downloads App. |
| 535 | */ |
| 536 | public static final int DESTINATION_NON_DOWNLOADMANAGER_DOWNLOAD = 6; |
| 537 | |
| 538 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 539 | * This download is allowed to run. |
| 540 | */ |
| 541 | public static final int CONTROL_RUN = 0; |
| 542 | |
| 543 | /** |
| 544 | * This download must pause at the first opportunity. |
| 545 | */ |
| 546 | public static final int CONTROL_PAUSED = 1; |
| 547 | |
| 548 | /* |
| 549 | * Lists the states that the download manager can set on a download |
| 550 | * to notify applications of the download progress. |
| 551 | * The codes follow the HTTP families:<br> |
| 552 | * 1xx: informational<br> |
| 553 | * 2xx: success<br> |
| 554 | * 3xx: redirects (not used by the download manager)<br> |
| 555 | * 4xx: client errors<br> |
| 556 | * 5xx: server errors |
| 557 | */ |
| 558 | |
| 559 | /** |
| 560 | * Returns whether the status is informational (i.e. 1xx). |
| 561 | */ |
| 562 | public static boolean isStatusInformational(int status) { |
| 563 | return (status >= 100 && status < 200); |
| 564 | } |
| 565 | |
| 566 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 567 | * Returns whether the status is a success (i.e. 2xx). |
| 568 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 569 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 570 | public static boolean isStatusSuccess(int status) { |
| 571 | return (status >= 200 && status < 300); |
| 572 | } |
| 573 | |
| 574 | /** |
| 575 | * Returns whether the status is an error (i.e. 4xx or 5xx). |
| 576 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 577 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 578 | public static boolean isStatusError(int status) { |
| 579 | return (status >= 400 && status < 600); |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * Returns whether the status is a client error (i.e. 4xx). |
| 584 | */ |
| 585 | public static boolean isStatusClientError(int status) { |
| 586 | return (status >= 400 && status < 500); |
| 587 | } |
| 588 | |
| 589 | /** |
| 590 | * Returns whether the status is a server error (i.e. 5xx). |
| 591 | */ |
| 592 | public static boolean isStatusServerError(int status) { |
| 593 | return (status >= 500 && status < 600); |
| 594 | } |
| 595 | |
| 596 | /** |
Vasu Nori | f9e8523 | 2011-02-10 14:59:54 -0800 | [diff] [blame] | 597 | * this method determines if a notification should be displayed for a |
| 598 | * given {@link #COLUMN_VISIBILITY} value |
| 599 | * @param visibility the value of {@link #COLUMN_VISIBILITY}. |
| 600 | * @return true if the notification should be displayed. false otherwise. |
| 601 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 602 | @UnsupportedAppUsage |
Vasu Nori | f9e8523 | 2011-02-10 14:59:54 -0800 | [diff] [blame] | 603 | public static boolean isNotificationToBeDisplayed(int visibility) { |
| 604 | return visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED || |
| 605 | visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION; |
| 606 | } |
| 607 | |
| 608 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 609 | * Returns whether the download has completed (either with success or |
| 610 | * error). |
| 611 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 612 | @UnsupportedAppUsage |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 613 | public static boolean isStatusCompleted(int status) { |
| 614 | return (status >= 200 && status < 300) || (status >= 400 && status < 600); |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * This download hasn't stated yet |
| 619 | */ |
| 620 | public static final int STATUS_PENDING = 190; |
| 621 | |
| 622 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 623 | * This download has started |
| 624 | */ |
| 625 | public static final int STATUS_RUNNING = 192; |
| 626 | |
| 627 | /** |
Steve Howard | 3e8c1d3 | 2010-09-29 17:03:32 -0700 | [diff] [blame] | 628 | * This download has been paused by the owning app. |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 629 | */ |
Steve Howard | 3e8c1d3 | 2010-09-29 17:03:32 -0700 | [diff] [blame] | 630 | public static final int STATUS_PAUSED_BY_APP = 193; |
| 631 | |
| 632 | /** |
| 633 | * This download encountered some network error and is waiting before retrying the request. |
| 634 | */ |
| 635 | public static final int STATUS_WAITING_TO_RETRY = 194; |
| 636 | |
| 637 | /** |
| 638 | * This download is waiting for network connectivity to proceed. |
| 639 | */ |
| 640 | public static final int STATUS_WAITING_FOR_NETWORK = 195; |
| 641 | |
| 642 | /** |
| 643 | * This download exceeded a size limit for mobile networks and is waiting for a Wi-Fi |
| 644 | * connection to proceed. |
| 645 | */ |
| 646 | public static final int STATUS_QUEUED_FOR_WIFI = 196; |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 647 | |
| 648 | /** |
Vasu Nori | 0ba3055 | 2011-02-08 17:18:27 -0800 | [diff] [blame] | 649 | * This download couldn't be completed due to insufficient storage |
| 650 | * space. Typically, this is because the SD card is full. |
| 651 | */ |
| 652 | public static final int STATUS_INSUFFICIENT_SPACE_ERROR = 198; |
| 653 | |
| 654 | /** |
| 655 | * This download couldn't be completed because no external storage |
| 656 | * device was found. Typically, this is because the SD card is not |
| 657 | * mounted. |
| 658 | */ |
| 659 | public static final int STATUS_DEVICE_NOT_FOUND_ERROR = 199; |
| 660 | |
| 661 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 662 | * This download has successfully completed. |
| 663 | * Warning: there might be other status values that indicate success |
| 664 | * in the future. |
Steve McKay | 996dab2 | 2016-01-17 08:32:20 -0800 | [diff] [blame] | 665 | * Use isStatusSuccess() to capture the entire category. |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 666 | */ |
| 667 | public static final int STATUS_SUCCESS = 200; |
| 668 | |
| 669 | /** |
| 670 | * This request couldn't be parsed. This is also used when processing |
| 671 | * requests with unknown/unsupported URI schemes. |
| 672 | */ |
| 673 | public static final int STATUS_BAD_REQUEST = 400; |
| 674 | |
| 675 | /** |
| 676 | * This download can't be performed because the content type cannot be |
| 677 | * handled. |
| 678 | */ |
| 679 | public static final int STATUS_NOT_ACCEPTABLE = 406; |
| 680 | |
| 681 | /** |
| 682 | * This download cannot be performed because the length cannot be |
| 683 | * determined accurately. This is the code for the HTTP error "Length |
| 684 | * Required", which is typically used when making requests that require |
| 685 | * a content length but don't have one, and it is also used in the |
| 686 | * client when a response is received whose length cannot be determined |
| 687 | * accurately (therefore making it impossible to know when a download |
| 688 | * completes). |
| 689 | */ |
| 690 | public static final int STATUS_LENGTH_REQUIRED = 411; |
| 691 | |
| 692 | /** |
| 693 | * This download was interrupted and cannot be resumed. |
| 694 | * This is the code for the HTTP error "Precondition Failed", and it is |
| 695 | * also used in situations where the client doesn't have an ETag at all. |
| 696 | */ |
| 697 | public static final int STATUS_PRECONDITION_FAILED = 412; |
| 698 | |
| 699 | /** |
Steve Howard | 33bbd12 | 2010-08-02 17:51:29 -0700 | [diff] [blame] | 700 | * The lowest-valued error status that is not an actual HTTP status code. |
| 701 | */ |
Steve Howard | a9e87c9 | 2010-09-16 12:02:03 -0700 | [diff] [blame] | 702 | public static final int MIN_ARTIFICIAL_ERROR_STATUS = 488; |
| 703 | |
| 704 | /** |
| 705 | * The requested destination file already exists. |
| 706 | */ |
| 707 | public static final int STATUS_FILE_ALREADY_EXISTS_ERROR = 488; |
Steve Howard | 33bbd12 | 2010-08-02 17:51:29 -0700 | [diff] [blame] | 708 | |
| 709 | /** |
| 710 | * Some possibly transient error occurred, but we can't resume the download. |
| 711 | */ |
| 712 | public static final int STATUS_CANNOT_RESUME = 489; |
| 713 | |
| 714 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 715 | * This download was canceled |
| 716 | */ |
| 717 | public static final int STATUS_CANCELED = 490; |
| 718 | |
| 719 | /** |
| 720 | * This download has completed with an error. |
| 721 | * Warning: there will be other status values that indicate errors in |
| 722 | * the future. Use isStatusError() to capture the entire category. |
| 723 | */ |
| 724 | public static final int STATUS_UNKNOWN_ERROR = 491; |
| 725 | |
| 726 | /** |
| 727 | * This download couldn't be completed because of a storage issue. |
| 728 | * Typically, that's because the filesystem is missing or full. |
Attila Bodis | f238ad7 | 2010-01-26 14:52:32 -0800 | [diff] [blame] | 729 | * Use the more specific {@link #STATUS_INSUFFICIENT_SPACE_ERROR} |
| 730 | * and {@link #STATUS_DEVICE_NOT_FOUND_ERROR} when appropriate. |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 731 | */ |
| 732 | public static final int STATUS_FILE_ERROR = 492; |
| 733 | |
| 734 | /** |
| 735 | * This download couldn't be completed because of an HTTP |
| 736 | * redirect response that the download manager couldn't |
| 737 | * handle. |
| 738 | */ |
| 739 | public static final int STATUS_UNHANDLED_REDIRECT = 493; |
| 740 | |
| 741 | /** |
| 742 | * This download couldn't be completed because of an |
| 743 | * unspecified unhandled HTTP code. |
| 744 | */ |
| 745 | public static final int STATUS_UNHANDLED_HTTP_CODE = 494; |
| 746 | |
| 747 | /** |
| 748 | * This download couldn't be completed because of an |
| 749 | * error receiving or processing data at the HTTP level. |
| 750 | */ |
| 751 | public static final int STATUS_HTTP_DATA_ERROR = 495; |
| 752 | |
| 753 | /** |
| 754 | * This download couldn't be completed because of an |
| 755 | * HttpException while setting up the request. |
| 756 | */ |
| 757 | public static final int STATUS_HTTP_EXCEPTION = 496; |
| 758 | |
| 759 | /** |
| 760 | * This download couldn't be completed because there were |
| 761 | * too many redirects. |
| 762 | */ |
| 763 | public static final int STATUS_TOO_MANY_REDIRECTS = 497; |
| 764 | |
| 765 | /** |
Jeff Sharkey | fdfef57 | 2011-06-16 15:07:48 -0700 | [diff] [blame] | 766 | * This download has failed because requesting application has been |
| 767 | * blocked by {@link NetworkPolicyManager}. |
| 768 | * |
| 769 | * @hide |
Jeff Sharkey | 15ec7d6 | 2012-04-17 12:23:40 -0700 | [diff] [blame] | 770 | * @deprecated since behavior now uses |
| 771 | * {@link #STATUS_WAITING_FOR_NETWORK} |
Jeff Sharkey | fdfef57 | 2011-06-16 15:07:48 -0700 | [diff] [blame] | 772 | */ |
Jeff Sharkey | 15ec7d6 | 2012-04-17 12:23:40 -0700 | [diff] [blame] | 773 | @Deprecated |
Jeff Sharkey | fdfef57 | 2011-06-16 15:07:48 -0700 | [diff] [blame] | 774 | public static final int STATUS_BLOCKED = 498; |
| 775 | |
Jeff Sharkey | 58d9fb6 | 2012-04-13 14:42:50 -0700 | [diff] [blame] | 776 | /** {@hide} */ |
| 777 | public static String statusToString(int status) { |
| 778 | switch (status) { |
| 779 | case STATUS_PENDING: return "PENDING"; |
| 780 | case STATUS_RUNNING: return "RUNNING"; |
| 781 | case STATUS_PAUSED_BY_APP: return "PAUSED_BY_APP"; |
| 782 | case STATUS_WAITING_TO_RETRY: return "WAITING_TO_RETRY"; |
| 783 | case STATUS_WAITING_FOR_NETWORK: return "WAITING_FOR_NETWORK"; |
| 784 | case STATUS_QUEUED_FOR_WIFI: return "QUEUED_FOR_WIFI"; |
| 785 | case STATUS_INSUFFICIENT_SPACE_ERROR: return "INSUFFICIENT_SPACE_ERROR"; |
| 786 | case STATUS_DEVICE_NOT_FOUND_ERROR: return "DEVICE_NOT_FOUND_ERROR"; |
| 787 | case STATUS_SUCCESS: return "SUCCESS"; |
| 788 | case STATUS_BAD_REQUEST: return "BAD_REQUEST"; |
| 789 | case STATUS_NOT_ACCEPTABLE: return "NOT_ACCEPTABLE"; |
| 790 | case STATUS_LENGTH_REQUIRED: return "LENGTH_REQUIRED"; |
| 791 | case STATUS_PRECONDITION_FAILED: return "PRECONDITION_FAILED"; |
| 792 | case STATUS_FILE_ALREADY_EXISTS_ERROR: return "FILE_ALREADY_EXISTS_ERROR"; |
| 793 | case STATUS_CANNOT_RESUME: return "CANNOT_RESUME"; |
| 794 | case STATUS_CANCELED: return "CANCELED"; |
| 795 | case STATUS_UNKNOWN_ERROR: return "UNKNOWN_ERROR"; |
| 796 | case STATUS_FILE_ERROR: return "FILE_ERROR"; |
| 797 | case STATUS_UNHANDLED_REDIRECT: return "UNHANDLED_REDIRECT"; |
| 798 | case STATUS_UNHANDLED_HTTP_CODE: return "UNHANDLED_HTTP_CODE"; |
| 799 | case STATUS_HTTP_DATA_ERROR: return "HTTP_DATA_ERROR"; |
| 800 | case STATUS_HTTP_EXCEPTION: return "HTTP_EXCEPTION"; |
| 801 | case STATUS_TOO_MANY_REDIRECTS: return "TOO_MANY_REDIRECTS"; |
| 802 | case STATUS_BLOCKED: return "BLOCKED"; |
| 803 | default: return Integer.toString(status); |
| 804 | } |
| 805 | } |
| 806 | |
Jeff Sharkey | fdfef57 | 2011-06-16 15:07:48 -0700 | [diff] [blame] | 807 | /** |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 808 | * This download is visible but only shows in the notifications |
| 809 | * while it's in progress. |
| 810 | */ |
Vasu Nori | 4c6e5df | 2010-10-26 17:00:16 -0700 | [diff] [blame] | 811 | public static final int VISIBILITY_VISIBLE = DownloadManager.Request.VISIBILITY_VISIBLE; |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 812 | |
| 813 | /** |
| 814 | * This download is visible and shows in the notifications while |
| 815 | * in progress and after completion. |
| 816 | */ |
Vasu Nori | 4c6e5df | 2010-10-26 17:00:16 -0700 | [diff] [blame] | 817 | public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED = |
| 818 | DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED; |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 819 | |
| 820 | /** |
| 821 | * This download doesn't show in the UI or in the notifications. |
| 822 | */ |
Vasu Nori | 4c6e5df | 2010-10-26 17:00:16 -0700 | [diff] [blame] | 823 | public static final int VISIBILITY_HIDDEN = DownloadManager.Request.VISIBILITY_HIDDEN; |
Steve Howard | ea9147d | 2010-07-13 19:02:45 -0700 | [diff] [blame] | 824 | |
| 825 | /** |
| 826 | * Constants related to HTTP request headers associated with each download. |
| 827 | */ |
| 828 | public static class RequestHeaders { |
| 829 | public static final String HEADERS_DB_TABLE = "request_headers"; |
| 830 | public static final String COLUMN_DOWNLOAD_ID = "download_id"; |
| 831 | public static final String COLUMN_HEADER = "header"; |
| 832 | public static final String COLUMN_VALUE = "value"; |
| 833 | |
| 834 | /** |
| 835 | * Path segment to add to a download URI to retrieve request headers |
| 836 | */ |
| 837 | public static final String URI_SEGMENT = "headers"; |
| 838 | |
| 839 | /** |
| 840 | * Prefix for ContentValues keys that contain HTTP header lines, to be passed to |
| 841 | * DownloadProvider.insert(). |
| 842 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 843 | @UnsupportedAppUsage |
Steve Howard | ea9147d | 2010-07-13 19:02:45 -0700 | [diff] [blame] | 844 | public static final String INSERT_KEY_PREFIX = "http_header_"; |
| 845 | } |
Jean-Baptiste Queru | 32d80bf | 2010-01-13 15:49:16 -0800 | [diff] [blame] | 846 | } |
Jeff Sharkey | 948eef8 | 2012-03-20 17:44:42 -0700 | [diff] [blame] | 847 | |
Sudheer Shanka | e93db51 | 2019-01-11 16:05:28 -0800 | [diff] [blame] | 848 | /** @hide */ |
| 849 | public static final String MEDIASTORE_DOWNLOADS_DELETED_CALL = "mediastore_downloads_deleted"; |
| 850 | |
| 851 | /** @hide */ |
| 852 | public static final String EXTRA_IDS = "ids"; |
| 853 | /** @hide */ |
| 854 | public static final String EXTRA_MIME_TYPES = "mime_types"; |
| 855 | |
Jeff Sharkey | 948eef8 | 2012-03-20 17:44:42 -0700 | [diff] [blame] | 856 | /** |
| 857 | * Query where clause for general querying. |
| 858 | */ |
| 859 | private static final String QUERY_WHERE_CLAUSE = Impl.COLUMN_NOTIFICATION_PACKAGE + "=? AND " |
| 860 | + Impl.COLUMN_NOTIFICATION_CLASS + "=?"; |
| 861 | |
| 862 | /** |
| 863 | * Delete all the downloads for a package/class pair. |
| 864 | */ |
| 865 | public static final void removeAllDownloadsByPackage( |
| 866 | Context context, String notification_package, String notification_class) { |
| 867 | context.getContentResolver().delete(Impl.CONTENT_URI, QUERY_WHERE_CLAUSE, |
| 868 | new String[] { notification_package, notification_class }); |
| 869 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 870 | } |