summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Fix race conditions around filename claiming.Jeff Sharkey2013-03-012-10/+66
| | | | | | | | | | | | | 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
* Adjust timeouts to reduce false-positive bugs.Jeff Sharkey2013-02-262-4/+4
| | | | | | | | | Otherwise we end up triggering MSG_FINAL_UPDATE while still waiting for socket timeouts. Using 20 seconds for timeout is more sane, and matches Volley. Bug: 8233041 Change-Id: Ia7220033a5942c46ca1d79a88e2b3f530cb3edac
* 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
* Merge "Ack, we actually need to UpdateThread.quit()."Jeff Sharkey2013-02-211-8/+6
|\
| * Ack, we actually need to UpdateThread.quit().Jeff Sharkey2013-02-201-8/+6
| | | | | | | | | | | | | | | | | | Otherwise they end up leaking. There is a race around UpdateThread continuing to process messages before onDestroy() has been invoked, so explicitly UpdateThread.quit() in both places. Bug: 8233041 Change-Id: I73f1b70aedace19e23a61a3dddf4986d82f2c7d6
* | Merge "Only use single UpdateThread."Jeff Sharkey2013-02-201-4/+5
|\|
| * Only use single UpdateThread.Jeff Sharkey2013-02-201-4/+5
| | | | | | | | | | | | | | | | Since DownloadService starts and stops frequently, recycle a single UpdateThread across invocations. Bug: 8233041 Change-Id: I07756fb6bfdbad811cbd58e628fdfdbf63d71bf8
* | Merge remote-tracking branch 'goog/jb-mr2-release'Ed Heyl2013-02-200-0/+0
|\ \ | |/ |/|
| * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-02-200-0/+0
|/|
| * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-02-190-0/+0
| |\
| | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-02-130-0/+0
| | |\
| | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-02-110-0/+0
| | | |\
| | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-02-070-0/+0
| | | | |\
| | | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-02-060-0/+0
| | | | | |\
| | | | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-02-010-0/+0
| | | | | | |\
| | | | | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-01-310-0/+0
| | | | | | | |\
| | | | | | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-01-300-0/+0
| | | | | | | | |\
| | | | | | | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-01-290-0/+0
| | | | | | | | | |\
| | | | | | | | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-01-230-0/+0
| | | | | | | | | | |\
| | | | | | | | | | | * merge in jb-mr2-release history after reset to masterThe Android Automerger2013-01-180-0/+0
| | | | | | | | | | | |\
| | | | | | | | | | | | * merge in master-release history after reset to masterThe Android Automerger2013-01-140-0/+0
| | | | | | | | | | | | |\
| | | | | | | | | | | | | * Only add one User-Agent header.Jeff Sharkey2013-01-102-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also include more details when reporting HTTP error codes. Bug: 7966393 Change-Id: I251b1ec7c827693817391b6e9fb8b0cab995395e
* | | | | | | | | | | | | | Only report speeds from full samples windows.Jeff Sharkey2013-02-192-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Wait until we've passed a full sample window (500ms) before reporting an estimated speed. This avoid showing skewed times like "900 hours remaining." Also remember to clean up the UpdateThread. Bug: 8176417 Change-Id: I851e0abcbb443114abe9c22f4650fee7a9bc3aaa
* | | | | | | | | | | | | | Retries shouldn't backoff when network changes.Jeff Sharkey2013-02-193-26/+22
|/ / / / / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a download fails due to a network change, treat it as waiting for network, instead of subjecting it to full retry backoff. Change-Id: Ifdae62fd7c2baad7422f68e09da94740b5f513d0
* / / / / / / / / / / / / Update database before sending broadcast.Jeff Sharkey2013-02-141-1/+1
|/ / / / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was moved to to solve a race condition around service shutdown, but ended up causing another race with remote apps. Bug: 8200919 Change-Id: Ief470e9454e9be8ec43ca3ec11e3b3440fa5852d
* / / / / / / / / / / / Redesign of DownloadManager update loop.Jeff Sharkey2013-02-127-372/+459
|/ / / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* / / / / / / / / / / Active notifications only for running downloads.Jeff Sharkey2013-02-071-1/+2
|/ / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 8145142 Change-Id: I9119796f809aa967f7ec6bb2a3d2b815e86eaf1b
* / / / / / / / / / Allow granting access to "my_downloads" paths.Jeff Sharkey2013-02-061-0/+3
|/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PackageInstaller attempts to grant Uri permissions on my_downloads paths passed internally. This change lets the system successfully grant permissions to these paths. Bug: 7426851 Change-Id: I9a4eea4397c02175aff4e3881a9a79cea1e6e0e3
* / / / / / / / / Update Downloads UI for RTL languages.Jeff Sharkey2013-02-052-9/+15
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 8133419 Change-Id: I0c8c0909e41d51cfa2e136304a0a13c5d46afb3b
* / / / / / / / Migrate to using Mockito directly.Jeff Sharkey2013-01-313-9/+9
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | Change-Id: Ice24d5c62bbcbcfd3d7374eac3a20580f7f31f36
* / / / / / / Dump recent downloads from provider.Jeff Sharkey2013-01-301-1/+41
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lifetime of DownloadService can be limited, and it's often missing from bugreports. The provider has a much longer lifetime, so have it dump raw data about recent downloads. Bug: 7350685 Change-Id: I55c9d602d77014ea27820936f1cf5c8ad24f286a
* / / / / / Tests for max retries/redirects, ETag switches.Jeff Sharkey2013-01-297-26/+119
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* / / / / Cleaner thread management, less global state.Jeff Sharkey2013-01-285-149/+101
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch to using a ThreadPoolExecutor for handling downloads, which gives us parallelism logic that is easier to reason about. Also open the door to eventually waiting until the executor is drained to stopSelf(). Removes DownloadHandler singleton, and gives explicit path for publishing active download speeds to notifications. Change-Id: I1836e7742bb8a84861d1ca6bd1e59b2040bd12f8
* / / / Import translations. DO NOT MERGEBaligh Uddin2013-01-221-1/+1
|/ / / | | | | | | | | | | | | Change-Id: I37a549fc1bf508361eb7f2fbfaebbdf9d173db38 Auto-generated-cl: translation import
* / / Better handling of retryable errors.Jeff Sharkey2013-01-175-59/+60
|/ / | | | | | | | | | | | | | | 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
* | Move network state to enums for type safety.Jeff Sharkey2013-01-122-91/+68
| | | | | | | | Change-Id: Ib8ea24fc58a866f8a5626cdd20e5891eb0a2bbeb
* | Only add one User-Agent header.Jeff Sharkey2013-01-102-10/+16
|/ | | | | | | Also include more details when reporting HTTP error codes. Bug: 7966393 Change-Id: I251b1ec7c827693817391b6e9fb8b0cab995395e
* Simplify download flow control, handle redirects.Jeff Sharkey2013-01-096-110/+165
| | | | | | | | | | 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-0812-127/+84
| | | | | | | | | | | 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
* Remove singleton StorageManager.Jeff Sharkey2013-01-054-27/+19
| | | | | | | Now DownloadService creates and owns the lifecycle of its own StorageManager instance. Change-Id: I8f6bedc02f1dbe610a8e6a25d55383a12716d344
* Fold InnerState into State.Jeff Sharkey2012-12-201-47/+46
| | | | | | | It was cluttering up method signatures, and can easily be reset before starting each download pass. Change-Id: I7dee9d2160c3b5f737e7db86baa826d5d0b04b2d
* Always append to files, handle end of stream.Jeff Sharkey2012-12-172-34/+39
| | | | | | | | | | | | 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
* Merge "Cleaner I/O."Jeff Sharkey2012-12-135-351/+86
|\
| * Cleaner I/O.Jeff Sharkey2012-12-135-351/+86
| | | | | | | | | | | | | | | | | | | | | | | | This cleans up writing of downloaded data by always writing through OutputStream interface, which applies DRM if needed. Hands I/O streams along with method calls to give clearer chain of ownership. Only retry writes once after verifying free space. Remove checkCanHandleDownload() check, since most downloads are now using public API. Release DrmManagerClient sessions when finished. Change-Id: I49e479089a8218690b556d31ec65a030930ad368
* | am 195b46b8: am b0bb182a: Cancel stale notifications when starting.Jeff Sharkey2012-12-132-0/+5
|\ \ | |/ |/| | | | | * commit '195b46b8a59eb522fc91ac6f498f359a337d3f3e': Cancel stale notifications when starting.
| * am b0bb182a: Cancel stale notifications when starting.Jeff Sharkey2012-12-132-0/+5
| |\ | | | | | | | | | | | | * commit 'b0bb182a1b52b31ccf1ec5e0be82308ebb4857e2': Cancel stale notifications when starting.
| | * Cancel stale notifications when starting.Jeff Sharkey2012-12-132-0/+5
| | | | | | | | | | | | | | | Bug: 7693834 Change-Id: I5e212be321cccae0f7c76f80049c4e09f0867694
* | | am 770f0d7c: (-s ours) am 1d71eb6b: Import translations. DO NOT MERGEBaligh Uddin2012-12-120-0/+0
|\| | | | | | | | | | | | | | * commit '770f0d7ce322ffb332ae325d7377afc4dcae4f7a': Import translations. DO NOT MERGE
| * | am 1d71eb6b: Import translations. DO NOT MERGEBaligh Uddin2012-12-120-0/+0
| |\| | | | | | | | | | | | | * commit '1d71eb6b347cf861c53c1bc4c18b8928528b244c': Import translations. DO NOT MERGE
| | * Import translations. DO NOT MERGEBaligh Uddin2012-12-121-2/+2
| | | | | | | | | | | | | | | Change-Id: Icadeb210d13e600f85b1a1d21aaaa79e26d78240 Auto-generated-cl: translation import