5dcbf701c9077e62ca8c1ee0079b4cbffaf57d14 |
29-Apr-2014 |
Elliott Hughes <enh@google.com> |
Move internal DownloadProvider code off libcore.os. (As much as possible. There are no plans to make the mocking API public.) Change-Id: I348877b850d6d34572d5a19e67952254bc4f12ef
ownloads/StorageTest.java
|
8b36635d727451930ef4939aad25148c05c66b09 |
25-Apr-2014 |
Colin Cross <ccross@android.com> |
fix test builds StructStatVfs and ErrnoException were moved from libcore.io to android.system Change-Id: I42c789a941f964ae7dde224b16af39a95212fbc7
ownloads/StorageTest.java
|
dffbb9c4567e9d29d19964a83129e38dceab7055 |
31-Jan-2014 |
Jeff Sharkey <jsharkey@android.com> |
Many improvements to download storage management. 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
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/AbstractPublicApiTest.java
ownloads/FakeSystemFacade.java
ownloads/HelpersTest.java
ownloads/PublicApiFunctionalTest.java
ownloads/StorageTest.java
ownloads/ThreadingTest.java
|
323f5ae0cafdc72f61defefaa5ba938f1b4d0dda |
03-Apr-2013 |
Jeff Sharkey <jsharkey@android.com> |
Follow MockWebServer API changes. Change-Id: Icaba016bc6e098745e56a3b6367a8a6af0151158
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
1b5c0091270cdc04054c9a2af33ba4f94d652cff |
21-Mar-2013 |
Jeff Sharkey <jsharkey@android.com> |
Start using MockStreamResponse. Change-Id: Ida4a0a85883ccd6763b07e958ddc6ecf7eedf790
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
5ba69740a47857fcebd36866e07963ba798269d5 |
01-Mar-2013 |
Jeff Sharkey <jsharkey@android.com> |
Fix race conditions around filename claiming. 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
ownloads/ThreadingTest.java
|
7ce206b2108714035eeed29c1dc268a3f1ccf359 |
22-Feb-2013 |
Jeff Sharkey <jsharkey@android.com> |
Test to verify extremely large downloads. Streams a 3GB file to verify that it downloads correctly, using new MockWebServer streaming API. Bug: 8209169 Change-Id: Ic36271bfef3176e1ccea2b40edc7abb1044222f1
ownloads/AbstractPublicApiTest.java
ownloads/FakeInputStream.java
ownloads/PublicApiFunctionalTest.java
|
925976230936a5177365dc24b50da8607a9af8d4 |
12-Feb-2013 |
Jeff Sharkey <jsharkey@android.com> |
Redesign of DownloadManager update loop. 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
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/MockitoHelper.java
|
70c0e1eff5ff7cd5051738f76cecd6cb87353a43 |
01-Feb-2013 |
Jeff Sharkey <jsharkey@android.com> |
Migrate to using Mockito directly. Change-Id: Ice24d5c62bbcbcfd3d7374eac3a20580f7f31f36
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
58eee87b70862a7ced85eabc3c225fad24664065 |
29-Jan-2013 |
Jeff Sharkey <jsharkey@android.com> |
Tests for max retries/redirects, ETag switches. 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
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/AbstractPublicApiTest.java
ownloads/DownloadProviderFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
ownloads/ThreadingTest.java
|
12f5dc46aaa8e28cabfbe25d55f0af68f24ab306 |
18-Jan-2013 |
Jeff Sharkey <jsharkey@android.com> |
Better handling of retryable errors. 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
ownloads/PublicApiFunctionalTest.java
|
0de55602ec6d350548248feddc68c91b29326eff |
24-Dec-2012 |
Jeff Sharkey <jsharkey@android.com> |
Simplify download flow control, handle redirects. 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
ownloads/AbstractPublicApiTest.java
ownloads/PublicApiFunctionalTest.java
|
8ac10e0e0667a4fe35191deebb5fa9786bf4226c |
04-Jan-2013 |
Jeff Sharkey <jsharkey@android.com> |
Clean up DownloadManager threading tests. 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
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/AbstractPublicApiTest.java
ownloads/DownloadProviderFunctionalTest.java
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
ownloads/ThreadingTest.java
|
a85832b4772626852142b60c4806ff5384a76478 |
18-Dec-2012 |
Jeff Sharkey <jsharkey@android.com> |
Always append to files, handle end of stream. 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
ownloads/PublicApiFunctionalTest.java
|
52b703c5d0c4cff72bafdec0e2229368d3cc20d0 |
13-Nov-2012 |
Jeff Sharkey <jsharkey@android.com> |
Show remaining time in download notifications. 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
ownloads/DownloadProviderFunctionalTest.java
|
a40a349c0107660bfb4004467550725a3ca3ec97 |
03-Aug-2012 |
Jeff Sharkey <jsharkey@android.com> |
Rewrite of download notifications. 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
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
36612d27b67ff2e79ffff8eb12d95d2058abde02 |
25-Jul-2012 |
Jeff Sharkey <jsharkey@android.com> |
Move notification tests to LittleMock. Directly mock NotificationManager instead of using SystemFacade. Change-Id: If932d26e23816e8674469c275a828701cce5fc2d
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
a7ae77fdae69bcc6d6609d4639fed5d96e55eeaa |
17-Apr-2012 |
Jeff Sharkey <jsharkey@android.com> |
Add and enforce ALLOW_METERED column. 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
ownloads/FakeSystemFacade.java
|
ae6856b0fca5215f45619dd031a7e7beae7bd8cc |
29-Mar-2012 |
Jeff Sharkey <jsharkey@android.com> |
Migrate to shared MockWebServer. Bug: 4726601 Change-Id: Ibe537bd5c2a092dbf974360cd454751881f7f4ea
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/AbstractDownloadProviderFunctionalTest.java
ownloads/AbstractPublicApiTest.java
ownloads/DownloadManagerFunctionalTest.java
ownloads/DownloadProviderFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
ownloads/ThreadingTest.java
|
255582a7542bc16622369986e1ba0484270b2e8d |
14-Oct-2011 |
Jeff Sharkey <jsharkey@android.com> |
Fix test to match behavior after 5196436. Change-Id: Idfd4da891a6709504ea4f0cc72701400f63e0c2d
ownloads/HelpersTest.java
|
961024389b3782936a40a7d090d670290bb66c3c |
15-Jun-2011 |
Jeff Sharkey <jsharkey@android.com> |
Teach DownloadManager about network policy. 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
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
6baceb7073ed7858d3424ccf774e5f6a946bec59 |
10-Mar-2011 |
Vasu Nori <vnori@google.com> |
(master) bug:3204324 allow no more than certain number of concurrent downloads Change-Id: Ibbce0782fcf7649209d6f56be240209cebd9045b
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/DownloadManagerFunctionalTest.java
|
c0f732bad06924bc4ef1652ace35d9b0ffc93e2e |
08-Jan-2011 |
Vasu Nori <vnori@google.com> |
Revert "Merge "downloadmanager should use "files" dir - not "cache" dir to store its files" into honeycomb" This reverts commit 7d96bafa59111d9ca735e5ef86dc0598f946b2be, reversing changes made to 2ce876d2d7000b0c3a1430c5f4932568090f5170.
ownloads/DownloadManagerFunctionalTest.java
|
f5699308bc41c39ccbb388feb00a248304f30c54 |
07-Jan-2011 |
Vasu Nori <vnori@google.com> |
downloadmanager should use "files" dir - not "cache" dir to store its files 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
ownloads/DownloadManagerFunctionalTest.java
|
6eeee34a2cf4fb477cb789c7a232d09fc6565023 |
23-Dec-2010 |
olly <olly@google.com> |
Adding HelpersTest.java for testing the download provider's helpers class. Note - only a small fraction of input cases are currently tested. Change-Id: I830fff43cc283367a3534b7a3ffcc2a6d296e7c3
ownloads/HelpersTest.java
|
5218d33d57990c3e3549c58bd3f0ac244dfc3d59 |
17-Dec-2010 |
Vasu Nori <vnori@google.com> |
bug:3286430 set quota on downloads data dir 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
ownloads/DownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
a1cbbb41a7423c6f87b2f461075aad4c665f19dd |
15-Dec-2010 |
Vasu Nori <vnori@google.com> |
fix downloadmanager tests. again. Change-Id: I61c6020017a300076ab2a5901ab87eabb1e0d0b7
ownloads/DownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
9aadb4b3f2b3c914166ebfae8851fbecaf536f4f |
14-Dec-2010 |
Vasu Nori <vnori@google.com> |
Download dir: /data/data/com.android.providers.downloads/cache NOT /cache 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
ownloads/DownloadManagerFunctionalTest.java
|
5d217003acf21aea852975af0dff3b398cea6768 |
07-Dec-2010 |
Vasu Nori <vnori@google.com> |
fix broken DownloadManager tests one big change in this CL is addition of a new feature to MockWebServer. It can now play a long response to the Downloading thread to keep it busy while something - such as cancel/remove - can be done to that Download Request. Also, added changes to FakeSystemFacade to start threads in normal fashion instead of queuing them up and later running just their run() methods. the following tests should work now packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ DownloadManagerFunctionalTest.java PublicApiFunctionalTest.java ThreadingTest.java PublicApiAccessTest.java DownloadProviderPermissionsTest.java the following are flaky. they need to be split up into smaller tests. frameworks/base/core/tests/coretests/src/android/app/ DownloadManagerIntegrationTest.java DownloadManagerStressTest.java Change-Id: Ia0b11963f92e8f8365f701761dcbce467be3ee9b
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/AbstractPublicApiTest.java
ownloads/DownloadManagerFunctionalTest.java
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
04f09085f85d094207d22ae8969102bd48178180 |
20-Oct-2010 |
Vasu Nori <vnori@google.com> |
remove usage of hidden public constants. Change-Id: I2edf1bef5e741de8193cb293807e3ace42003b0c
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/DownloadManagerFunctionalTest.java
|
b108a273b150e81bf26553b8851d6241bc711f98 |
30-Sep-2010 |
Steve Howard <showard@google.com> |
Improve how the download manager reports paused statuses. This change makes the download manager report more detail when a download is paused. Rather than always reporting status RUNNING_PAUSED, there are now four different statuses: * paused by the app * waiting to retry after a network error * waiting for network connectivity * queued for wifi due to size limits This allows a few improvements: * code deciding when to run a download can be improved and cleaned up (I've taken some extra steps in cleaning up this particular code) * notification code no longer has to rely on the in-memory-only "mPausedReason" member of DownloadInfo; instead, it knows from the status that the download is queued for wifi, and can display the appropriate string. This moves the string fetching out into the UI-specific logic and is a sign that this is really the right way to do things. And finally, the real motivation for this change: I've changed the meaning of "Queued" in the downloads UI so it now means "Queued for WiFi'. This is what was originally intended, I'd misunderstood. What was formerly known as "Queued", a download that hadn't started, is now displayed as "In progress" (it's always a transient state so it's basically meaningless anyway). Otherwise it remains the same (in particular, downloads paused for other reasons are still reported as "In progress"). I've also increased some of the logging in DownloadThread a bit, as this change initally introduced some bugs that were impossible to track down without that logging. There have been other bug reports that were impossible to diagnose and these few extra log statements should really help, without cluttering logs too much. I've taken care to avoid potentially introducing any PII into the logs. Change-Id: Id0b8d65fc8e4406ad7ffa1439ffc22a0281b051f
ownloads/DownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
14961f94d762e733a733e3268fca1074d8da5f8c |
28-Sep-2010 |
Steve Howard <showard@google.com> |
Moved DownloadManager to android.app (DO NOT MERGE) I'll merge this manually, as there's some additional master-only code that will be to be simultaneously changed. Change-Id: Ifdb1740f32e228bc07f266585737b98a7b794685
ownloads/AbstractPublicApiTest.java
ownloads/PublicApiFunctionalTest.java
ownloads/ThreadingTest.java
|
ebb555c0687061993dd6a22d15f6aab2437ee8c5 |
23-Sep-2010 |
Steve Howard <showard@google.com> |
Support multi-valued HTTP headers, handle new API changes * backend support for multiple values for the same HTTP headers, for corresponding API changes * other minor changes in response to DownloadManager API changes Change-Id: I7c595e94a60ed7afaca6cc3fb4c05aaeeff20c2a
ownloads/PublicApiFunctionalTest.java
|
d319729622da1893e895f2e35f41d01ecdca3705 |
18-Sep-2010 |
Steve Howard <showard@google.com> |
Implement dialogs for wifi required + recommended limits. This change extends the original work to add a size limit over which wifi is required to download a file. First, this change adds a second size limit, over which wifi is recommended but not required. The user has the option to bypass this limit. Second, this change implements dialogs shown to the user when either limit is exceeded. These dialogs are shown by the background download manager service when a download is started and found to be over the limit (and wifi is not connected). I'm including one small fix to the unit tests needed from the previous change. Change-Id: Ia0f0acaa7b0d00e98355925c3446c0472048df10
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
b9a0ad7182209d4aca708e13e876e9b1b43ffafc |
16-Sep-2010 |
Steve Howard <showard@google.com> |
Improve file error reporting + new detailed error messages in UI * support new error code for "destination file already exists" * improve error handling for various file error cases to return a more specific error code when appropriate * make UI support more detailed error messages for some cases * use Uri.getPath() instead of Uri.getSchemeSpecificPart() for file URIs Change-Id: Icb01d4d3b47c7776be3ddcd8347212e950cd023e
ownloads/PublicApiFunctionalTest.java
|
3398db8f3b195959faa2a7cf09918f364432ac28 |
15-Sep-2010 |
Steve Howard <showard@google.com> |
Fix notification bugs, cleanup DownloadService + DownloadReceiver This change started out just fixing a few regressions related to notifications: * Browser downloads weren't picking up a title from the determined filename. This was due to my change to default the title field to "" instead of null. * Notification click/hide events weren't being handled properly. This was due to previous change to the URI structure of DownloadProvider. DownloadReceiver needed to be changed to perform queries through /all_downloads URIs, like all other parts of the download manager code. I did some general refactoring of the DownloadReceiver code while I was there. * The code in DownloadNotification wasn't picking up some updates to downloads properly. This was due to my change to make DownloadNotification use the DownloadInfo objects rather than querying the database directly, so that it could make use of info provided by the DownloadThread that didn't go into the DB. Fixing this didn't turn out to be all that complicated, but along the way to figuring this out I made some substantial refactoring in DownloadService which made it much cleaner anyway and eliminated a lot of duplication. That's something that had to happen eventually, so I'm leaving it all in. Change-Id: I847ccf80e3d928c84e36bc24791b33204104e1b2
ownloads/FakeSystemFacade.java
|
3d55d829c03fe78ad8cdab119293efb6c6e49c64 |
13-Sep-2010 |
Steve Howard <showard@google.com> |
New URI structure with "my_downloads" and "all_downloads" This change introduces a second view into the download manager database via a set of URIs starting with /all_downloads, renaming the original /download URIs to /my_downloads. In addition to making things more clear, this change allows the downloads UI to grant permissions on individual downloads to viewer apps. The old semantics were: * for ordinary callers, /download included only downloads initiated by the calling UID * for intraprocess calls or calls by root, /download included all downloads The new semantics are * /my_downloads always includes only downloads initiated by the calling UID, and requires only INTERNET permission. It could just as well require no permission, but that's not possible in the framework, since path-permissions can only broaden access, not tighten it. It doesn't matter, because these URIs are useless without INTERNET permission -- if a user can't initiate downloads, there's no reason to read this. * /all_downloads always includes all downloads on the system, and requires the new permission ACCESS_ALL_DOWNLOADS. This permission is currently protectionLevel=signature -- this could be relaxed later to support third-party download managers. All download manager code has been changed to use /all_downloads URIs, except when passing a URI to another app. In making this change across the download manager code, I've taken some liberties in cleaning things up. Other apps are unchanged and will use /my_downloads. Finally, this incorporates changes to DownloadManager to return a content URI for /cache downloads -- the download UI no longer assumes it's a file URI, and it grants permissions to the receiver of the VIEW intent. The public API test has also been updated. I've also fixed some null cursor checking in DownloadManager. Change-Id: I05a501eb4388249fe80c43724405657c950d7238
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
71e7fda9135a0915af1fd419d07ebf85ad09beb4 |
09-Sep-2010 |
Steve Howard <showard@google.com> |
Further work on the new downloads UI. * add support for downloads not visible in the UI * add support for restarting failed downloads and downloads for which the file is missing * add "clear selection" button to selection menu * fix DateSortedExpandableListAdapter to ensure the view refreshes properly anytime the underlying data changes * make DownloadList handle when a selected download gets deleted by another app * make DownloadList close a dialog for a pending download when the download starts * show a dialog when the user tries to open a download but the file is missing * display "<Unknown>" when no title is provided for a download * add a test case for DownloadManager.orderBy() (should've gone in the previous commit) Change-Id: Ibf3062e8228e7f2c1270be24d8d5527dfb064658
ownloads/PublicApiFunctionalTest.java
|
a89321ea04ced76d06f60f5909be203cb654a830 |
03-Aug-2010 |
Steve Howard <showard@google.com> |
Fix and test handling of null/empty download fields. Minor change to make title/description default to blank stings, and add test case covering all null/empty download fields. Change-Id: Id44344bc2e464f46589faed49c8f383a45a8d329
ownloads/PublicApiFunctionalTest.java
|
adb6887d3270d180c94eaf90878d5b67d74a8f28 |
31-Jul-2010 |
Steve Howard <showard@google.com> |
Clean up error codes returned by download manager. This set of changes cleans up the error codes returned by the download manager in various failure cases, aiming for improved consistency. Error codes are part of the public API so it's important to get this right now. The main changes here are: * Refactoring the flow of error status information throughout DownloadThread to make it more explicit, by having StopRequest accept a status code in its constructor and eliminating State.mFinaStatus. * Eliminating the use of valid HTTP 4xx statuses when those statuses weren't actually returned by the server. Now, if the returned error code is a valid HTTP status code, that means it was returned by the server. These cases have been replaced with more sensible artificial error codes, including a new ERROR_CANNOT_RESUME when an interrupted download can't be resumed. * Improvements to some of the error handling code paths -- ensuring we don't clear the cache for external downloads, ensuring we don't fail with CANNOT_RESUME when the download hasn't actually started yet, removing the restriction on acceptable mime types for public API downloads. Change-Id: I0d825845fe0fe7ed5df74bad26e8d34ac0d1cc4e
ownloads/PublicApiFunctionalTest.java
|
9da9df3d6e84a3c4b04dd22d277e0e6d8f7f1ccb |
29-Jul-2010 |
Steve Howard <showard@google.com> |
Make all public API downloads visible. This change makes all downloads through the public API visible by default. It removes the API that had allowed applications to control notifications while the download runs. This has been replaced with a hidden API, since such behavior is needed by SystemUpdater and Market (for self-updates). Additionally, the behavior is now protected by a new permission. I'm making this permission signatureOrSystem, and changing the non-purgeable permission to the same (it should've been that, I just didn't know). I'm also adding string descriptions to appease the translation folks. Change-Id: I192e8b19ff9b0e425257cef0db081c3d75996ea5
ownloads/PublicApiFunctionalTest.java
|
0d4f9f105c3a31475a36e9a1edfa868c66ff455f |
28-Jul-2010 |
Steve Howard <showard@google.com> |
Get wifi limit from secure settings. Change-Id: I750654c28cb3d9f9aa67bd56e4d8d770dbfde4b4
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
dea0a5f8e5804d3aba40eaa7de763dd88058384e |
28-Jul-2010 |
Steve Howard <showard@google.com> |
Add test for many interruptions to a single download. Adding a new test case for downloads that undergo many interruptions (as may happen with a very large download that takes many hours). Includes some refactoring in the test suite. Early on, this test exposed a race condition in which the download manager got some I/O exception while reading from the MockWebServer. I went in and improved/refactored much of the error logging code in DownloadThread to try and track this down. Unfortunately, once I finished, the race condition no longer seems to be reproducible, even with hundreds of runs of the test case. So I've given up on it for now. In any event, error logging is better and much duplicate code has been eliminated.
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
f85aa9ef563f2fbb3c0db6c980121122a14d953f |
27-Jul-2010 |
Steve Howard <showard@google.com> |
Improved support for 302/307 redirects. Change the download manager's handling of 302/307 temporary redirects so that after an interruption of any kind, the delayed retry/resume will return to the original URI. This complies better with the HTTP spec. This change also makes the download manager handle other redirects immediately rather than using the delay that's otherwise applied to download errors. I made one more method extraction in DownloadThread to simplify this change, pulling the top-level logic for a single request into executeDownload(). It was then just a matter of introducing a new RetryDownload exeception, similar to StopRequest, and making the redirection code use it. Change-Id: Ic719c5725a9fd2e5eebe4dc03453ee71d9f27cd4
ownloads/PublicApiFunctionalTest.java
|
f6b4c24b4a876daa3f4e91d6da418983222b9dfd |
28-Jul-2010 |
Steve Howard <showard@google.com> |
Fix bug with closing output stream for external downloads. I added a unit test to cover this, and it caught another issue with disallowing external destinations outside of the default downloads directory (which are now allowed with the new API). Change-Id: I4df6442bebb06458ad28c85f6bc8cbcbf3ce67a1
ownloads/PublicApiFunctionalTest.java
|
e6a05a1aa4697440e9630d12b741b3bae321fe49 |
27-Jul-2010 |
Steve Howard <showard@google.com> |
Serialize threading for download manager testing. The download manager uses threading in a simple way -- it launches two threads, UpdateThread and DownloadThread, and both are "fire and forget". This is fortunate for testing, since it means we can eliminate multithreading and simply run each thread in order, and everything still works. This change does just that, abstracting Thread.start() behind SystemFacade and making FakeSystemFacade put new threads into a queue and then run through them serially. This simplifies much of the test code and makes it all much more predictable. I've simplified the test code as much as possible here and moved a few more tests over to PublicApiFunctionalTest, leaving only a minimum in DownloadManagerFunctionalTest, which will eventually be deleted altogether. I've also improved testing in some areas -- for example, we can now test that running notifications get cancelled after the download completes in a robust way. There is one test case that checks for race conditions and requires multithreading. I've moved this into a new ThreadingTest class, which uses a custom FakeSystemFacade that allows multithreading. I've extracted AbstractPublicApiTest for the newly shared code. Change-Id: Ic1d5c76bfa9913fe053174c3d8b516790ca8b25f
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/AbstractPublicApiTest.java
ownloads/DownloadManagerFunctionalTest.java
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
ownloads/ThreadingTest.java
|
93155e1da7e89d4925e244f5afa94afb8ada7381 |
24-Jul-2010 |
Steve Howard <showard@google.com> |
Stub out and test system notifications. This change abstracts NotificationManager interactions behind SystemFacade and takes advantage of that to test notifications, to a limited degree. It also fixes a silly typo in AbstractDownloadManagerFunctionalTest, and it introduces an extra sleep between tests to avoid some flakiness. I'll look for a better solution to that problem after this change goes in. Change-Id: I3a0307f828955cd45b0e3581ad499da28cc0556e
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
691fc58e9a61d99ab5018c5ddc8349ed413e4470 |
24-Jul-2010 |
Steve Howard <showard@google.com> |
Test + utilize change notification in DownloadProvider Now that I've learned how ContentResolver.notifyChange() works, add a test to explicitly check it's being called in DownloadProvider, and take advantage of it in waitForDownloadToStop to get rid of the ugly old polling mechanism. Change-Id: Iba71bdf1b0d31454cc4e186ceb4fdd9fdb5faad5
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
0a77c62a82503b38c484e0079648f0231dd85d53 |
21-Jul-2010 |
Steve Howard <showard@google.com> |
Public API support for broadcasts and connectivity control. * Three new DB fields, one indicating whether a download was initiated by the public API or not, two to hold connectivity control info. DB migration to add these fields and code in DownloadProvider.insert() to handle them. * Change broadcast intent code to match public API spec, for public API downloads only. (Legacy code can go away once existing clients are converted over to the new API.) * Introduce SystemFacade methods for sending broadcasts and checking package ownership; this facilitates new tests of broadcast code. * Change DownloadInfo.canUseNetwork() to obey new connectivity controls available in public API, but again, retain legacy behavior for downloads initiated directly through DownloadProvider * New test cases to cover the new behavior Also made a couple changes to reduce some test flakiness I was observing: * in tearDown(), wait for any running UpdateThread to complete * in PublicApiFunctionalTest.setUp(), if the test directory already exists, remove it rather than aborting DB changes for broadcast + roaming support Change-Id: I60f39fc133f678f3510880ea6eb9f639358914b4
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
b5629da794cb3c1ca1970d206343743b165b9644 |
16-Jul-2010 |
Steve Howard <showard@google.com> |
Major refactoring of DownloadThread.run(). Motivation: I need to fix the handling of 302s, so that after a disconnect, subsequent retries will use the original URI, not the redirected one. Rather than store extra information in the DB, I'd like to just keep the redirected URI in memory and make the redirected request within the same DownloadThread. This involves working with the large-scale structure of DownloadThread.run(). Since run() was a ~700 line method, I didn't feel comfortable making such changes. So this change refactors run() into a ~80 line method which calls into a collection of ~20 other short methods. The state previously kept in local variables has been pulled into a couple of state-only inner classes. The error-handling control flow, formerly handled by "break http_request_loop" statements, is now handled by throwing a "StopRequest" exception. The remaining structure of run() has been simplified -- the outermost for loop, for example, could never actually repeat and has been removed for now. Some other bits of code have been cleaned up a bit, but the functionality has not been modified. There are many good next steps to this refactoring. Besides various other cleanup bits, a major improvement would be to consolidate the State/InnerState classes, move some functionality to this new class (there are many functions of the form "void foo(State)" which would be good candidates), and promote it to a top-level class. But I want to take things one step at a time, and I think what I've got here is a major improvement and should be enough to allow me to safely implement the changes to redirection handling. In the process of doing this refactoring I added many test cases to PublicApiFunctionalTest to exercise some of the pieces of code I was moving around. I also moved some test cases from DownloadManagerFunctionalTest. Over time I'd like to move everything over to use the PublicApiFunctionalTest approach, and then I may break that into some smaller suites. Other minor changes: * use longs instead of ints to track file sizes, as these may be getting quite large in the future * provide a default DB value of -1 for COLUMN_TOTAL_BYTES, as this simplifies some logic in DownloadThread * small extensions to MockResponse to faciliate new test cases Change-Id: If7862349296ad79ff6cdc97e554ad14c01ce1f49
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/DownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
5180de23e77139dd6971dfd48269242e3e3562d9 |
20-Jul-2010 |
Steve Howard <showard@google.com> |
Fix bug with deciding when to restart a download. In previous refactoring I had combined the code for starting a download (from DownloadService.insertDownload()) and restarting a download (from DownloadService.updateDownload()). I'd missed the fact that the former checks DownloadInfo.isReadyToStart() while the latter checks DownloadInfo.isReadyToRestart(). This cause a race condition where multiple startService() calls during a download would cause the service to try to spawn a second thread for the same running download. I've fixed the bug and added a test case to exercise this. Change-Id: Ia968331a030137daac7c8b5792a01e3e19065b38
ownloads/PublicApiFunctionalTest.java
|
071bd7acb3185f4f1e807855605c5e6018e9742f |
16-Jul-2010 |
Steve Howard <showard@google.com> |
Support for max download size that may go over mobile This change introduces support for a maximum download size that may go over a mobile connection. Downloads above this limit will wait for a wifi connection. To accomplish this, I moved a lot of the logic for checking connectivity info into DownloadInfo itself. I then moved the code to call these checks from DownloadService, where it would call the checks before spawning a DownloadThread, into DownloadThread itself. This makes it simpler to check connectivity after we get Content-Length info. It also eliminates the risk of a race condition where connectivity changes between the check and the actual request execution. I realize this change reduces efficiency, because we now call into ConnectivityManager/TelephonyManager twice per DownloadThread, rather than once per DownloadService "tick". I feel that it's OK since its a small amount of computation running relatively infrequently. If we feel that it's a serious concern, and that the efficiency issues outweigh the race problem, I can go easily back to the old approach. I've left out the code to actually fetch the limit. I think this will come from system settings, but I want to double-check, so I'll put it in a separate change. Other changes: * simplify SystemFacade's interface to get connectivity info - rather than returning all connected types, just return the active type, since that should be all we care about * adding @LargeTest to PublicApiFunctionalTest Change-Id: Id1faa2c45bf2dade9fe779440721a1d42cbdfcd1
ownloads/FakeSystemFacade.java
ownloads/PublicApiFunctionalTest.java
|
af28400b74de05862b470412a5c92f68e99f59f8 |
16-Jul-2010 |
Steve Howard <showard@google.com> |
Introduce a seam to ConnectivityManager and TelephonyManager This change abstracts access to ConnectivityManager and TelephonyManager behind methods on SystemFacade, moving the code from Helpers into RealSystemFacade and adding fake implementations to FakeSystemFacade. This facilitates new connectivity tests. Change-Id: Id6c6b861e1d4ca45b3c1572bfb8ae0aa26af756b
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/DownloadManagerFunctionalTest.java
ownloads/FakeIConnectivityManager.java
ownloads/FakeSystemFacade.java
|
5224c6fbf20b4803a580ef449ab87ebfbbfedb78 |
14-Jul-2010 |
Steve Howard <showard@google.com> |
Support for custom HTTP headers on download requests Provider changes: * new many-to-one DB table holding headers for each download. since there was no real migration logic in DownloadProvider, I implemented some. * DownloadProvider.insert() reads request headers out of the ContentValues and puts them into the new table * DownloadProvider.query() supports a new URI form, download/#/headers, to fetch the headers associated with a download * DownloadProvider.delete() removes request headers from this table Service changes: * made DownloadInfo store request headers upon initialization. While I was at it, I refactored the initialization logic into DownloadInfo to get rid of the massive 24-parameter constructor. The right next step would be to move the update logic into DownloadInfo and merge it with the initialization logic; however, I realized that headers don't need to be updatable, and in the future, we won't need the update logic at all, so i didn't bother touching the update code. * made DownloadThread read headers from the DownloadInfo and include them in the request; merged the custom Cookie and Referer logic into this logic Also added a couple new test cases for this stuff. Change-Id: I421ce1f0a694e815f2e099795182393650fcb3ff
ownloads/PublicApiFunctionalTest.java
|
6d9b98282c817b86a00f9c19a705da4cb19bc3a6 |
13-Jul-2010 |
Steve Howard <showard@google.com> |
Support for file URI destinations + last modified timestamp File URI destinations: * permission checking in DownloadProvider * implementation in Helpers.generateSaveFile(). it's a fairly small amount of logic added here, but I did some significant method extraction to simplify this change and clean up the code in general. * added test case Last modified timestamp: * made DownloadProvider use a SystemFacade for getting system time, so I could properly test timestamps * updated test cases to cover last modified time + handle new ordering
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
df71633a02ce2f1b6228dad1ba3198185edf6107 |
02-Jul-2010 |
Steve Howard <showard@google.com> |
New functional test for download manager public API. I refactored a lot of the logic from DownloadManagerFunctionalTest into a new abstract class so that it could be shared with the new PublicApiFunctionalTest. There could be even more sharing, but it's not entirely clear it'd be worthwhile at this point. The new test covers most features of the new public API. Change-Id: I8c6859411f44b6430f8b348cf26a61225f5768cb
ownloads/AbstractDownloadManagerFunctionalTest.java
ownloads/DownloadManagerFunctionalTest.java
ownloads/PublicApiFunctionalTest.java
|
23357198c440e6872d3aef3e608295db7f8273bc |
23-Jun-2010 |
Steve Howard <showard@google.com> |
Stub out the system clock in the download manager, add tests Introduce SystemFacade, an interface that allows us to stub out the system clock for testing the download manager. This allows us to test retrying a failed download without having the test wait 60 seconds. This interface can include other dependencies in the future as well. I've also used this to add tests for 503 (retry-after) and 301 (redirect), and I've added a test for download to the cache partition. Other changes: * made MockWebServer capable of checking + rethrowing exceptions from child threads * refactoring + cleanup of DownloadManagerFunctionalTest
ownloads/DownloadManagerFunctionalTest.java
ownloads/FakeSystemFacade.java
|
b0aada69b9e6258bb9a1a7c1b783d0361ef3c6f2 |
30-Jun-2010 |
Steve Howard <showard@google.com> |
Fix build in master - new method in FakeIConnectivityManager Change-Id: I76996b9a7b6d0f725480cacb1da032cec2dade0b
ownloads/FakeIConnectivityManager.java
|
d6f9b5e72a135365f2358d79b3ea3c9f7cb99c8e |
10-Jun-2010 |
Steve Howard <showard@google.com> |
First pass at a functional test for the Download Manager. This "Large" test sets up an HTTP server on the device using MockWebServer and then initiates downloads from that server through the download manager. It uses ServiceTestCase to control the construction and execution of the DownloadService, and it uses some logic from ProviderTestCase2 to construct a DownloadProvider and a ContentResolver that uses it. This setup gives us some ability to mock dependencies. This commit includes use of a fake ConnectivityManager to test responses to connectivity changes, and use of some customizations to MockWebServer to test resuming an interrupted download. This test is disabled, though, since it requires a very long sleep. Avoiding that, and achieving certain other things, will require changes to the Download Manager code itself to introduce new seams. I wanted to check this in before I started such changes. Change-Id: Iefb13b3c3cccdc13fabe5cc18703e13244805539
ownloads/DownloadManagerFunctionalTest.java
ownloads/FakeIConnectivityManager.java
|