summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers
Commit message (Collapse)AuthorAgeFilesLines
* Trigger mediascan after a download is completed.Sudheer Shanka2019-08-011-0/+6
| | | | | | | | | | | | | | | When a media item is inserted, media_type will be automatically updated but some of the other media attributes will only be updated after a media scan. Bug: 138419471 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: If8192b31fb7da37425480e7afa53dd1304533b76 (cherry picked from commit 90de12ad0c76fa9e231b3864c4afb8f312b53dda)
* Whitelist DownloadManager.ACTION_NOTIFICATION_CLICKED broadcastMichal Karpinski2019-06-182-0/+17
| | | | | | | | | | | | | for background activity starts When the DownloadManager download notification is clicked, that broadcast is sent to an app, and the app should be able to open activities from bg for its duration. Bug: 135515407 Test: com.android.providers.downloads.PublicApiFunctionalTest#testNotificationClickedBroadcast Test: manual Change-Id: Ic1691f5bda890ceb2938ac76f4ca2a4c7e7a1160
* Update behavior of setDestinationInExternalPublicDir().Sudheer Shanka2019-05-091-0/+15
| | | | | | | | | | | | | | 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: I62d4f810c71c9231e2b6d8e276a0a1e326382e14
* Fix DownloadProviderTests.Sudheer Shanka2019-05-012-3/+11
| | | | | | Bug: 131693243 Test: atest DownloadProviderTests Change-Id: Iefdd7690e45351c2dbdac1cff49f0d11aeba0fb0
* Update API impl of allowScanningByMediaScanner/setVisibleInDownloadsUi.Sudheer Shanka2019-04-301-0/+17
| | | | | | | | | | | | | These APIs javadocs have been updated earlier to indicate how they behave on Q, now updating impl of those APIs to match with javadocs. Bug: 131693243 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: I8fb43806b27fefaffc510fde5424b48e3ff56d20
* Make downloads deletion on owner uninstall consistent.Sudheer Shanka2019-04-281-2/+3
| | | | | | | | | | | | When an app is uninstalled, it's downloads in top-level download directory will be orphaned and the rest will be deleted. Bug: 126064843 Test: manual Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Change-Id: Iad430f7ec14f306ed859a3b30db9eea29a23c19d
* Canonicalize filepaths before saving to db.Sudheer Shanka2019-03-021-1/+1
| | | | | | | | | Bug: 126888145 Bug: 122475235 Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Change-Id: I96fa73d3a18e94986043c45dc4e12a47d62eeea6
* Add DownloadProvider entries to MediaStore Downloads collection.Sudheer Shanka2019-01-061-0/+37
| | | | | | | | | | | | | | Files downloaded using DownloadManager or those added to DownloadProvider using DownloadManager.addCompletedDownload() API are added to MediaStore Downloads collection so that apps can query all their downloads using MediaStore collection APIs. Bug: 120876251 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: Icaff9b013bb9486651ce0b5631cc48e80cdbb4b9
* Merge "Stop using Arrays.checkOffsetAndCount." am: 20dfa43eb7Pete Gillin2018-05-161-2/+3
|\ | | | | | | | | | | am: 991e53c2df Change-Id: Ic0366d2492e941cebd44c83e167c7876a0892bdc
| * Stop using Arrays.checkOffsetAndCount.Pete Gillin2018-05-101-2/+3
| | | | | | | | | | | | | | | | | | Start using ArrayUtils.throwsIfOutOfBounds instead. The Arrays method is going to be removed. Bug: 78447530 Test: tradefed.sh run commandAndExit template/local_min --template:map test=DownloadProviderTests Change-Id: I973f0b145d1dfd98b43ba429393b2324122ba374
* | Use the network security config's cleartext settingsChad Brubaker2018-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | Previously DownloadManager only respected the manifest attribute, this change makes DownloadManager handle both the manifest and the network security config Change-Id: I5666a1eea6278acc3864620a0e5a4c3ae37635b8 Fixes: 78028215 Test: atest CtsNetSecConfigDownloadManagerTestCases
* | Move to NOT_ROAMING capability.Jeff Sharkey2017-11-091-3/+13
| | | | | | | | | | | | | | | | | | Checking new capability is perferred way to verify a network isn't roaming; isRoaming() is now deprecated. Test: bit DownloadProviderTests:* Bug: 68397798 Change-Id: I11d19fd5a389b52e199c604a6906423d405072e2
* | Use explicit Network from JobParameters.Jeff Sharkey2017-10-251-1/+2
|/ | | | | | | | | | | | On devices with multiple active networks, or rapidly switching between networks, we need an API to tell jobs explicitly which network to use. (For example, the default route could meet all job criteria, but we could have changed the default network by the time we spun up the JobService.) Test: verified via DownloadManager Bug: 64133169 Change-Id: I9c131818d7199f79e147893d85c281473d00bee9
* Allocate space using new StorageManager API.Jeff Sharkey2017-07-152-272/+12
| | | | | | | | | | | | | | Instead of reaching directly into PackageManager, use the new StorageManager API to allocate disk space for downloads. This wraps both clearing cached files and fallocate() into a single method. Remove support for storing downloads on the /cache partition, which doesn't exist on many devices. Bug: 63057877 Test: bit DownloadProviderTests:* Exempt-From-Owner-Approval: Bug 63673347 Change-Id: I5749f7a2f7ded9157fea763dc652bf4da88d86ff
* Follow removal of NetworkInfo metered flag.Jeff Sharkey2017-07-141-2/+7
| | | | | | | | | | The OS now completely relies on NET_CAPABILITY_NOT_METERED to avoid confusion and staleness. Bug: 63391323 Test: builds, boots, Wi-Fi policy is upgraded Exempt-From-Owner-Approval: Bug 63673347 Change-Id: Iea83e0afd8cbd2be10d85b8a35c903047716b5b9
* Use calling app\\\'s Network Security Config for HTTPS downloads am: ↵Chad Brubaker2016-06-211-0/+18
|\ | | | | | | | | | | | | | | 473ee1358d am: 3799056e04 am: f2283c55d4 Change-Id: I4368376fe6f963c44e179df93ea6124a82d3954f
| * Use calling app's Network Security Config for HTTPS downloadsChad Brubaker2016-06-201-0/+18
| | | | | | | | | | Bug:29505888 Change-Id: Ifc33fd75e44d1dbc5a4ce5caa8e1ff938b94623e
* | Enable search for Downloads.Ben Lin2016-05-101-0/+18
|/ | | | | Bug: 26524617 Change-Id: Ide23c822b97ccab29a341184f14698dc942e8e14
* Visible downloads should run while blocked/dozing.Jeff Sharkey2016-04-291-2/+2
| | | | | | | | | | | Downloads with visible notifications should behave as if the requesting app was running a foreground service. The easiest way to implement this for now is to ignore any BLOCKED network status and use the new setWillBeForeground() API so job scheduling ignores any active blocked/dozing status. Bug: 26571724 Change-Id: I8ea2b2a7cdb5f469adc11b4d897ff55bd8a9db9a
* Move DownloadManager to use JobScheduler.Jeff Sharkey2016-04-256-82/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JobScheduler is in a much better position to coordinate tasks across the platform to optimize battery and RAM usage. This change removes a bunch of manual scheduling logic by representing each download as a separate job with relevant scheduling constraints. Requested network types, retry backoff timing, and newly added charging and idle constraints are plumbed through as job parameters. When a job times out, we halt the download and schedule it to resume later. The majority of downloads should have ETag values to enable resuming like this. Remove local wakelocks, since the platform now acquires and blames our jobs on the requesting app. When an active download is pushing updates to the database, check for both paused and cancelled state to quickly halt an ongoing download. Shift DownloadNotifier to update directly based on a Cursor, since we no longer have the overhead of fully-parsed DownloadInfo objects. Unify a handful of worker threads into a single shared thread. Remove legacy "large download" activity that was thrown in the face of the user; the UX best-practice is to go through notification, and update that dialog to let the user override and continue if under the hard limit. Bug: 28098882, 26571724 Change-Id: I33ebe59b3c2ea9c89ec526f70b1950c734abc4a7
* Tidy up uses of Integer.valueOf.Narayan Kamath2016-04-191-1/+1
| | | | | | | | Use parseInt when the result is assigned to an int. Allocates fewer objects. bug: 28078871 Change-Id: I2c58112795fecce6395c558f2bb1e1fefe83a5bf
* Merge "Implement multi-network downloads" into nyc-devRobin Lee2016-04-071-0/+7
|\
| * Implement multi-network downloadsRobin Lee2016-04-071-0/+7
| | | | | | | | | | | | | | | | | | Downloads should use the default network for the caller. This prevents applications from, for example, bypassing VPN by routing all requests through the DownloadProvider. Bug: 27074270 Change-Id: I7830226dd2910757d3a5c78f373330f84637ccfa
* | Add tag to downloadprovider storage tests to run in apctMd Haque2016-03-241-0/+2
|/ | | | Change-Id: I9b2711c2a9b3edd4bbef97ff6cdcae9fdc9ef433
* Follow framework refactoring.Jeff Sharkey2016-01-061-1/+13
| | | | | Bug: 22958127 Change-Id: I314a9bdd21988bf7e6cc79a2ae842bed29c96f17
* Add "Cancel" action to downloads in notification.Oren Blasberg2015-06-252-1/+32
| | | | | | | | | | | | Add a "Cancel" action to in-progress downloads shown in notification pane. We add a new action type for a new "cancel" intent sent by DownloadNotifier to DownloadReceiver, which in turn cancels the download by way of DownloadManager. BUG=19972464 Change-Id: I83cd2f40e1442c327f756027b99f9eac913a0e70
* Make DownloadProvider honor the cleartext traffic policy.Alex Klyubin2015-04-012-0/+23
| | | | | | | | | | | | | | | | | | | This makes the Provider-side of the DownloadManager framework honor the per-UID cleartext network traffic policy. The policy is enforced in the Provider rather than in its client (DownloadManager) because download URLs could get redirected between HTTPS and HTTP and only the Provider currently has visibility into and control over this. Whether cleartext network traffic is permitted is a per-package policy. However, the DownloadProvider can only access the UID of the requesting application. Multiple packages can run under the same UID. In that scenario, cleartext traffic is permited for the UID if cleartext traffic is permitted for any of the packages running under the UID. This could be improved by making the DownloadManager provide the package name in addition to the UID. Bug: 19215516 Change-Id: Ib37585a7a2fc2869954d52a1b08052926f49bc9b
* Fix compilation after update to MockWebServerNeil Fuller2014-10-271-1/+2
| | | | | | | Bug: 18083851 (cherry pick from commit f1cd37d8bade42be0632f54dcd61f81711269606) Change-Id: I93f14e171abc7a52fe2117c8503374734147513b
* Move internal DownloadProvider code off libcore.os.Elliott Hughes2014-04-281-7/+6
| | | | | | (As much as possible. There are no plans to make the mocking API public.) Change-Id: I348877b850d6d34572d5a19e67952254bc4f12ef
* fix test buildsColin Cross2014-04-241-2/+2
| | | | | | | StructStatVfs and ErrnoException were moved from libcore.io to android.system Change-Id: I42c789a941f964ae7dde224b16af39a95212fbc7
* Many improvements to download storage management.Jeff Sharkey2014-02-067-46/+350
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change all data transfer to occur through FileDescriptors instead of relying on local files. This paves the way for downloading directly to content:// Uris in the future. Rewrite storage management logic to preflight download when size is known. If enough space is found, immediately reserve the space with fallocate(), advising the kernel block allocator to try giving us a contiguous block regions to reduce fragmentation. When preflighting on internal storage or emulated external storage, ask PackageManager to clear private app caches to free up space. Since we fallocate() the entire file, use the database as the source of truth for resume locations, which requires that we fsync() before each database update. Store in-progress downloads in separate directories to keep the OS from deleting out from under us. Clean up filename generation logic to break ties in this new dual-directory case. Clearer enforcement of successful download preconditions around content lengths and ETags. Move all database field mutations to clearer DownloadInfoDelta object, and write back through single code path. Catch and log uncaught exceptions from DownloadThread. Tests to verify new storage behaviors. Fixed existing test to reflect correct RFC behavior. Bug: 5287571, 3213677, 12663412 Change-Id: I6bb905eca7c7d1a6bc88df3db28b65d70f660221
* Follow MockWebServer API changes.Jeff Sharkey2013-04-032-7/+1
| | | | Change-Id: Icaba016bc6e098745e56a3b6367a8a6af0151158
* Start using MockStreamResponse.Jeff Sharkey2013-03-252-1/+7
| | | | Change-Id: Ida4a0a85883ccd6763b07e958ddc6ecf7eedf790
* Fix race conditions around filename claiming.Jeff Sharkey2013-03-011-0/+46
| | | | | | | | | | | | | When multiple downloads are running in parallel, they can end up claiming the same filename and clobber over each other. This change introduces locking around filename generation, and touches the claimed filename so other threads fail the File.exists() check and keep looking. Tests to verify. Bug: 8255596 Change-Id: Ie75ed047c199cf679832c75159056ca036eac18d
* Test to verify extremely large downloads.Jeff Sharkey2013-02-253-3/+105
| | | | | | | | Streams a 3GB file to verify that it downloads correctly, using new MockWebServer streaming API. Bug: 8209169 Change-Id: Ic36271bfef3176e1ccea2b40edc7abb1044222f1
* Redesign of DownloadManager update loop.Jeff Sharkey2013-02-122-0/+57
| | | | | | | | | | | | | | | | | | Previously, the service lifecycle was managed through a large for() loop which was extremely tricky to reason about. This resulted in several race conditions that could leave the service running indefinitely, or terminate it early before tasks had finished. This change redesigns the update loop to be event driven based on database updates, and to collapse mutiple pending update passes. It is much easier to reason about service termination conditions, and it correctly uses startId to handle races during command delivery. Also moves scanner into isolated class, and switches to using public API instead of binding to private interface. Bug: 7638470, 7455406, 7162341 Change-Id: I380e77f5432223b2acb4e819e37f29f98ee4782b
* Migrate to using Mockito directly.Jeff Sharkey2013-01-312-8/+8
| | | | Change-Id: Ice24d5c62bbcbcfd3d7374eac3a20580f7f31f36
* Tests for max retries/redirects, ETag switches.Jeff Sharkey2013-01-295-14/+108
| | | | | | | | | | Verify that servers responding with many retries or redirects result in failed download, instead of spinning out of control. Test to verify that changed ETag results in download failing. Also fix handling of HTTP 301 to update Uri in database. Change-Id: Iff2948d79961a245b7900117d107edaa356618c9
* Better handling of retryable errors.Jeff Sharkey2013-01-171-1/+1
| | | | | | | | Now the final errors are always thrown, and the outer code decides how to handle them as retries. Also clean up method signatures. Bug: 8022478 Change-Id: I4e7e43be793294ab837370df521e7c381e0bb6c3
* Simplify download flow control, handle redirects.Jeff Sharkey2013-01-092-9/+12
| | | | | | | | | | Move redirection handling into a single loop, and handle each HTTP response code inline to make flow control easier to reason about. Fix race condition in tests by waiting for first status update. Bug: 7887226 Change-Id: Id4bfd182941baad4cd0bb702376c4beeb7275bb2
* Clean up DownloadManager threading tests.Jeff Sharkey2013-01-086-87/+76
| | | | | | | | | | | Change runUntilStatus() methods to polling with timeout instead of requiring internal knowledge about threading. Fix notification tests, and move opening of InputStream until after handling headers to avoid FNFE. Always reset facade to defaults before each test. Change-Id: I6b2d6cfc4e685d2090c1133b1b2e89ae12760f8b
* Always append to files, handle end of stream.Jeff Sharkey2012-12-171-4/+5
| | | | | | | | | | | | Fix bug where resumed downloads wouldn't open in append mode. Handle end of stream exceptions from URLConnection as special-case for now to keep tests passing. Move stream creation outside of DrmOutputStream, and always fsync() before closing files. Treat HTTP header errors as retryable. Add explicit state checks to redirection tests. Change-Id: I19d007284f6bfbffaac93859fe47cd98b79a59c4
* Show remaining time in download notifications.Jeff Sharkey2012-11-141-1/+1
| | | | | | | | | | Calculate speed of in-progress downloads and estimate time remaining until completion. Uses a moving average that is weighted 1:1 with the most recent 500ms sample. Funnels timing data to notifications through DownloadHandler. Bug: 6777872 Change-Id: I9155f2979aa330bd1172f63bbfca1d053815cee5
* Rewrite of download notifications.Jeff Sharkey2012-11-092-6/+12
| | | | | | | | | | | | | | | | | | Switch to using new inbox-style notifications when collapsing multiple downloads. Correctly handles clustering, including cancellation of stale notifications. All notifications are now handled in a single class, making it easier to reason about correctness. Fixed bugs around handling of visibility flags. Move away from using "int" as internal keys, since they can overflow. Started work for time estimates, will finish in a future CL. Explicitly pass all relevant IDs to DownloadReceiver instead of doing a second racy query. Fix StrictMode warnings when querying in DownloadReceiver. Bug: 6777872, 5463678, 6663547, 6967346, 6634261, 5608365 Change-Id: I5eb47b73b90b6250acec2ce5bf8d7a274ed9d3a9
* Move notification tests to LittleMock.Jeff Sharkey2012-07-243-56/+57
| | | | | | Directly mock NotificationManager instead of using SystemFacade. Change-Id: If932d26e23816e8674469c275a828701cce5fc2d
* Add and enforce ALLOW_METERED column.Jeff Sharkey2012-04-171-0/+6
| | | | | | | | | | | | Include flag with each download to indicate if its allowed to proceed over metered networks. Downloads are left in WAITING_FOR_NETWORK state, similar to how ALLOWED_NETWORK_TYPES is handled. Also keep blocked downloads in WAITING_FOR_NETWORK state instead of marking them as failed. Bug: 3001465, 5734560 Change-Id: I80bb9aa9bd25ddf6f7a2472db344b6ba6878bd74
* Migrate to shared MockWebServer.Jeff Sharkey2012-03-295-107/+111
| | | | | Bug: 4726601 Change-Id: Ibe537bd5c2a092dbf974360cd454751881f7f4ea
* Fix test to match behavior after 5196436.Jeff Sharkey2011-10-131-11/+2
| | | | Change-Id: Idfd4da891a6709504ea4f0cc72701400f63e0c2d
* Teach DownloadManager about network policy.Jeff Sharkey2011-06-172-4/+10
| | | | | | | | | | | Now network access is determined by using getActiveNetworkInfoForUid() which uses BLOCKED to indicate that network should be rejected for the requesting UID. While download in progress, watch for any policy changes that should trigger pause. Also check NetworkInfo.isConnected() for correctness. Change-Id: I1efa79823f15ecc3fa088a6719da1b770c64b255
* (master) bug:3204324 allow no more than certain number of concurrent downloadsVasu Nori2011-03-102-2/+16
| | | | Change-Id: Ibbce0782fcf7649209d6f56be240209cebd9045b