summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* DO NOT MERGE: Update DownloadProvider for correct meterednessBenedict Wong2018-07-201-0/+5
| | | | | | | | | | | | This patch updates DownloadProvider to use the fixed meteredness hidden APIs for OC-MR1. This corrects a bug where DownloadProvider would fail to allow downloads to proceed when VPNs are connected, but the underlying networks are metered. Bug: 78644887 Test: Flashed on Walleye and tested. Change-Id: I13c1bd6d7ab26489923329bc7985060228e9bb29 (cherry picked from commit b627002ea9dc2511bad6ea5e68f4248f36c4a3eb)
* Allocate space using new StorageManager API.Jeff Sharkey2017-07-153-273/+13
| | | | | | | | | | | | | | 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
* Add test config to DownloadProviderTestsDan Shi2017-03-221-0/+27
| | | | | | | | | Details about test configs changes are tracked in doc https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit# Bug: 35882476 Test: local test Change-Id: I468b280c2285f8ff0b7f79161cb4e21d4ebd19c2
* packages/providers/DownloadProvider: Add APCT tests to the device-tests suite.Simran Basi2017-03-151-0/+1
| | | | | | | | | | | | | | This CL adds the APCT tests within this project to a similar suite as CTS known as device-tests. The current method of running APCT tests in the infrastructure is unaffected. Bug: 35882476 Test: `make dist device-tests -j` and local builds of continuous_instrumentation_tests & continuous_native_tests Change-Id: Ia52f36245fb9ec0bedcc71933fb2af46310fb1a9
* Merge "Remove unnecessary direct dependency on dexmaker" am: b33ebabb85 am: ↵Paul Duffin2017-03-091-1/+0
|\ | | | | | | | | | | | | | | 5f8a055a1c am: 9264e2d7c2 Change-Id: Ic76eb48cbe5ab523eabb26cedc4f2cc4925d1073
| * Remove unnecessary direct dependency on dexmakerPaul Duffin2017-03-071-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The mockito-target library already statically includes dexmaker so the direct dependency is unnecessary and could make the upgrade of mockito more difficult. This is part of the cleanup work prior to upgrading mockito. I ran the tests before and after the change and in both cases got 2 failures and between 4-6 errors; at least some of the errors are flaky as the exact number changed from one run to the next. Bug: 32912773 Test: clean make of DownloadProviderTests, verify still includes dexmaker classes Change-Id: I8133d0869a2b0ff7a9ffc19daff61ed1bbc6a7f6
* | Merge "Prepare for removal of legacy-test from default targets" am: ↵Paul Duffin2017-01-183-1/+7
|\| | | | | | | | | | | | | | | ec6226a6e6 am: 1655131ad9 am: 8be70727ed am: 199c9d1ba8 Change-Id: I4cdfa049d3a5fb4b050aa02efdf7b1d8f619c3c5
| * Prepare for removal of legacy-test from default targetsPaul Duffin2017-01-173-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | In preparation for removing junit classes from the Android API the legacy-test target will be removed from the TARGET_DEFAULT_JAVA_LIBRARIES. This change adds explicit dependencies on junit and/or legacy-android-test to ensure that modules will compile properly once it is removed. Bug: 30188076 Test: make checkbuild Change-Id: I8b29b7d78c97c648d3c98067ac7b050b0a106369
* | 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-062-2/+14
| | | | | 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-068-46/+352
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-123-1/+58
| | | | | | | | | | | | | | | | | | 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-313-9/+9
| | | | 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-244-57/+58
| | | | | | 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-299-703/+112
| | | | | 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
* Revert "Merge "downloadmanager should use "files" dir - not "cache" dir to ↵Vasu Nori2011-01-071-1/+1
| | | | | | | store its files" into honeycomb" This reverts commit 7d96bafa59111d9ca735e5ef86dc0598f946b2be, reversing changes made to 2ce876d2d7000b0c3a1430c5f4932568090f5170.
* downloadmanager should use "files" dir - not "cache" dir to store its filesVasu Nori2011-01-071-1/+1
| | | | | | | | | | | | | data/data/com.android.providers.downlaods/cache is being used to store the downloaded files, when the user doesn't specify the destination path. but system seems to remove files from this dir EVEN when space is running low. bug:3324673 instead, let DownloadManager use data/data/com.android.providers.downlaods/files dir Downlaodmanager manages its space anyway. Change-Id: I2eb15570395a214477891f50f635fada0b466544
* Adding HelpersTest.java for testing the download provider's helpers class. ↵olly2011-01-042-1/+54
| | | | | | Note - only a small fraction of input cases are currently tested. Change-Id: I830fff43cc283367a3534b7a3ffcc2a6d296e7c3
* bug:3286430 set quota on downloads data dirVasu Nori2010-12-232-6/+1
| | | | | | | | | | make sure the doanloads data dir size is limited by some quote - 100MB default and 200MB for SR. bug:3286430 tests are in Change-Id: I688f7e058511089bec7fa21e972e23780604d98a Change-Id: Iba7fab9fa91ea018f35e1c3ef5ec0e6b03cba650
* fix downloadmanager tests. again.Vasu Nori2010-12-153-19/+7
| | | | Change-Id: I61c6020017a300076ab2a5901ab87eabb1e0d0b7
* Download dir: /data/data/com.android.providers.downloads/cache NOT /cacheVasu Nori2010-12-142-0/+18
| | | | | | | | | | bug:3264401 still to do: make sure only N bytes are taken up by downloads dir N = a value specific to each device. default = 100MB. Change-Id: I2a49f4b3831d3a8d7be13b5fd46d85d56e831e38