summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* New PendingIntents when extras change.Jeff Sharkey2013-03-261-2/+4
| | | | | | | Otherwise notifications end up launching with stale download IDs. Bug: 8417220 Change-Id: Ie72a2f4ac7b72213678ac6001af45709034492dd
* Unregister observer when tearing down service.Jeff Sharkey2013-03-263-5/+7
| | | | | | | Also reduce and adjust some logging. Bug: 8470658 Change-Id: Ia1f1cbd315ded04edd2113506e5c5a1db5ec85b4
* Revert "Avoid sending messages after HandlerThread.quit()."Fabrice Di Meglio2013-03-261-12/+6
| | | | | | This reverts commit 97d507d95f9885ceb12f2ce2483361b5ed265f9f Change-Id: I20374301561b3a1c79c2d986292af50049de2aac
* Avoid sending messages after HandlerThread.quit().Jeff Sharkey2013-03-251-6/+12
| | | | | Bug: 8470658 Change-Id: I4cfd6a01c2c2d845a72d3f58c29eec8b44176537
* Reduce logging, dump stacks before wtf().Jeff Sharkey2013-03-253-6/+44
| | | | | | | | | Most wtf() are looking like network timeouts, not threading bugs, so disable verbose debugging and add more targeted thread logging before calling wtf(). Bug: 8233041 Change-Id: I8e276bffd7880cfe13b65e7e81f5507cab627692
* Merge "Increase timeout for domains with many DNS entries." into jb-mr2-devJeff Sharkey2013-03-211-2/+2
|\
| * Increase timeout for domains with many DNS entries.Jeff Sharkey2013-03-201-2/+2
| | | | | | | | | | Bug: 8233041 Change-Id: Ifb70273474c391ef687ba018d9ef809a359c7149
* | Defeat transparent Accept-Encoding: gzip.Jeff Sharkey2013-03-181-0/+4
|/ | | | | | | | Transparent gzip encoding doesn't allow us to easily resume partial requests, so defeat it for now. Bug: 8409417 Change-Id: I1172709c09d1153fff1ba8df072a9bef896e244d
* Fix race conditions around filename claiming.Jeff Sharkey2013-03-011-10/+20
| | | | | | | | | | | | | 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
* 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
* 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
* 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-124-371/+401
| | | | | | | | | | | | | | | | | | 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
* 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-292-12/+11
| | | | | | | | | | 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
* Better handling of retryable errors.Jeff Sharkey2013-01-174-58/+59
| | | | | | | | 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-094-101/+153
| | | | | | | | | | 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-40/+8
| | | | | | | | | | | 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-171-30/+34
| | | | | | | | | | | | 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.
| * Cancel stale notifications when starting.Jeff Sharkey2012-12-132-0/+5
| | | | | | | | | | Bug: 7693834 Change-Id: I5e212be321cccae0f7c76f80049c4e09f0867694
* | Move DownloadManager to HttpURLConnection.Jeff Sharkey2012-12-122-265/+116
|/ | | | | | | | | | Apache HttpClient is in maintenance mode, and doesn't have support for features like Server Name Indication (SNI). This change moves DownloadManager to use HttpURLConnection internally. It also moves redirection handling into HttpURLConnection. Bug: 7070597 Change-Id: Ie80093eeeecd14f94e1c8b7597ff3f8f5d220691
* Improve download remaining time calculation.Jeff Sharkey2012-11-283-26/+14
| | | | | | | | | | | Calculate remaining time in DownloadNotifier so we always use the most recent progress data, which avoids showing stale times. Weight speed calculation to prefer historical data so remaining time is smoother on bumpy network connections. Bug: 7631948 Change-Id: I497be0899e65086356745340b19d3987c6185bdd
* Update extras for in-progress download.Jeff Sharkey2012-11-272-1/+3
| | | | | | | | Follow move to EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS extras, which was missing during refactoring. Bug: 7617373 Change-Id: I26203a2bc6fc0e211a1aa602c0de018332d76f60
* Show remaining time in download notifications.Jeff Sharkey2012-11-144-16/+82
| | | | | | | | | | 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-095-396/+426
| | | | | | | | | | | | | | | | | | 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
* Better sanity checking for finished downloads.Jeff Sharkey2012-10-242-2/+35
| | | | | | | | | | | | | | | Downloads in the RUNNING state are considered ready to start so that downloads are correctly resumed when the process crashes. However, this causes a race condition while UpdateThread is processing a Cursor when a DownloadThread finishes. With this change, DownloadThread now skips requests for downloads already marked as finished. Apps listening for the DOWNLOAD_COMPLETE broadcast will no longer see data mutated by the second thread, and will not see the broadcast duplicated. Bug: 6948938, 6970458, 6818900 Change-Id: I35deac3cedbfe7f50091fab5818d85594dba558c
* Bring back DRM mimetypes.Jeff Sharkey2012-10-191-1/+4
| | | | | | | I don't like DRM, but other people do. Bug: 7370549 Change-Id: I44220404eab6e6cc85ea16cfcf58474135c03f83
* Skip scanning a file which will be deleted.Jeff Sharkey2012-10-051-3/+0
| | | | | | | | | When deleting a download, don't bother scanning it, since we'll just delete it moments later. This was already racy since it didn't even wait for the scan to complete. Bug: 7256243 Change-Id: I8c3b96823d94bc1688ef336cb45746ccd35fc760
* Handle not fully connected networks.Jeff Sharkey2012-10-031-1/+1
| | | | | | | | | When checking network status, treat non-connected networks as disconnected. This handles cases like captive portal checks, and slow DHCP servers. Bug: 7264340 Change-Id: I0b466cee5d5cb73037f3fb209c583711b8f9eefd
* Merge "Remove FLAG_ACTIVITY_NEW_TASK from the VIEW intent." into jb-mr1-devRuben Brunk2012-09-282-1/+2
|\
| * Remove FLAG_ACTIVITY_NEW_TASK from the VIEW intent.Ruben Brunk2012-09-262-1/+2
| | | | | | | | | | | | | | | | | | Bug: 7164238 Bug: 7237908 Got rid of FLAG_ACTIVITY_NEW_TASK for proper back behavior Change-Id: I50af9aeafb27d6079bda4f81f4a116b6bb600676
* | Send uid of the application that initiated the downloadBen Gruver2012-09-271-0/+17
|/ | | | | Bug: 6923241 Change-Id: Idf4037b4e360cb6453b315d1cc95608762c9e0c8
* Send ORIGINATING_URI and REFERRER to installer.Jeff Sharkey2012-08-272-17/+110
| | | | | | | | | When building PackageInstaller intents, include ORIGINATING_URI and REFERRER extras. Unify view intent building for both notifications and list UI. Bug: 6900672 Change-Id: I18435e0f8aa549880ec594f82b6a250232706135
* am d7dd6019: Merge "Adds missing Bluetooth as network type."Jean-Baptiste Queru2012-08-081-0/+3
|\ | | | | | | | | * commit 'd7dd6019baf12961dce722d33003e238cdd72f6a': Adds missing Bluetooth as network type.
| * Adds missing Bluetooth as network type.HÃ¥kan3 Johansson2012-07-101-0/+3
| | | | | | | | | | | | | | | | The network connection type for Bluetooth is added so that it is possible to use Bluetooth as Hotspot during download from the Internet. Change-Id: Ic32b083068d8316a41f2c31a3575a28163f6c7f3
* | Move notification tests to LittleMock.Jeff Sharkey2012-07-245-55/+50
| | | | | | | | | | | | Directly mock NotificationManager instead of using SystemFacade. Change-Id: If932d26e23816e8674469c275a828701cce5fc2d
* | Reduce deletion logging.Jeff Sharkey2012-07-203-14/+23
|/ | | | | Bug: 6544953 Change-Id: I4157c67b9b9cddab4ade795c328a202f6a230f95
* am f918429d: Uniform "when" to avoid flashing notifications.Jeff Sharkey2012-06-071-1/+16
|\ | | | | | | | | * commit 'f918429d0c1927a19d688baa26a07c2c65765580': Uniform "when" to avoid flashing notifications.