summaryrefslogtreecommitdiff
path: root/core/java/android/app/DownloadManager.java
Commit message (Collapse)AuthorAgeFilesLines
* Download: Add support to manually pause/resume downloadqqzhou2022-09-121-0/+40
| | | | | | | | | | | Add the pause and resume APIs here so that applications can pause and resume downloads manually through DownloadManager. This patch consists of 2 changes: 1. Add pause and resume download APIs 2. Add another paused reason for this download status Change-Id: I606b48ca20f43bcc6c119683818c2ab6ff03bfe5
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-3/+3
| | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-3/+3
| | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-3/+3
| | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* Override MIME type to match MediaStore behavior.Jeff Sharkey2020-06-231-0/+56
| | | | | | | | | | | | | Internally, DownloadManager synchronizes its contents with MediaStore, which relies heavily on using file extensions to determine MIME types. To prevent these two databases from getting confused, this change adjusts DownloadManager to force the MIME type of already-completed downloads based on the file extension, matching what MediaStore does. Bug: 159594536 Test: atest PublicApiAccessTest#testAddCompletedWithoutExtension Change-Id: I60c613eafcfe55007dffcac2d7d1fe375b753c19
* Final push to build against SDK.Jeff Sharkey2020-01-081-0/+35
| | | | | | | | | | | | | | | | | | | | | | The bulk of the work needed to get MediaProvider building against the "system_current" SDK surface has been slowly merged over the last few months, and this change makes the last few adjustments. This adds a new StorageVolumeCallback which is simpler version of StorageEventListener that simply delivers the changed StorageVolume. Move DownloadManager logic into a onMediaStoreDownloadsDeleted() method which hides the implementation details of how the OS connects with that implementation. Make local copies of some ExifInterface parsing logic; they could be added to the androidx version in an unbundled release. Make a local copy of RedactingFileDescriptor, since it's only needed for the next few weeks until FUSE is globally enabled. Bug: 137890034 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: Ib416eb8724781bdd234c8b7d728dee8b695ad6ac
* Use new UnsupportedAppUsage annotation.Artur Satayev2019-12-181-1/+1
| | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I8789f8499d4dca08580672e9e45ed9a7026dd686
* Shuffling to prepare for MediaProvider APEX.Jeff Sharkey2019-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | An upcoming change will move MediaStore to be within the recently created MediaProvider APEX. This means that MediaStore will need to be fully built against @SystemApi, and so this CL adjusts APIs to support a clean transition: -- Listing of "recent" storage volumes and scan paths for "internal" storage is now handled by StorageManager directly, so that partners retain control over what is deemed recent. -- StorageVolume now returns the MediaStore volume name and the filesystem directory where its contents are presented to apps. -- Conversion of legacy thumbnail "kind" values to dimensions now happens directly inside MediaStore. -- PendingParams and PendingSession are completely removed. -- Contributed media APIs are completely removed. -- Media for demo users is now surfaced as a unique StorageVolume. -- Migrate most MediaStore APIs to accept ContentResolver, which supports easy usage of ContentResolver.wrap(). Bug: 144247087, 137890034 Test: atest --test-mapping packages/providers/MediaProvider Exempt-From-Owner-Approval: in-place refactoring Change-Id: I445528b2779bb37b9f2558e67a3cfc9f60412092
* Enable stricter SQLiteQueryBuilder options.Jeff Sharkey2019-07-191-20/+22
| | | | | | | | | | | | | | | | | | | | | | | Malicious callers can leak side-channel information by using subqueries in any untrusted inputs where SQLite allows "expr" values. This change starts using setStrictColumns() and setStrictGrammar() on SQLiteQueryBuilder to block this class of attacks. This means we now need to define the projection mapping of valid columns, which consists of both the columns defined in the public API and columns read internally by DownloadInfo.Reader. We're okay growing sAppReadableColumnsSet like this, since we're relying on our trusted WHERE clause to filter away any rows that don't belong to the calling UID. Remove the legacy Lexer code, since we're now internally relying on the robust and well-tested SQLiteTokenizer logic. Bug: 135270103, 135269143 Test: atest DownloadProviderTests Test: atest CtsAppTestCases:android.app.cts.DownloadManagerTest Change-Id: I7c911f6b8d58fba6229b83f4e22d6b670dd179a7
* Trigger a mediascan when downloads get renamed.Sudheer Shanka2019-05-231-0/+6
| | | | | | | | | | | Fixes: 132811564 Test: manual Test: atest --test-mapping packages/providers/MediaProvider Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java Change-Id: I319a5b45e703b1eda5846d085c5e1e1e86bbae2b
* Update behavior of setDestinationInExternalPublicDir().Sudheer Shanka2019-05-081-9/+7
| | | | | | | | | | | | | | Allow apps to use DownloadManager for downloading files into known public dirs other than "Download" but don't include them as part of Downloads collection. Bug: 132136431 Test: manual Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java Change-Id: I059c0b19218e07c7813e23c6b2d414d0306434d5
* Merge "Deprecate ↵Sudheer Shanka2019-04-281-0/+16
|\ | | | | | | DownloadManager.allowScanningByMediaScanner/setVisibleInDownloadsUi" into qt-dev
| * Deprecate DownloadManager.allowScanningByMediaScanner/setVisibleInDownloadsUiSudheer Shanka2019-04-281-0/+16
| | | | | | | | | | | | Bug: 131483165 Test: n/a Change-Id: I8e7f9c29d9bb323a7c0849e9ae4a87d0e74b16ab
* | Merge "Deprecate DownloadManager.addCompletedDownload." into qt-devJeff Sharkey2019-04-281-0/+20
|\ \
| * | Deprecate DownloadManager.addCompletedDownload.Sudheer Shanka2019-04-271-0/+20
| |/ | | | | | | | | | | Bug: 131483165 Test: n/a Change-Id: Ie7df900e4cd79dcb4578f1f86fc44ca69356fd7b
* / Don't assume all downloaded files are under top-level Download dir.Sudheer Shanka2019-04-271-32/+28
|/ | | | | | | | | | | Apps could have downloaded files into their own package-owned paths and those targeting P or lower, anywhere. Fixes: 128320098 Test: manual Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Change-Id: I28d9f9b8017b66095fb1abeb9a389a18770989a4
* Fix QT build breakage.Sudheer Shanka2019-04-241-1/+1
| | | | | Test: builds Change-Id: Iff6f516d68659a9b81009f82b6e1874089daa592
* Update behavior of some DownloadManager APIs.Sudheer Shanka2019-04-231-9/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -- Update behavior of DownloadManager.setDestinationUri(), DownloadManager.setDestinationInExternalPublicDir() and DownloadManager.addCompletedDownload() based on the latest storage re-design. Essentially, going forward these APIs will only allow downloading files into package owned dirs or the top-level Download dir. -- Allow some system components to specify MediaColumns.OWNER_PACKAGE_NAME when inserting items into MediaProvider. -- Don't copy DownloadManager.COLUMN_TITLE to MediaProvider. DownloadProvider and MediaProvider have different constraints around "title" and there isn't really a need to keep these in sync. -- Sanity check file download paths hinted by apps. -- Remove sandbox related logic in DownloadProvider. Bug: 120879208 Bug: 128630262 Bug: 130797842 Test: manual Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: If48bc9ecf9ed94412c6c62ce4e5e6a55fff9b789
* Merge "Add @UnsupportedAppUsage annotations"Andrei-Valentin Onea2019-03-061-0/+1
|\
| * Add @UnsupportedAppUsage annotationsAndrei Onea2019-03-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For packages: android.accounts android.app This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I65c961e3f59b9868156b3ee6a3b1cab81b0e9d25
* | Mark COLUMN_MEDIASTORE_URI as @TestApi.Sudheer Shanka2019-02-281-0/+5
|/ | | | | | Bug: 126395605 Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Change-Id: I727555d7b2a5812b2a802ea447c2d9b9d26c9572
* Don't ignore COLUMN_MEDIA_SCANNED values from caller.Sudheer Shanka2019-01-291-21/+4
| | | | | | | | | | | | | | | | | | | | Right now, DownloadProvider only uses the COLUMN_MEDIA_SCANNED value if it is coming from addCompletedDownload and for the rest of the requests, it ignores the incoming COLUMN_MEDIA_SCANNED value and always invokes mediascanner. This is not what the documentation says. For e.g., if the caller uses DownloadManager.setDestinationUri() API, then unless otherwise specified, the download doesn't need to be mediascanned. Also, since we are inserting user visible downloads to MediaProvider, use that info to populate the COLUMN_MEDIAPROVIDER_URI column as well and update DownloadProvider to not invoke MediaScanner. Bug: 123440050 Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: I65ccae672eabe2efd5132d4b105c18bb591379fc
* Update DownloadStorageProvider to include MediaStore.Downloads.Sudheer Shanka2019-01-281-1/+6
| | | | | | | | | | Bug: 120879205 Test: manual Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest MediaProviderTests Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: I44be836899437d87fc1a00e5fe316c6b68488643
* Update DownloadManager.addCompletedDownload javadoc.Sudheer Shanka2019-01-181-2/+4
| | | | | | | | | | | Starting from Q, downloads added using DownloadManager.addCompletedDownload are by default going to be added to MediaProvider regardless of isMediaScannerScannable argument specified by clients. Update the javadoc to reflect this. Bug: 120876251 Test: n/a Change-Id: Ie091703d801bb9cecc9574a122e13a242f4cca95
* Move some members to the "Q blacklist".Mathew Inwood2018-09-141-2/+2
| | | | | | | | | | | | | | Based on some analysis, these fields/methods are likely false positives. Set maxTargetSdk=P so that any apps using them are required to migrate off them in future. See the bug for more details. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | For packages: android.app.usage android.app.trust android.app.timezonedetector android.app.timezone android.app.timedetector android.app.job android.app.backup android.app.assist android.app.admin android.app This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I618c5dc4462ae990d9df45c3e9ed3f092cc5138c
* Test if allocation supported; @removed clean up.Jeff Sharkey2017-07-151-26/+7
| | | | | | | | | | | | | | | | | | | | | | SM.allocateBytes() doesn't offer a clear way to detect if a failed request could ever succeed. (For example, we can never work with pipes, or files on an unsupported storage device.) So give developers a first-class API to test if allocation is supported. If the underlying filesystem doesn't support fallocate(), fall back to ftruncate() instead of failing completely. Clean up @removed APIs that were refactoring during API 26 review process. Remove support for storing downloads on the /cache partition, which doesn't exist on many devices. Bug: 63057877 Test: bit DownloadProviderTests:* Test: bit DocumentsUITests:com.android.documentsui.services.CopyJobTest Test: bit DocumentsUITests:com.android.documentsui.services.MoveJobTest Change-Id: I85d42a1a7240034b4f2a6f359011ac182bdce36e
* Annotate @SystemApi with required permissions.Jeff Sharkey2017-06-051-6/+4
| | | | | | | | | | | | | | | | | Most @SystemApi methods should be protected with system (or higher) permissions, so annotate common methods with @RequiresPermission to make automatic verification easier. Verification is really only relevant when calling into system services (where permissions checking can happen on the other side of a Binder call), so annotate managers with the new @SystemService annotation, which is now automatically documented. This is purely a docs change; no logic changes are being made. Test: make -j32 update-api && make -j32 offline-sdk-docs Bug: 62263906 Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
* Add legacy DownloadManager actions to SystemApi.Jeff Sharkey2017-04-041-0/+6
| | | | | | | | They're still used by at least one bundled app. Test: builds, boots Bug: 35256608 Change-Id: I45966b3e0ed506ead4544bbbfc9d82b7f9d5205d
* Merge commit '0a9d537f623b2c11dce707fb9b91fea016fd0e9f' into ↵Jeff Sharkey2016-09-171-3/+3
|\ | | | | | | | | | | | | | | manual_merge_0a9d537 am: df42d732f8 am: afcd1135c3 am: fc1c0f9dff am: 33ada2e927 am: db901ee296 am: bd5d0049d7 am: f7caea844f Change-Id: Ifa9167a9a69240712a59b90839a32605cfdd7037
| * Merge commit '0a9d537f623b2c11dce707fb9b91fea016fd0e9f' into ↵Jeff Sharkey2016-09-171-3/+3
| |\ | | | | | | | | | | | | | | | | | | | | | manual_merge_0a9d537 am: df42d732f8 am: afcd1135c3 am: fc1c0f9dff am: 33ada2e927 Change-Id: I9b6d2b6f9101e7e7610f191cd4927d568ae0476a
| | * Merge commit '0a9d537f623b2c11dce707fb9b91fea016fd0e9f' into ↵Jeff Sharkey2016-09-161-3/+3
| | |\ | | | | | | | | | | | | | | | | | | | | manual_merge_0a9d537 Change-Id: Ib1a0bbb34edb61666ac5739f0b0eaadbe4c5fe06
| | | * Use "all_downloads" instead of "my_downloads".Jeff Sharkey2016-09-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can no longer return the "my_downloads" paths: if those Uris were shared beyond the app that requested the download, access would be denied. Instead, we need to switch to using "all_downloads" Uris so that permission grants can be issued to third-party viewer apps. Since an app requesting a download doesn't normally have permission to "all_downloads" paths, DownloadProvider now issues narrow grants toward the owner of each download, both at device boot and when new downloads are started. Bug: 30537115, 30945409 Change-Id: I533125b36444877f54373d88922f2acc777e250b
* | | | Add support for search in DownloadManager.Ben Lin2016-05-101-5/+38
|/ / / | | | | | | | | | | | | Bug: 26524617 Change-Id: I41c0f92381bec8ad06db73b25ec67466f368b55c
* | | Add ability to rename a downloaded file.Ben Lin2016-05-021-0/+82
| | | | | | | | | | | | | | | Bug: 28359663 Change-Id: I2674720777c7aafd81e8395e873967fd5d7a2f26
* | | API changes for DownloadManager and JobScheduler.Jeff Sharkey2016-04-241-10/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support moving DownloadManager, add new JobScheduler network type constraint that matches "any network except roaming." Also add an API to get a specific JobInfo by ID. Since the default network can be different on a per-app basis, and individual apps may be blocked due to app standby, evaluate job connectivity constraints on a per-UID basis. To implement this cleanly, add NetworkInfo.isMetered() to match the isRoaming() API. Add new DownloadManager APIs to support charging and device idle constraints, which are plumbed through to JobScheduler under the hood when scheduled. Add filtering to JobScheduler dumpsys to omit noisy details for packages the caller isn't interested in. Bug: 28098882, 26571724, 19821935 Change-Id: I09ca7184ef7ce6adba399f579d415a5fb2ea6110
* | | Keep COLUMN_LOCAL_URI working for now.Jeff Sharkey2016-03-301-1/+1
| | | | | | | | | | | | | | | Bug: 26515039 Change-Id: I48f3ef90443b01fb75a3852e5cfdd83a9bbcac0f
* | | Merge "DO NOT MERGE Revert "Revert "DO NOT MERGE Extend the ↵Edward Cunningham2016-03-251-3/+50
|\ \ \ | | | | | | | | | | | | DownloadManager.addCompletedDownload() method to support origin details.""" into nyc-dev
| * | | DO NOT MERGE Revert "Revert "DO NOT MERGE Extend the ↵Edward Cunningham2016-03-251-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DownloadManager.addCompletedDownload() method to support origin details."" This reverts commit c6f5738d3c8621d2e682026e35e57f540750d117. Change-Id: Ibb330f44c3910b3fc124ee8c718a508cdf3b32b4
* | | | Throw the right exception flavor.Jeff Sharkey2016-03-221-1/+1
|/ / / | | | | | | | | | Change-Id: Ie017fce925ed0122d3820c3f3d91e1b86982a7b1
* | | Revert "DO NOT MERGE Extend the DownloadManager.addCompletedDownload() ↵Edward Cunningham2016-02-241-50/+3
| | | | | | | | | | | | | | | | | | | | | | | | method to support origin details." This reverts commit baccf15a4adafe3fb3fdf23c35ea29d95c45c89b. Change-Id: If218d579cbf473fdab2b16a715a5dbb75dc9fbbc
* | | DO NOT MERGE Extend the DownloadManager.addCompletedDownload() method to ↵Edward Cunningham2016-02-161-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | support origin details. Bug: 20294239 Change-Id: Ic770a223c23013ebab08d22dd14e7192dc8e3109 (cherry picked from commit 735a31e093d9262139c1da6bf426bc8166d4b18e)
* | | Internal components still need filename access.Jeff Sharkey2016-01-071-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | Give them a way to force-enable filename access, bypassing the recently added deprecated check. Bug: 26438975 Change-Id: Ifd1e3debf7c7b3113907a5f2815c29ddb7db581f
* | | Discourage use of "_data" column.Jeff Sharkey2016-01-061-11/+37
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moving forward, all client file access really needs to be going through explicit APIs like openFileDescriptor(), since that allows the provider to better protect its underlying files. This change also changes several classes to use the AutoClosable pattern, which enables try-with-resources usage. Older release() methods are deprecated in favor of close(). Uniformly apply CloseGuard across several classes, using AtomicBoolean to avoid double-freeing, and fix several resource leaks and bugs related to MediaScanner allocation. Switch MediaScanner and friends to use public API instead of raw AIDL calls. Bug: 22958127 Change-Id: Id722379f72c9e4b80d8b72550d7ce90e5e2bc786
* | Always return content Uri for downloads.Jeff Sharkey2015-07-291-24/+3
| | | | | | | | | | | | | | | | Now that we're relying more heavily on Uri permission grants between apps, we should always return content:// Uris. Bug: 22820206 Change-Id: Ie9603da09944dc594ea5dde2db04455f57d6f103
* | Document that DownloadManager supports HTTPS.Alex Klyubin2015-06-111-1/+1
|/ | | | | Bug: 14112655 Change-Id: I37708553b7ae2f48dcd574f3c66daa8dfdd00f3a
* Docfixes for DownloadManager.John Spurlock2013-11-041-10/+6
| | | | Change-Id: If01420ed3964fda89c459d3f9021b5088520b6b1
* Docs change: annotate media intent actions.Jeff Sharkey2013-10-021-0/+5
| | | | | Bug: 11043141 Change-Id: I66777c5ce25014d8e64da5b4ce3f70334befb0b7
* Allow saving to Downloads.Jeff Sharkey2013-09-231-1/+19
| | | | | | | | Uses new column to mark writability. Also filter file selection in create mode to only allow writable files. Bug: 10667164, 10893268 Change-Id: I90f74efbb7ac634fbdb3cc02a904a96a434d3605
* Handle external storage errors uniformly.Jeff Sharkey2013-03-251-18/+42
| | | | | Bug: 6777728 Change-Id: I021db160bc959fdf02bfd448edf977961bd1d9d0