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 19 import android.net.Uri; 20 21 /** 22 * The Download Manager 23 * 24 * @pending 25 */ 26 public final class Downloads { 27 /** 28 * @hide 29 */ 30 private Downloads() {} 31 32 /** 33 * The permission to access the download manager 34 * @hide 35 */ 36 public static final String PERMISSION_ACCESS = "android.permission.ACCESS_DOWNLOAD_MANAGER"; 37 38 /** 39 * The permission to access the download manager's advanced functions 40 * @hide 41 */ 42 public static final String PERMISSION_ACCESS_ADVANCED = 43 "android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED"; 44 45 /** 46 * The permission to directly access the download manager's cache directory 47 * @hide 48 */ 49 public static final String PERMISSION_CACHE = "android.permission.ACCESS_CACHE_FILESYSTEM"; 50 51 /** 52 * The permission to send broadcasts on download completion 53 * @hide 54 */ 55 public static final String PERMISSION_SEND_INTENTS = 56 "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS"; 57 58 /** 59 * The content:// URI for the data table in the provider 60 * @hide 61 */ 62 public static final Uri CONTENT_URI = 63 Uri.parse("content://downloads/my_downloads"); 64 65 /** 66 * Broadcast Action: this is sent by the download manager to the app 67 * that had initiated a download when that download completes. The 68 * download's content: uri is specified in the intent's data. 69 * @hide 70 */ 71 public static final String ACTION_DOWNLOAD_COMPLETED = 72 "android.intent.action.DOWNLOAD_COMPLETED"; 73 74 /** 75 * Broadcast Action: this is sent by the download manager to the app 76 * that had initiated a download when the user selects the notification 77 * associated with that download. The download's content: uri is specified 78 * in the intent's data if the click is associated with a single download, 79 * or Downloads.CONTENT_URI if the notification is associated with 80 * multiple downloads. 81 * Note: this is not currently sent for downloads that have completed 82 * successfully. 83 * @hide 84 */ 85 public static final String ACTION_NOTIFICATION_CLICKED = 86 "android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED"; 87 88 /** 89 * The name of the column containing the URI of the data being downloaded. 90 * <P>Type: TEXT</P> 91 * <P>Owner can Init/Read</P> 92 * @hide 93 */ 94 public static final String COLUMN_URI = "uri"; 95 96 /** 97 * The name of the column containing application-specific data. 98 * <P>Type: TEXT</P> 99 * <P>Owner can Init/Read/Write</P> 100 * @hide 101 */ 102 public static final String COLUMN_APP_DATA = "entity"; 103 104 /** 105 * The name of the column containing the flags that indicates whether 106 * the initiating application is capable of verifying the integrity of 107 * the downloaded file. When this flag is set, the download manager 108 * performs downloads and reports success even in some situations where 109 * it can't guarantee that the download has completed (e.g. when doing 110 * a byte-range request without an ETag, or when it can't determine 111 * whether a download fully completed). 112 * <P>Type: BOOLEAN</P> 113 * <P>Owner can Init</P> 114 * @hide 115 */ 116 public static final String COLUMN_NO_INTEGRITY = "no_integrity"; 117 118 /** 119 * The name of the column containing the filename that the initiating 120 * application recommends. When possible, the download manager will attempt 121 * to use this filename, or a variation, as the actual name for the file. 122 * <P>Type: TEXT</P> 123 * <P>Owner can Init</P> 124 * @hide 125 */ 126 public static final String COLUMN_FILE_NAME_HINT = "hint"; 127 128 /** 129 * The name of the column containing the filename where the downloaded data 130 * was actually stored. 131 * <P>Type: TEXT</P> 132 * <P>Owner can Read</P> 133 * @hide 134 */ 135 public static final String _DATA = "_data"; 136 137 /** 138 * The name of the column containing the MIME type of the downloaded data. 139 * <P>Type: TEXT</P> 140 * <P>Owner can Init/Read</P> 141 * @hide 142 */ 143 public static final String COLUMN_MIME_TYPE = "mimetype"; 144 145 /** 146 * The name of the column containing the flag that controls the destination 147 * of the download. See the DESTINATION_* constants for a list of legal values. 148 * <P>Type: INTEGER</P> 149 * <P>Owner can Init</P> 150 * @hide 151 */ 152 public static final String COLUMN_DESTINATION = "destination"; 153 154 /** 155 * The name of the column containing the flags that controls whether the 156 * download is displayed by the UI. See the VISIBILITY_* constants for 157 * a list of legal values. 158 * <P>Type: INTEGER</P> 159 * <P>Owner can Init/Read/Write</P> 160 * @hide 161 */ 162 public static final String COLUMN_VISIBILITY = "visibility"; 163 164 /** 165 * The name of the column containing the current control state of the download. 166 * Applications can write to this to control (pause/resume) the download. 167 * the CONTROL_* constants for a list of legal values. 168 * <P>Type: INTEGER</P> 169 * <P>Owner can Read</P> 170 * @hide 171 */ 172 public static final String COLUMN_CONTROL = "control"; 173 174 /** 175 * The name of the column containing the current status of the download. 176 * Applications can read this to follow the progress of each download. See 177 * the STATUS_* constants for a list of legal values. 178 * <P>Type: INTEGER</P> 179 * <P>Owner can Read</P> 180 * @hide 181 */ 182 public static final String COLUMN_STATUS = "status"; 183 184 /** 185 * The name of the column containing the date at which some interesting 186 * status changed in the download. Stored as a System.currentTimeMillis() 187 * value. 188 * <P>Type: BIGINT</P> 189 * <P>Owner can Read</P> 190 * @hide 191 */ 192 public static final String COLUMN_LAST_MODIFICATION = "lastmod"; 193 194 /** 195 * The name of the column containing the package name of the application 196 * that initiating the download. The download manager will send 197 * notifications to a component in this package when the download completes. 198 * <P>Type: TEXT</P> 199 * <P>Owner can Init/Read</P> 200 * @hide 201 */ 202 public static final String COLUMN_NOTIFICATION_PACKAGE = "notificationpackage"; 203 204 /** 205 * The name of the column containing the component name of the class that 206 * will receive notifications associated with the download. The 207 * package/class combination is passed to 208 * Intent.setClassName(String,String). 209 * <P>Type: TEXT</P> 210 * <P>Owner can Init/Read</P> 211 * @hide 212 */ 213 public static final String COLUMN_NOTIFICATION_CLASS = "notificationclass"; 214 215 /** 216 * If extras are specified when requesting a download they will be provided in the intent that 217 * is sent to the specified class and package when a download has finished. 218 * <P>Type: TEXT</P> 219 * <P>Owner can Init</P> 220 * @hide 221 */ 222 public static final String COLUMN_NOTIFICATION_EXTRAS = "notificationextras"; 223 224 /** 225 * The name of the column contain the values of the cookie to be used for 226 * the download. This is used directly as the value for the Cookie: HTTP 227 * header that gets sent with the request. 228 * <P>Type: TEXT</P> 229 * <P>Owner can Init</P> 230 * @hide 231 */ 232 public static final String COLUMN_COOKIE_DATA = "cookiedata"; 233 234 /** 235 * The name of the column containing the user agent that the initiating 236 * application wants the download manager to use for this download. 237 * <P>Type: TEXT</P> 238 * <P>Owner can Init</P> 239 * @hide 240 */ 241 public static final String COLUMN_USER_AGENT = "useragent"; 242 243 /** 244 * The name of the column containing the referer (sic) that the initiating 245 * application wants the download manager to use for this download. 246 * <P>Type: TEXT</P> 247 * <P>Owner can Init</P> 248 * @hide 249 */ 250 public static final String COLUMN_REFERER = "referer"; 251 252 /** 253 * The name of the column containing the total size of the file being 254 * downloaded. 255 * <P>Type: INTEGER</P> 256 * <P>Owner can Read</P> 257 * @hide 258 */ 259 public static final String COLUMN_TOTAL_BYTES = "total_bytes"; 260 261 /** 262 * The name of the column containing the size of the part of the file that 263 * has been downloaded so far. 264 * <P>Type: INTEGER</P> 265 * <P>Owner can Read</P> 266 * @hide 267 */ 268 public static final String COLUMN_CURRENT_BYTES = "current_bytes"; 269 270 /** 271 * The name of the column where the initiating application can provide the 272 * UID of another application that is allowed to access this download. If 273 * multiple applications share the same UID, all those applications will be 274 * allowed to access this download. This column can be updated after the 275 * download is initiated. This requires the permission 276 * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED. 277 * <P>Type: INTEGER</P> 278 * <P>Owner can Init</P> 279 * @hide 280 */ 281 public static final String COLUMN_OTHER_UID = "otheruid"; 282 283 /** 284 * The name of the column where the initiating application can provided the 285 * title of this download. The title will be displayed ito the user in the 286 * list of downloads. 287 * <P>Type: TEXT</P> 288 * <P>Owner can Init/Read/Write</P> 289 * @hide 290 */ 291 public static final String COLUMN_TITLE = "title"; 292 293 /** 294 * The name of the column where the initiating application can provide the 295 * description of this download. The description will be displayed to the 296 * user in the list of downloads. 297 * <P>Type: TEXT</P> 298 * <P>Owner can Init/Read/Write</P> 299 * @hide 300 */ 301 public static final String COLUMN_DESCRIPTION = "description"; 302 303 /** 304 * Set to true if this download is deleted. It is completely removed from the database 305 * when MediaProvider database also deletes the metadata asociated with this downloaded file. 306 * <P>Type: BOOLEAN</P> 307 * <P>Owner can Read</P> 308 * @hide 309 */ 310 public static final String COLUMN_DELETED = "deleted"; 311 312 /* 313 * Lists the destinations that an application can specify for a download. 314 */ 315 316 /** 317 * This download will be saved to the external storage. This is the 318 * default behavior, and should be used for any file that the user 319 * can freely access, copy, delete. Even with that destination, 320 * unencrypted DRM files are saved in secure internal storage. 321 * Downloads to the external destination only write files for which 322 * there is a registered handler. The resulting files are accessible 323 * by filename to all applications. 324 * @hide 325 */ 326 public static final int DESTINATION_EXTERNAL = 0; 327 328 /** 329 * This download will be saved to the download manager's private 330 * partition. This is the behavior used by applications that want to 331 * download private files that are used and deleted soon after they 332 * get downloaded. All file types are allowed, and only the initiating 333 * application can access the file (indirectly through a content 334 * provider). This requires the 335 * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED permission. 336 * @hide 337 */ 338 public static final int DESTINATION_CACHE_PARTITION = 1; 339 340 /** 341 * This download will be saved to the download manager's private 342 * partition and will be purged as necessary to make space. This is 343 * for private files (similar to CACHE_PARTITION) that aren't deleted 344 * immediately after they are used, and are kept around by the download 345 * manager as long as space is available. 346 * @hide 347 */ 348 public static final int DESTINATION_CACHE_PARTITION_PURGEABLE = 2; 349 350 /** 351 * This download will be saved to the download manager's private 352 * partition, as with DESTINATION_CACHE_PARTITION, but the download 353 * will not proceed if the user is on a roaming data connection. 354 * @hide 355 */ 356 public static final int DESTINATION_CACHE_PARTITION_NOROAMING = 3; 357 358 /** 359 * This download is allowed to run. 360 * @hide 361 */ 362 public static final int CONTROL_RUN = 0; 363 364 /** 365 * This download must pause at the first opportunity. 366 * @hide 367 */ 368 public static final int CONTROL_PAUSED = 1; 369 370 /* 371 * Lists the states that the download manager can set on a download 372 * to notify applications of the download progress. 373 * The codes follow the HTTP families:<br> 374 * 1xx: informational<br> 375 * 2xx: success<br> 376 * 3xx: redirects (not used by the download manager)<br> 377 * 4xx: client errors<br> 378 * 5xx: server errors 379 */ 380 381 /** 382 * Returns whether the status is informational (i.e. 1xx). 383 * @hide 384 */ 385 public static boolean isStatusInformational(int status) { 386 return (status >= 100 && status < 200); 387 } 388 389 /** 390 * Returns whether the status is a success (i.e. 2xx). 391 * @hide 392 */ 393 public static boolean isStatusSuccess(int status) { 394 return (status >= 200 && status < 300); 395 } 396 397 /** 398 * Returns whether the status is an error (i.e. 4xx or 5xx). 399 * @hide 400 */ 401 public static boolean isStatusError(int status) { 402 return (status >= 400 && status < 600); 403 } 404 405 /** 406 * Returns whether the status is a client error (i.e. 4xx). 407 * @hide 408 */ 409 public static boolean isStatusClientError(int status) { 410 return (status >= 400 && status < 500); 411 } 412 413 /** 414 * Returns whether the status is a server error (i.e. 5xx). 415 * @hide 416 */ 417 public static boolean isStatusServerError(int status) { 418 return (status >= 500 && status < 600); 419 } 420 421 /** 422 * Returns whether the download has completed (either with success or 423 * error). 424 * @hide 425 */ 426 public static boolean isStatusCompleted(int status) { 427 return (status >= 200 && status < 300) || (status >= 400 && status < 600); 428 } 429 430 /** 431 * This download hasn't stated yet 432 * @hide 433 */ 434 public static final int STATUS_PENDING = 190; 435 436 /** 437 * This download has started 438 * @hide 439 */ 440 public static final int STATUS_RUNNING = 192; 441 442 /** 443 * This download has successfully completed. 444 * Warning: there might be other status values that indicate success 445 * in the future. 446 * Use isSucccess() to capture the entire category. 447 * @hide 448 */ 449 public static final int STATUS_SUCCESS = 200; 450 451 /** 452 * This request couldn't be parsed. This is also used when processing 453 * requests with unknown/unsupported URI schemes. 454 * @hide 455 */ 456 public static final int STATUS_BAD_REQUEST = 400; 457 458 /** 459 * This download can't be performed because the content type cannot be 460 * handled. 461 * @hide 462 */ 463 public static final int STATUS_NOT_ACCEPTABLE = 406; 464 465 /** 466 * This download cannot be performed because the length cannot be 467 * determined accurately. This is the code for the HTTP error "Length 468 * Required", which is typically used when making requests that require 469 * a content length but don't have one, and it is also used in the 470 * client when a response is received whose length cannot be determined 471 * accurately (therefore making it impossible to know when a download 472 * completes). 473 * @hide 474 */ 475 public static final int STATUS_LENGTH_REQUIRED = 411; 476 477 /** 478 * This download was interrupted and cannot be resumed. 479 * This is the code for the HTTP error "Precondition Failed", and it is 480 * also used in situations where the client doesn't have an ETag at all. 481 * @hide 482 */ 483 public static final int STATUS_PRECONDITION_FAILED = 412; 484 485 /** 486 * This download was canceled 487 * @hide 488 */ 489 public static final int STATUS_CANCELED = 490; 490 491 /** 492 * This download has completed with an error. 493 * Warning: there will be other status values that indicate errors in 494 * the future. Use isStatusError() to capture the entire category. 495 * @hide 496 */ 497 public static final int STATUS_UNKNOWN_ERROR = 491; 498 499 /** 500 * This download couldn't be completed because of a storage issue. 501 * Typically, that's because the filesystem is missing or full. 502 * Use the more specific {@link #STATUS_INSUFFICIENT_SPACE_ERROR} 503 * and {@link #STATUS_DEVICE_NOT_FOUND_ERROR} when appropriate. 504 * @hide 505 */ 506 public static final int STATUS_FILE_ERROR = 492; 507 508 /** 509 * This download couldn't be completed because of an HTTP 510 * redirect response that the download manager couldn't 511 * handle. 512 * @hide 513 */ 514 public static final int STATUS_UNHANDLED_REDIRECT = 493; 515 516 /** 517 * This download couldn't be completed because of an 518 * unspecified unhandled HTTP code. 519 * @hide 520 */ 521 public static final int STATUS_UNHANDLED_HTTP_CODE = 494; 522 523 /** 524 * This download couldn't be completed because of an 525 * error receiving or processing data at the HTTP level. 526 * @hide 527 */ 528 public static final int STATUS_HTTP_DATA_ERROR = 495; 529 530 /** 531 * This download couldn't be completed because of an 532 * HttpException while setting up the request. 533 * @hide 534 */ 535 public static final int STATUS_HTTP_EXCEPTION = 496; 536 537 /** 538 * This download couldn't be completed because there were 539 * too many redirects. 540 * @hide 541 */ 542 public static final int STATUS_TOO_MANY_REDIRECTS = 497; 543 544 /** 545 * This download couldn't be completed due to insufficient storage 546 * space. Typically, this is because the SD card is full. 547 * @hide 548 */ 549 public static final int STATUS_INSUFFICIENT_SPACE_ERROR = 498; 550 551 /** 552 * This download couldn't be completed because no external storage 553 * device was found. Typically, this is because the SD card is not 554 * mounted. 555 * @hide 556 */ 557 public static final int STATUS_DEVICE_NOT_FOUND_ERROR = 499; 558 559 /** 560 * This download is visible but only shows in the notifications 561 * while it's in progress. 562 * @hide 563 */ 564 public static final int VISIBILITY_VISIBLE = 0; 565 566 /** 567 * This download is visible and shows in the notifications while 568 * in progress and after completion. 569 * @hide 570 */ 571 public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED = 1; 572 573 /** 574 * This download doesn't show in the UI or in the notifications. 575 * @hide 576 */ 577 public static final int VISIBILITY_HIDDEN = 2; 578 579 /** 580 * Implementation details 581 * 582 * Exposes constants used to interact with the download manager's 583 * content provider. 584 * The constants URI ... STATUS are the names of columns in the downloads table. 585 * 586 * @hide 587 */ 588 public static final class Impl implements BaseColumns { 589 private Impl() {} 590 591 /** 592 * The permission to access the download manager 593 */ 594 public static final String PERMISSION_ACCESS = "android.permission.ACCESS_DOWNLOAD_MANAGER"; 595 596 /** 597 * The permission to access the download manager's advanced functions 598 */ 599 public static final String PERMISSION_ACCESS_ADVANCED = 600 "android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED"; 601 602 /** 603 * The permission to directly access the download manager's cache directory 604 */ 605 public static final String PERMISSION_CACHE = "android.permission.ACCESS_CACHE_FILESYSTEM"; 606 607 /** 608 * The permission to send broadcasts on download completion 609 */ 610 public static final String PERMISSION_SEND_INTENTS = 611 "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS"; 612 613 /** 614 * The permission to download files to the cache partition that won't be automatically 615 * purged when space is needed. 616 */ 617 public static final String PERMISSION_CACHE_NON_PURGEABLE = 618 "android.permission.DOWNLOAD_CACHE_NON_PURGEABLE"; 619 620 /** 621 * The permission to download files without any system notification being shown. 622 */ 623 public static final String PERMISSION_NO_NOTIFICATION = 624 "android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"; 625 626 /** 627 * The content:// URI to access downloads owned by the caller's UID. 628 */ 629 public static final Uri CONTENT_URI = 630 Uri.parse("content://downloads/my_downloads"); 631 632 /** 633 * The content URI for accessing all downloads across all UIDs (requires the 634 * ACCESS_ALL_DOWNLOADS permission). 635 */ 636 public static final Uri ALL_DOWNLOADS_CONTENT_URI = 637 Uri.parse("content://downloads/all_downloads"); 638 639 /** 640 * Broadcast Action: this is sent by the download manager to the app 641 * that had initiated a download when that download completes. The 642 * download's content: uri is specified in the intent's data. 643 */ 644 public static final String ACTION_DOWNLOAD_COMPLETED = 645 "android.intent.action.DOWNLOAD_COMPLETED"; 646 647 /** 648 * Broadcast Action: this is sent by the download manager to the app 649 * that had initiated a download when the user selects the notification 650 * associated with that download. The download's content: uri is specified 651 * in the intent's data if the click is associated with a single download, 652 * or Downloads.CONTENT_URI if the notification is associated with 653 * multiple downloads. 654 * Note: this is not currently sent for downloads that have completed 655 * successfully. 656 */ 657 public static final String ACTION_NOTIFICATION_CLICKED = 658 "android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED"; 659 660 /** 661 * The name of the column containing the URI of the data being downloaded. 662 * <P>Type: TEXT</P> 663 * <P>Owner can Init/Read</P> 664 */ 665 public static final String COLUMN_URI = "uri"; 666 667 /** 668 * The name of the column containing application-specific data. 669 * <P>Type: TEXT</P> 670 * <P>Owner can Init/Read/Write</P> 671 */ 672 public static final String COLUMN_APP_DATA = "entity"; 673 674 /** 675 * The name of the column containing the flags that indicates whether 676 * the initiating application is capable of verifying the integrity of 677 * the downloaded file. When this flag is set, the download manager 678 * performs downloads and reports success even in some situations where 679 * it can't guarantee that the download has completed (e.g. when doing 680 * a byte-range request without an ETag, or when it can't determine 681 * whether a download fully completed). 682 * <P>Type: BOOLEAN</P> 683 * <P>Owner can Init</P> 684 */ 685 public static final String COLUMN_NO_INTEGRITY = "no_integrity"; 686 687 /** 688 * The name of the column containing the filename that the initiating 689 * application recommends. When possible, the download manager will attempt 690 * to use this filename, or a variation, as the actual name for the file. 691 * <P>Type: TEXT</P> 692 * <P>Owner can Init</P> 693 */ 694 public static final String COLUMN_FILE_NAME_HINT = "hint"; 695 696 /** 697 * The name of the column containing the filename where the downloaded data 698 * was actually stored. 699 * <P>Type: TEXT</P> 700 * <P>Owner can Read</P> 701 */ 702 public static final String _DATA = "_data"; 703 704 /** 705 * The name of the column containing the MIME type of the downloaded data. 706 * <P>Type: TEXT</P> 707 * <P>Owner can Init/Read</P> 708 */ 709 public static final String COLUMN_MIME_TYPE = "mimetype"; 710 711 /** 712 * The name of the column containing the flag that controls the destination 713 * of the download. See the DESTINATION_* constants for a list of legal values. 714 * <P>Type: INTEGER</P> 715 * <P>Owner can Init</P> 716 */ 717 public static final String COLUMN_DESTINATION = "destination"; 718 719 /** 720 * The name of the column containing the flags that controls whether the 721 * download is displayed by the UI. See the VISIBILITY_* constants for 722 * a list of legal values. 723 * <P>Type: INTEGER</P> 724 * <P>Owner can Init/Read/Write</P> 725 */ 726 public static final String COLUMN_VISIBILITY = "visibility"; 727 728 /** 729 * The name of the column containing the current control state of the download. 730 * Applications can write to this to control (pause/resume) the download. 731 * the CONTROL_* constants for a list of legal values. 732 * <P>Type: INTEGER</P> 733 * <P>Owner can Read</P> 734 */ 735 public static final String COLUMN_CONTROL = "control"; 736 737 /** 738 * The name of the column containing the current status of the download. 739 * Applications can read this to follow the progress of each download. See 740 * the STATUS_* constants for a list of legal values. 741 * <P>Type: INTEGER</P> 742 * <P>Owner can Read</P> 743 */ 744 public static final String COLUMN_STATUS = "status"; 745 746 /** 747 * The name of the column containing the date at which some interesting 748 * status changed in the download. Stored as a System.currentTimeMillis() 749 * value. 750 * <P>Type: BIGINT</P> 751 * <P>Owner can Read</P> 752 */ 753 public static final String COLUMN_LAST_MODIFICATION = "lastmod"; 754 755 /** 756 * The name of the column containing the package name of the application 757 * that initiating the download. The download manager will send 758 * notifications to a component in this package when the download completes. 759 * <P>Type: TEXT</P> 760 * <P>Owner can Init/Read</P> 761 */ 762 public static final String COLUMN_NOTIFICATION_PACKAGE = "notificationpackage"; 763 764 /** 765 * The name of the column containing the component name of the class that 766 * will receive notifications associated with the download. The 767 * package/class combination is passed to 768 * Intent.setClassName(String,String). 769 * <P>Type: TEXT</P> 770 * <P>Owner can Init/Read</P> 771 */ 772 public static final String COLUMN_NOTIFICATION_CLASS = "notificationclass"; 773 774 /** 775 * If extras are specified when requesting a download they will be provided in the intent that 776 * is sent to the specified class and package when a download has finished. 777 * <P>Type: TEXT</P> 778 * <P>Owner can Init</P> 779 */ 780 public static final String COLUMN_NOTIFICATION_EXTRAS = "notificationextras"; 781 782 /** 783 * The name of the column contain the values of the cookie to be used for 784 * the download. This is used directly as the value for the Cookie: HTTP 785 * header that gets sent with the request. 786 * <P>Type: TEXT</P> 787 * <P>Owner can Init</P> 788 */ 789 public static final String COLUMN_COOKIE_DATA = "cookiedata"; 790 791 /** 792 * The name of the column containing the user agent that the initiating 793 * application wants the download manager to use for this download. 794 * <P>Type: TEXT</P> 795 * <P>Owner can Init</P> 796 */ 797 public static final String COLUMN_USER_AGENT = "useragent"; 798 799 /** 800 * The name of the column containing the referer (sic) that the initiating 801 * application wants the download manager to use for this download. 802 * <P>Type: TEXT</P> 803 * <P>Owner can Init</P> 804 */ 805 public static final String COLUMN_REFERER = "referer"; 806 807 /** 808 * The name of the column containing the total size of the file being 809 * downloaded. 810 * <P>Type: INTEGER</P> 811 * <P>Owner can Read</P> 812 */ 813 public static final String COLUMN_TOTAL_BYTES = "total_bytes"; 814 815 /** 816 * The name of the column containing the size of the part of the file that 817 * has been downloaded so far. 818 * <P>Type: INTEGER</P> 819 * <P>Owner can Read</P> 820 */ 821 public static final String COLUMN_CURRENT_BYTES = "current_bytes"; 822 823 /** 824 * The name of the column where the initiating application can provide the 825 * UID of another application that is allowed to access this download. If 826 * multiple applications share the same UID, all those applications will be 827 * allowed to access this download. This column can be updated after the 828 * download is initiated. This requires the permission 829 * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED. 830 * <P>Type: INTEGER</P> 831 * <P>Owner can Init</P> 832 */ 833 public static final String COLUMN_OTHER_UID = "otheruid"; 834 835 /** 836 * The name of the column where the initiating application can provided the 837 * title of this download. The title will be displayed ito the user in the 838 * list of downloads. 839 * <P>Type: TEXT</P> 840 * <P>Owner can Init/Read/Write</P> 841 */ 842 public static final String COLUMN_TITLE = "title"; 843 844 /** 845 * The name of the column where the initiating application can provide the 846 * description of this download. The description will be displayed to the 847 * user in the list of downloads. 848 * <P>Type: TEXT</P> 849 * <P>Owner can Init/Read/Write</P> 850 */ 851 public static final String COLUMN_DESCRIPTION = "description"; 852 853 /** 854 * The name of the column indicating whether the download was requesting through the public 855 * API. This controls some differences in behavior. 856 * <P>Type: BOOLEAN</P> 857 * <P>Owner can Init/Read</P> 858 */ 859 public static final String COLUMN_IS_PUBLIC_API = "is_public_api"; 860 861 /** 862 * The name of the column indicating whether roaming connections can be used. This is only 863 * used for public API downloads. 864 * <P>Type: BOOLEAN</P> 865 * <P>Owner can Init/Read</P> 866 */ 867 public static final String COLUMN_ALLOW_ROAMING = "allow_roaming"; 868 869 /** 870 * The name of the column holding a bitmask of allowed network types. This is only used for 871 * public API downloads. 872 * <P>Type: INTEGER</P> 873 * <P>Owner can Init/Read</P> 874 */ 875 public static final String COLUMN_ALLOWED_NETWORK_TYPES = "allowed_network_types"; 876 877 /** 878 * Whether or not this download should be displayed in the system's Downloads UI. Defaults 879 * to true. 880 * <P>Type: INTEGER</P> 881 * <P>Owner can Init/Read</P> 882 */ 883 public static final String COLUMN_IS_VISIBLE_IN_DOWNLOADS_UI = "is_visible_in_downloads_ui"; 884 885 /** 886 * If true, the user has confirmed that this download can proceed over the mobile network 887 * even though it exceeds the recommended maximum size. 888 * <P>Type: BOOLEAN</P> 889 */ 890 public static final String COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT = 891 "bypass_recommended_size_limit"; 892 893 /** 894 * Set to true if this download is deleted. It is completely removed from the database 895 * when MediaProvider database also deletes the metadata asociated with this downloaded file. 896 * <P>Type: BOOLEAN</P> 897 * <P>Owner can Read</P> 898 */ 899 public static final String COLUMN_DELETED = "deleted"; 900 901 /** 902 * The URI to the corresponding entry in MediaProvider for this downloaded entry. It is 903 * used to delete the entries from MediaProvider database when it is deleted from the 904 * downloaded list. 905 * <P>Type: TEXT</P> 906 * <P>Owner can Read</P> 907 */ 908 public static final String COLUMN_MEDIAPROVIDER_URI = "mediaprovider_uri"; 909 910 /* 911 * Lists the destinations that an application can specify for a download. 912 */ 913 914 /** 915 * This download will be saved to the external storage. This is the 916 * default behavior, and should be used for any file that the user 917 * can freely access, copy, delete. Even with that destination, 918 * unencrypted DRM files are saved in secure internal storage. 919 * Downloads to the external destination only write files for which 920 * there is a registered handler. The resulting files are accessible 921 * by filename to all applications. 922 */ 923 public static final int DESTINATION_EXTERNAL = 0; 924 925 /** 926 * This download will be saved to the download manager's private 927 * partition. This is the behavior used by applications that want to 928 * download private files that are used and deleted soon after they 929 * get downloaded. All file types are allowed, and only the initiating 930 * application can access the file (indirectly through a content 931 * provider). This requires the 932 * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED permission. 933 */ 934 public static final int DESTINATION_CACHE_PARTITION = 1; 935 936 /** 937 * This download will be saved to the download manager's private 938 * partition and will be purged as necessary to make space. This is 939 * for private files (similar to CACHE_PARTITION) that aren't deleted 940 * immediately after they are used, and are kept around by the download 941 * manager as long as space is available. 942 */ 943 public static final int DESTINATION_CACHE_PARTITION_PURGEABLE = 2; 944 945 /** 946 * This download will be saved to the download manager's private 947 * partition, as with DESTINATION_CACHE_PARTITION, but the download 948 * will not proceed if the user is on a roaming data connection. 949 */ 950 public static final int DESTINATION_CACHE_PARTITION_NOROAMING = 3; 951 952 /** 953 * This download will be saved to the location given by the file URI in 954 * {@link #COLUMN_FILE_NAME_HINT}. 955 */ 956 public static final int DESTINATION_FILE_URI = 4; 957 958 /** 959 * This download is allowed to run. 960 */ 961 public static final int CONTROL_RUN = 0; 962 963 /** 964 * This download must pause at the first opportunity. 965 */ 966 public static final int CONTROL_PAUSED = 1; 967 968 /* 969 * Lists the states that the download manager can set on a download 970 * to notify applications of the download progress. 971 * The codes follow the HTTP families:<br> 972 * 1xx: informational<br> 973 * 2xx: success<br> 974 * 3xx: redirects (not used by the download manager)<br> 975 * 4xx: client errors<br> 976 * 5xx: server errors 977 */ 978 979 /** 980 * Returns whether the status is informational (i.e. 1xx). 981 */ 982 public static boolean isStatusInformational(int status) { 983 return (status >= 100 && status < 200); 984 } 985 986 /** 987 * Returns whether the status is a success (i.e. 2xx). 988 */ 989 public static boolean isStatusSuccess(int status) { 990 return (status >= 200 && status < 300); 991 } 992 993 /** 994 * Returns whether the status is an error (i.e. 4xx or 5xx). 995 */ 996 public static boolean isStatusError(int status) { 997 return (status >= 400 && status < 600); 998 } 999 1000 /** 1001 * Returns whether the status is a client error (i.e. 4xx). 1002 */ 1003 public static boolean isStatusClientError(int status) { 1004 return (status >= 400 && status < 500); 1005 } 1006 1007 /** 1008 * Returns whether the status is a server error (i.e. 5xx). 1009 */ 1010 public static boolean isStatusServerError(int status) { 1011 return (status >= 500 && status < 600); 1012 } 1013 1014 /** 1015 * Returns whether the download has completed (either with success or 1016 * error). 1017 */ 1018 public static boolean isStatusCompleted(int status) { 1019 return (status >= 200 && status < 300) || (status >= 400 && status < 600); 1020 } 1021 1022 /** 1023 * This download hasn't stated yet 1024 */ 1025 public static final int STATUS_PENDING = 190; 1026 1027 /** 1028 * This download has started 1029 */ 1030 public static final int STATUS_RUNNING = 192; 1031 1032 /** 1033 * This download has been paused by the owning app. 1034 */ 1035 public static final int STATUS_PAUSED_BY_APP = 193; 1036 1037 /** 1038 * This download encountered some network error and is waiting before retrying the request. 1039 */ 1040 public static final int STATUS_WAITING_TO_RETRY = 194; 1041 1042 /** 1043 * This download is waiting for network connectivity to proceed. 1044 */ 1045 public static final int STATUS_WAITING_FOR_NETWORK = 195; 1046 1047 /** 1048 * This download exceeded a size limit for mobile networks and is waiting for a Wi-Fi 1049 * connection to proceed. 1050 */ 1051 public static final int STATUS_QUEUED_FOR_WIFI = 196; 1052 1053 /** 1054 * This download has successfully completed. 1055 * Warning: there might be other status values that indicate success 1056 * in the future. 1057 * Use isSucccess() to capture the entire category. 1058 */ 1059 public static final int STATUS_SUCCESS = 200; 1060 1061 /** 1062 * This request couldn't be parsed. This is also used when processing 1063 * requests with unknown/unsupported URI schemes. 1064 */ 1065 public static final int STATUS_BAD_REQUEST = 400; 1066 1067 /** 1068 * This download can't be performed because the content type cannot be 1069 * handled. 1070 */ 1071 public static final int STATUS_NOT_ACCEPTABLE = 406; 1072 1073 /** 1074 * This download cannot be performed because the length cannot be 1075 * determined accurately. This is the code for the HTTP error "Length 1076 * Required", which is typically used when making requests that require 1077 * a content length but don't have one, and it is also used in the 1078 * client when a response is received whose length cannot be determined 1079 * accurately (therefore making it impossible to know when a download 1080 * completes). 1081 */ 1082 public static final int STATUS_LENGTH_REQUIRED = 411; 1083 1084 /** 1085 * This download was interrupted and cannot be resumed. 1086 * This is the code for the HTTP error "Precondition Failed", and it is 1087 * also used in situations where the client doesn't have an ETag at all. 1088 */ 1089 public static final int STATUS_PRECONDITION_FAILED = 412; 1090 1091 /** 1092 * The lowest-valued error status that is not an actual HTTP status code. 1093 */ 1094 public static final int MIN_ARTIFICIAL_ERROR_STATUS = 488; 1095 1096 /** 1097 * The requested destination file already exists. 1098 */ 1099 public static final int STATUS_FILE_ALREADY_EXISTS_ERROR = 488; 1100 1101 /** 1102 * Some possibly transient error occurred, but we can't resume the download. 1103 */ 1104 public static final int STATUS_CANNOT_RESUME = 489; 1105 1106 /** 1107 * This download was canceled 1108 */ 1109 public static final int STATUS_CANCELED = 490; 1110 1111 /** 1112 * This download has completed with an error. 1113 * Warning: there will be other status values that indicate errors in 1114 * the future. Use isStatusError() to capture the entire category. 1115 */ 1116 public static final int STATUS_UNKNOWN_ERROR = 491; 1117 1118 /** 1119 * This download couldn't be completed because of a storage issue. 1120 * Typically, that's because the filesystem is missing or full. 1121 * Use the more specific {@link #STATUS_INSUFFICIENT_SPACE_ERROR} 1122 * and {@link #STATUS_DEVICE_NOT_FOUND_ERROR} when appropriate. 1123 */ 1124 public static final int STATUS_FILE_ERROR = 492; 1125 1126 /** 1127 * This download couldn't be completed because of an HTTP 1128 * redirect response that the download manager couldn't 1129 * handle. 1130 */ 1131 public static final int STATUS_UNHANDLED_REDIRECT = 493; 1132 1133 /** 1134 * This download couldn't be completed because of an 1135 * unspecified unhandled HTTP code. 1136 */ 1137 public static final int STATUS_UNHANDLED_HTTP_CODE = 494; 1138 1139 /** 1140 * This download couldn't be completed because of an 1141 * error receiving or processing data at the HTTP level. 1142 */ 1143 public static final int STATUS_HTTP_DATA_ERROR = 495; 1144 1145 /** 1146 * This download couldn't be completed because of an 1147 * HttpException while setting up the request. 1148 */ 1149 public static final int STATUS_HTTP_EXCEPTION = 496; 1150 1151 /** 1152 * This download couldn't be completed because there were 1153 * too many redirects. 1154 */ 1155 public static final int STATUS_TOO_MANY_REDIRECTS = 497; 1156 1157 /** 1158 * This download couldn't be completed due to insufficient storage 1159 * space. Typically, this is because the SD card is full. 1160 */ 1161 public static final int STATUS_INSUFFICIENT_SPACE_ERROR = 498; 1162 1163 /** 1164 * This download couldn't be completed because no external storage 1165 * device was found. Typically, this is because the SD card is not 1166 * mounted. 1167 */ 1168 public static final int STATUS_DEVICE_NOT_FOUND_ERROR = 499; 1169 1170 /** 1171 * This download is visible but only shows in the notifications 1172 * while it's in progress. 1173 */ 1174 public static final int VISIBILITY_VISIBLE = 0; 1175 1176 /** 1177 * This download is visible and shows in the notifications while 1178 * in progress and after completion. 1179 */ 1180 public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED = 1; 1181 1182 /** 1183 * This download doesn't show in the UI or in the notifications. 1184 */ 1185 public static final int VISIBILITY_HIDDEN = 2; 1186 1187 /** 1188 * Constants related to HTTP request headers associated with each download. 1189 */ 1190 public static class RequestHeaders { 1191 public static final String HEADERS_DB_TABLE = "request_headers"; 1192 public static final String COLUMN_DOWNLOAD_ID = "download_id"; 1193 public static final String COLUMN_HEADER = "header"; 1194 public static final String COLUMN_VALUE = "value"; 1195 1196 /** 1197 * Path segment to add to a download URI to retrieve request headers 1198 */ 1199 public static final String URI_SEGMENT = "headers"; 1200 1201 /** 1202 * Prefix for ContentValues keys that contain HTTP header lines, to be passed to 1203 * DownloadProvider.insert(). 1204 */ 1205 public static final String INSERT_KEY_PREFIX = "http_header_"; 1206 } 1207 } 1208 } 1209