History log of /packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
629eed8893ba5ef978a9f777047d560e95e43456 26-Aug-2014 Jeff Sharkey <jsharkey@android.com> fallocate() returning ENOSYS is okay.

Fall back just like ENOTSUP.

Bug: 17285472
Change-Id: Ice4954726c14a0e84c39c5469d573644588934ae
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
6ea35f0acc28b9ede6b49fcbd456d6eacfe3f55b 29-Apr-2014 Elliott Hughes <enh@google.com> OsConstants is moving.

Change-Id: Ie72e18f539cbad593c489bf52b9afea5330f62c1
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
1f2c2c560400ba60c5b9dfd6fd4f5e73b232803a 07-Feb-2014 Jeff Sharkey <jsharkey@android.com> Add idle service to clean orphan downloads.

Periodically reconcile database against disk contents. This handles
the case where a user/app deletes files directly from disk without
updating the database, and the rare case where a database delete
didn't make it to deleting the underlying file.

Also cleans up any downloads belonging to a UID when removed.

Bug: 12924143
Change-Id: I4899d09df7ef71f2625491ac01ceeafa8a2013ce
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
9b731a5521f569c91aeb419d43fa098a34cf78cb 27-Jan-2014 Doug Zongker <dougz@android.com> Revert "change download provider to use system log"

This reverts commit 4f9d2d04003fafb358d7c127054055b3a9732c9b, was only
wanted for debugging.
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
4f9d2d04003fafb358d7c127054055b3a9732c9b 27-Jan-2014 Doug Zongker <dougz@android.com> change download provider to use system log

Try to catch the download provider in the act of deleting pending
system updates.

Bug: 12680933
Change-Id: If58aba5c30fd624217e5d073730645af05e98ac7
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
9770a3c402da1e09f3a5143f089173805edff32b 05-Oct-2013 Jeff Sharkey <jsharkey@android.com> Treat deleted in-progress downloads as canceled.

Otherwise the download thread would keep going!

Bug: 11081405
Change-Id: Ib8f1b624b29cabc782b8a0047d7b5db7e39a17de
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
724817b1884584aaba4c99a6a1d4cf8cb8d2f7a3 07-Jun-2013 Jeff Sharkey <jsharkey@android.com> Count download WakeLocks against requesting app.

This matches how network usage is already counted against the app
making the request.

Change-Id: I6a862e096f2f99441925a101268235615000355a
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
7bef37e8158502889ad400319a8c458adaa14d2b 11-May-2013 Jeff Sharkey <jsharkey@android.com> Increment operation counts to track downloads.

Bug: 8850035
Change-Id: If506ea21f0c823f9da4b7ae14d611fdbfbac8042
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ff0220f5b4624049a1052bd868d7706eee5a0daf 26-Mar-2013 Jeff Sharkey <jsharkey@android.com> Unregister observer when tearing down service.

Also reduce and adjust some logging.

Bug: 8470658
Change-Id: Ia1f1cbd315ded04edd2113506e5c5a1db5ec85b4
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
844782d81e12d8bd13c9b26a5f7aab3f4be81b5a 19-Mar-2013 Jeff Sharkey <jsharkey@android.com> Defeat transparent Accept-Encoding: gzip.

Transparent gzip encoding doesn't allow us to easily resume partial
requests, so defeat it for now.

Bug: 8409417
Change-Id: I1172709c09d1153fff1ba8df072a9bef896e244d
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
80a535d83ea9ed21f443fdc701c743569ae53eec 26-Feb-2013 Jeff Sharkey <jsharkey@android.com> Adjust timeouts to reduce false-positive bugs.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
d1214c9c92b6a4a44cfc46125c33d071a0f3d880 20-Feb-2013 Jeff Sharkey <jsharkey@android.com> Only report speeds from full samples windows.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
2eb144d8effed2dbb067957c5b25e735233bca89 19-Feb-2013 Jeff Sharkey <jsharkey@android.com> Retries shouldn't backoff when network changes.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
292f9bffb4d4055db57b6e6419591f14e00bfc74 14-Feb-2013 Jeff Sharkey <jsharkey@android.com> Update database before sending broadcast.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
38648831a92295e9a11831e19e5a9dab4cbd939e 13-Jan-2013 Jeff Sharkey <jsharkey@android.com> Cleaner thread management, less global state.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
97862429de71477b5c4488faa911a2256b90089b 13-Jan-2013 Jeff Sharkey <jsharkey@android.com> Move network state to enums for type safety.

Change-Id: Ib8ea24fc58a866f8a5626cdd20e5891eb0a2bbeb
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
89afc754d46a8574a9e014c7670746668de9f9b3 10-Jan-2013 Jeff Sharkey <jsharkey@android.com> Only add one User-Agent header.

Also include more details when reporting HTTP error codes.

Bug: 7966393
Change-Id: I251b1ec7c827693817391b6e9fb8b0cab995395e
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
b62364ce70074dbdea03aafdc0f64c7ba39c3a69 21-Dec-2012 Jeff Sharkey <jsharkey@android.com> Fold InnerState into State.

It was cluttering up method signatures, and can easily be reset
before starting each download pass.

Change-Id: I7dee9d2160c3b5f737e7db86baa826d5d0b04b2d
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
5cff4ecb10e89e4fb39cd9e39b8753a31efbe3cc 07-Dec-2012 Jeff Sharkey <jsharkey@android.com> Cleaner I/O.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
c92dc11cd94f5b00f0193cc8cf1e03644d825590 06-Dec-2012 Jeff Sharkey <jsharkey@android.com> Move DownloadManager to HttpURLConnection.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
fec5f50a85e1bfc7bb4fa12d04ffa7526c79fad7 28-Nov-2012 Jeff Sharkey <jsharkey@android.com> Improve download remaining time calculation.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
2fa007ef678b2283d47d007aa3dc91af683cc52c 25-Oct-2012 Jeff Sharkey <jsharkey@android.com> Better sanity checking for finished downloads.

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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ebcc93801eb9545004536587d10f82db378aeab5 21-Jul-2012 Jeff Sharkey <jsharkey@android.com> Reduce deletion logging.

Bug: 6544953
Change-Id: I4157c67b9b9cddab4ade795c328a202f6a230f95
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
f8b1f373fd884fffe384acf564d0a4e374de8e02 20-Apr-2012 Jeff Sharkey <jsharkey@android.com> More slogging around download deletion.

Bug: 6362988
Change-Id: Iab4b86cfcaa6aeed6466f88ff49eb935f96db495
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
72f4a080b611311560b727a127011748698ca74e 07-Apr-2012 Jeff Sharkey <jsharkey@android.com> Give DownloadManager a useful user agent.

Include platform version, model, and build, when available. Matches
current logic used by Browser.

Bug: 6257336
Change-Id: I0addfd944aff13bd4ce4226bb8d6328da6b0f5d5
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
d078f62f67821576199aefc02a77fdc0d5b5b3ff 06-Apr-2012 Jeff Sharkey <jsharkey@android.com> Move to new NetworkPolicyManager accessor.

Change-Id: I21e5f6280748529bad881942f8f5534aa374ba55
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ae6856b0fca5215f45619dd031a7e7beae7bd8cc 29-Mar-2012 Jeff Sharkey <jsharkey@android.com> Migrate to shared MockWebServer.

Bug: 4726601
Change-Id: Ibe537bd5c2a092dbf974360cd454751881f7f4ea
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
50c85944bf5e949ad5116fec9564318b3be90f24 08-Feb-2012 Jeff Sharkey <jsharkey@android.com> Match INetworkPolicyListener changes.

Change-Id: I78b6b0380a42b28f42334f93e0538ba7f32bc66d
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ac71f70c31f38d5f99e5d3bb06ea08cdf107b948 09-Jan-2012 Nick Pelly <npelly@google.com> Update DownloadProvider for new Intent.normalizeMimeType() API.

Change-Id: Ideeb8cbeaa4b4d82d7c9fc8197a35bf3541a22d7
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
3e1f6ff817247a5003df0f2c9f27acaf84ad40ec 25-Oct-2011 Jeff Sharkey <jsharkey@android.com> Sanity check only after updating from file size.

Database values can be stale, so delay sanity check until after
updating from file size on disk.

Bug: 5484249
Change-Id: Ia648a575d4a3a391a1f06a866c8282f2d569f15e
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
c5c30ba14d411b3e23c983912e7fea4f449c9f54 14-Oct-2011 Jeff Sharkey <jsharkey@android.com> NPE check before finalizeDestinationFile().

Bug: 5461417
Change-Id: I16f1e8594162b006b80bf7f2cdc6630d0dedfa38
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ce3f6100a62a184d01125f3f4c5ece66c611bacc 29-Aug-2011 Doug Zongker <dougz@android.com> fix DownloadThread's use of ETag, range headers

DownloadThread was only maintaining ETag and the file size for the
duration of one HTTP request, rather than over all the requests needed
to fetch a file, which kind of defeats the point of having them. Fix
this by moving several state variables from InnerState to State, and
initializing the total bytes and current bytes values from the
download database.

Skip actually making the HTTP request if we've already downloaded all
the bytes of the file. This works around bug 5217390 by making the
second DownloadThread do nothing instead of trying to fetch past the
end of the file. (A real fix would eliminate the race condition that
causes the second thread to get created in the first place.)

Bug: 5217390
Change-Id: Ib5b8f87398b4ed2cb3d7f09569e245b55a89da5a
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
f21edd015711fc2bdb1c2ab5aed15f44bcc0cee7 25-Jun-2011 Jeff Sharkey <jsharkey@android.com> Migrate setThreadStatsTag() from String to int.

Bug: 4948913
Change-Id: I831b9149208f0cc007cf3ebede3ef433b2636600
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
9356a4a9b1b1e5be9a3bd639cd89bb30aa6a5ae5 03-Jun-2011 Gloria Wang <gwang@google.com> Merge "Download provider change for DRM Forward Lock plugin: to convert .dm files to .fl files during downloading For bug 3188041"
3fb34dc34e5b352d52b769fd3b695fbd0e2d60f8 22-Apr-2011 Jeff Sharkey <jsharkey@android.com> Add Socket tagging for granular data accounting.

Tag active downloads, and account data usage towards UID that made
the original request. Also release WakeLock only after we've cleaned
up the download.

Change-Id: I72d58c6a51beaeb357e59aae4d7c0f5ac9abaa8d
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
0a17c2a28738d6ecb274def0e8e54f556d89f5f3 16-Feb-2011 Gloria Wang <gwang@google.com> Download provider change for DRM Forward Lock plugin:
to convert .dm files to .fl files during downloading
For bug 3188041

Change-Id: I882b851664432fba3e57dc25a6be827b48006e69
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
690e0547b2baea784e47e61044a89f3732eb37b1 17-Mar-2011 Vasu Nori <vnori@google.com> am 32d9917c: am 7666801a: Merge "bug:4121206 handle STOPSHIP comments/code" into honeycomb-mr1

* commit '32d9917cd4f56cabcbafa645c8cd89cd832ac523':
bug:4121206 handle STOPSHIP comments/code
cc048de9b7b2433ef497e4495126a166409ad3f7 17-Mar-2011 Vasu Nori <vnori@google.com> bug:4121206 handle STOPSHIP comments/code

Change-Id: I3c9f8e3b11dd301a0921d89e0333883489f37e55
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
43e3f0d1295d43f763b65b3140f6cf98e2562dbd 10-Feb-2011 Vasu Nori <vnori@google.com> bug:3422868 collect additional info to debug this problem

this bug is not so easy to reproduce.
so, this CL will produce some additional logging info for better insight

Change-Id: I0d53c647f1b98a49eb93b937c8e7203723c33dbe
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
789745f667c65661d82ccbd5ef49fdb132911736 09-Feb-2011 Vasu Nori <vnori@google.com> bug:3435895 listen to media_mounted broadcast intent

and retry downloads that failed due to the error "sdcard media not mounted"

Change-Id: Id181b8167d331214f72679c85f18cc8b9b969e40
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
541c252a15ed47e838875061ff33f15276eee9bb 27-Jan-2011 Vasu Nori <vnori@google.com> am d47f3711: am 3ea897d9: Merge "bug:3396889 (HC branch) fix STOPSHIP code" into honeycomb

* commit 'd47f37112d4d0a95cd78e6ec3e14cbbb362b1595':
bug:3396889 (HC branch) fix STOPSHIP code
c14debbcb3db951663beb94b4065c7c09ce481d7 27-Jan-2011 Vasu Nori <vnori@google.com> bug:3396889 (HC branch) fix STOPSHIP code

Change-Id: I1eeb8c5a9936db08bc5997980dc6c7307691034e
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
1bfe9ac0443303227e91b85c10fb02190e4beb2e 23-Jan-2011 Vasu Nori <vnori@google.com> bug:3062216 (master) store correct status about network when paused

bug:3062216
Change-Id: I4d510a9fc2095ec86991ae657e90d5f39bc55415
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
3022abb31ad80a5e4b263ac078709e91b97bf226 16-Jan-2011 Vasu Nori <vnori@google.com> manual merge of GB change Change-Id: I1acf2fb9491d24f5e109206a91dda3eea429e447

Change-Id: Ibaf889d78fc99a32038a77671036fc6a5068580f
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
597bbd96431ca1fb655a21285cfd5411a67bad16 11-Jan-2011 Vasu Nori <vnori@google.com> bug:3338089 NPE in downloadthread

Change-Id: I95b4c52598092e9f6ffa1713b36ac11d44e26279
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ead1b057d86021f4f0a44bad8616ddae2aa39a40 11-Jan-2011 Vasu Nori <vnori@google.com> bug:3338089 print better error msg in DownloadThread when exception occurs

when download thread gets an exception and aborts a download, print
the stacktrace of the exception - so one can debug the problem.

Change-Id: Iab1bae3b6180d8601e84020453ff35815ae3e69f
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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.
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
c988ce18d1525820f6371d91809c056019e5b577 03-Dec-2010 Vasu Nori <vnori@google.com> manually merging Change-Id: If7dc0f86ea7a3c4394603416ca0fc33847f10fa7

need this CL from GB. without it, downloads are badly broken in master.

Change-Id: I82ebc467f877bed50e373c437481ad19e14635bf
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
cea99881d3e83cdbb29204927db9e23c1785bdb6 02-Dec-2010 Vasu Nori <vnori@google.com> am 084c3dc3: am 26f86843: Merge "(GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC" into gingerbread

* commit '084c3dc34ed9e6ae9ddc471819de0d6d55021dfd':
(GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC
084c3dc34ed9e6ae9ddc471819de0d6d55021dfd 02-Dec-2010 Vasu Nori <vnori@google.com> am 26f86843: Merge "(GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC" into gingerbread

* commit '26f86843f48b3d7878837a1a9f93865b3eba0aee':
(GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC
e49f651bdce9fc91c6bad97f5c1bb26bba82e41f 02-Dec-2010 Vasu Nori <vnori@google.com> (GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC

Real fix is in Change-Id: Ifea1544737023008eff44aef9acd976902a0c143
In the database, sometimes _data column in downloads is set to null
and sometimes to empty string. this is inconsistent
and causes bugs such as bug:3144642.
This bug is caused by line# 793 in DownloadThread.
state.mFileName is null sometimes and empty string sometimes - because
the correspodning field is set inconsistentlt in downloads.db
_data column.

in GB MR, apply a bandaid because real fix could be too risky for
GB.

Change-Id: I115b3ba6cfe0262269dbbc4c336b9e1d63c618e4
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
9d27069a5453574824860ad3db179599d044e7bd 12-Nov-2010 Vasu Nori <vnori@google.com> when a download fails, store the error msg in db

useful for debugging for bugs like bug:3187299
without this error message, one doesn't know WHY downloads
fail.
to prevent PII info in database,
there is a STOPSHIP comment around storage of this error
message in database.

Change-Id: I612e383aef8483b68b772f70dff722a5daea2ef5
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
04f09085f85d094207d22ae8969102bd48178180 20-Oct-2010 Vasu Nori <vnori@google.com> remove usage of hidden public constants.

Change-Id: I2edf1bef5e741de8193cb293807e3ace42003b0c
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ace1d5da2b288f6166224cf2164731ae0fa2de61 01-Oct-2010 Steve Howard <showard@google.com> am d4dc8501: Merge "Seriously improve error reporting in DownloadThread." into gingerbread

Merge commit 'd4dc8501ecb89b91f865510207297dd960afe031' into gingerbread-plus-aosp

* commit 'd4dc8501ecb89b91f865510207297dd960afe031':
Seriously improve error reporting in DownloadThread.
26604ffc248081b8014ff7260536d18b43cb0de9 01-Oct-2010 Steve Howard <showard@google.com> Seriously improve error reporting in DownloadThread.

My old error reporting strategy for DownloadThread was to log the
stack trace for the exception, so we'd know exactly what conditions
caused the StopRequest. hackbod suggested that we shouldn't log
tracebacks as they clutter the log. Instead, we should just always
include a little string tag explaining why the request is being
stopped -- this is more concise and more useful to developers.

There are three main changes here to acheive this goal:
* make StopRequest require a short, log-friendly error message upon
construction, and add such a message to all construction sites
* make a similar change to GenerateSaveFileError, so that the variety
of errors that originate with Helpers.generateSaveFile() get
similarly fine-grained and concise error reporting
* make network usable checking code return a distinct error code for
each distinct negative condition, and add a utility to return a
log-friendly error message for each such code.

Finally, I cleaned up some of the ways errors/exceptions are handled
in the process.

Change-Id: Ie70cbf3f2960e260e97f8449258e25218d0f900f
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
ed2f11502fb02509d9efec1dbda7981c86f37fbd 30-Sep-2010 Steve Howard <showard@google.com> resolved conflicts for merge of b108a273 to gingerbread-plus-aosp

Change-Id: Iced3a5360702fdeb299f8b987a353d3aeca7629b
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
5dbaa73a7f356f67810becbf3ad258a7dd765e59 23-Sep-2010 Steve Howard <showard@google.com> am ebb555c0: Support multi-valued HTTP headers, handle new API changes

Merge commit 'ebb555c0687061993dd6a22d15f6aab2437ee8c5' into gingerbread-plus-aosp

* commit 'ebb555c0687061993dd6a22d15f6aab2437ee8c5':
Support multi-valued HTTP headers, handle new API changes
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
7b96b251c0404ed3f05652bd7d5209910fb999cc 21-Sep-2010 Steve Howard <showard@google.com> am d3197296: Implement dialogs for wifi required + recommended limits.

Merge commit 'd319729622da1893e895f2e35f41d01ecdca3705' into gingerbread-plus-aosp

* commit 'd319729622da1893e895f2e35f41d01ecdca3705':
Implement dialogs for wifi required + recommended limits.
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
2031fa7bad5ef3e31cf0ea73d0b9bf4670842cf0 21-Sep-2010 Steve Howard <showard@google.com> am dc738781: Merge "Improve file error reporting + new detailed error messages in UI" into gingerbread

Merge commit 'dc738781156d0f5ac1db62838d42c876d740810d' into gingerbread-plus-aosp

* commit 'dc738781156d0f5ac1db62838d42c876d740810d':
Improve file error reporting + new detailed error messages in UI
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
176a74426f750dc56e7d200a4cdc3b6ed75fe6cd 16-Sep-2010 Steve Howard <showard@google.com> resolved conflicts for merge of 3d55d829 to gingerbread-plus-aosp

Change-Id: I18ede2f2d5ad8aa40cd61bdb7213659d356fdf57
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
9877c7f8414bfa1feb49b2afe166f99fff678794 21-Aug-2010 Steve Howard <showard@google.com> am 97d590d5: Add UI message when queued for wifi due to size.

Merge commit '97d590d5a1f583acb7992d20851bdc6cd0454d12' into gingerbread-plus-aosp

* commit '97d590d5a1f583acb7992d20851bdc6cd0454d12':
Add UI message when queued for wifi due to size.
97d590d5a1f583acb7992d20851bdc6cd0454d12 21-Aug-2010 Steve Howard <showard@google.com> Add UI message when queued for wifi due to size.

As it stands, when a download is paused because it's too big to
proceed over mobile, and must proceed over wifi, it looks like any
other paused download, with no indication of why it's paused. That
may be passable for most other reasons for pausing a download, but it
seems too confusing for this case. So this change adds a simple
string message that replaces the progress bar when a download is
paused for this reason (the icon also changes to a warning).

The implementation isn't beautiful and could use some improvement, but
I think it's acceptable and necessary. The exact UI design and
wording are certainly open to change.

Change-Id: I753d57f463e2614b5694bdc178d2a51066da8ca3
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
fa5175e572258fba0cd55e1c8a01b654178e3f1e 17-Aug-2010 Steve Howard <showard@google.com> am adb6887d: Clean up error codes returned by download manager.

Merge commit 'adb6887d3270d180c94eaf90878d5b67d74a8f28' into gingerbread-plus-aosp

* commit 'adb6887d3270d180c94eaf90878d5b67d74a8f28':
Clean up error codes returned by download manager.
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
92ae639f324084a23a54812ab92304b009a93340 30-Jul-2010 Steve Howard <showard@google.com> am dea0a5f8: Add test for many interruptions to a single download.

Merge commit 'dea0a5f8e5804d3aba40eaa7de763dd88058384e' into gingerbread-plus-aosp

* commit 'dea0a5f8e5804d3aba40eaa7de763dd88058384e':
Add test for many interruptions to a single download.
915912de0373b78de4cd7cc1f45dad760ef94243 30-Jul-2010 Steve Howard <showard@google.com> resolved conflicts for merge of f85aa9ef to gingerbread-plus-aosp

Change-Id: I0adb03f16a6f0cc648886e02c79ffde63e18f99f
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.
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
7a8bf08fe936a1fdb0408dea1ec2f39b83acc5d7 28-Jul-2010 Steve Howard <showard@google.com> am f6b4c24b: Fix bug with closing output stream for external downloads.

Merge commit 'f6b4c24b4a876daa3f4e91d6da418983222b9dfd' into gingerbread-plus-aosp

* commit 'f6b4c24b4a876daa3f4e91d6da418983222b9dfd':
Fix bug with closing output stream for external downloads.
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
918f819abfb1da3661c1c604440666655e0c8909 21-Jul-2010 Steve Howard <showard@google.com> resolved conflicts for merge of b5629da7 to gingerbread-plus-aosp

Change-Id: Icddfa080f43f882cce60af8a729436dcc2406384
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
7d4a4bc1f4bf92906598ede0160ff234d1179dd4 19-Jul-2010 Steve Howard <showard@google.com> am 071bd7ac: Support for max download size that may go over mobile

Merge commit '071bd7acb3185f4f1e807855605c5e6018e9742f' into gingerbread-plus-aosp

* commit '071bd7acb3185f4f1e807855605c5e6018e9742f':
Support for max download size that may go over mobile
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
c45c8eb1f9e8d93a02a7af2621a8fbcea1b2f6a7 19-Jul-2010 Steve Howard <showard@google.com> am 1aa26989: Merge "Introduce a seam to ConnectivityManager and TelephonyManager" into gingerbread

Merge commit '1aa26989047495ff58d3e2598d3f9549465cbb65' into gingerbread-plus-aosp

* commit '1aa26989047495ff58d3e2598d3f9549465cbb65':
Introduce a seam to ConnectivityManager and TelephonyManager
8e64adfed603d808a712f0caad97425a5ef038f4 19-Jul-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: I706a8164dbb3f499736e6dcef0e8b65f3c309c44
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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.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
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
31073f8e470e9fe2782ecf95890c0a4acc91b8be 16-Jun-2010 Andreas Sandblad <andreas.sandblad@sonyericsson.com> Use proxy for downloads.

Uses the new Proxy method getPreferredHttpHost to easily get correct
proxy.

Change-Id: If859ad03c2ed5a896c62592aa131d0e79d1b9c02
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
055286d603745cb3281ddb04b0aa41a660624e65 10-May-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: If84d4054324db6d10fd0cdbd2169c039c6675726
72f14a6f122f020e560e6572b2581c43b3ea90e3 28-Mar-2010 usul <usultis@gmail.com> code left opened files behind
verified with lsof DownloadProvider after downloading a file shows:
${proc} 338 10034 33w REG 179,0 167634 5 /sdcard/download/fw4-1.pdf

Change-Id: I8e2412fe9a6348f5ece6f5ca3a9ebf99a4474bce
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
e7a7c7abf4ba5a2a5867205d75ad441e3996ee7d 25-Feb-2010 Dianne Hackborn <hackbod@google.com> Update to reflect android-common no longer in framework.
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
c4ded39114db06c09c3ba0cf4700fce560272aca 10-Feb-2010 Dan Egnor <egnor@google.com> Supply a Context to AndroidHttpClient.newInstance(), to enable
persistent SSL session caching.
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
7dd92fa94df0a13b4592ee636b7aa2b605f6b473 08-Jan-2010 Jean-Baptiste Queru <jbq@google.com> Use the private legacy API

The public API is getting deeply reworked for forward compatibility,
but since the Download Manager and the Browser need to continue using
the old API, a separate copy is being kept on the side.

Bug: 2245521

Change-Id: I85eff6ba9efc68600aa80e8dffa6720b0f2ed155
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
dc0accaaa66cdd7321505a8c42504b05a98ae341 14-Dec-2009 Paul Westbrook <pwestbro@google.com> Changed class paths for classes moved in unbundling effort
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
2061c03400a8e23cfeee5394b7e71db2440a48ed 24-Sep-2009 Jean-Baptiste Queru <jbq@google.com> Remove unnecessary logging

Also tweak some slightly inaccurate logging, and add a note
about a potential bug.

BUG=2055624
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
e2607d88081f02a418ff5d5067f5327d513e00a1 23-Sep-2009 Jean-Baptiste Queru <jbq@google.com> Add a bit more logging to track down network state issues.

BUG=2055624
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
a581a4af046fd82b5854d213519e3f418047c0ba 21-Sep-2009 Jean-Baptiste Queru <jbq@google.com> Add logging to track connectivity as seen from the Download Manager.

This is enabled by a separate build-time constant, so that it can
be turned on for everyone without having to use a system property.

BUG=2055624
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
e0114021be2a1ca49a8cba85bb88129d3a19d173 27-Mar-2009 The Android Open Source Project <initial-contribution@android.com> Merge commit 'korg/cupcake'

Conflicts:
src/com/android/providers/downloads/DownloadThread.java
9ae5f517f7699439b673330867b26ffc5ad880cc 20-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake_rel/...@141571
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
63ef384e15c40fdd4646157cb40b71e87b2062a6 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake_rel/...@140373
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
2dd83ce992eaaf3d44c32bc7468b47e3db014027 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
1edb39f280d23b3a87db45b63c2f26850d68eafe 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
6a338eb9f99486c6418596992a0de592e2e8d752 29-Dec-2008 Dennis Hsieh <yundom@gmail.com> Force sync the downloaded file to the storage after completion.

This will write the downlaoded file to the storage (sdcard in default).
It can prevent file corruption if the user removes the sdcard unsafely
after a download completes.
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
59910f4a9ce953ea74c8db759448f227c96796b3 20-Jan-2009 Jean-Baptiste Queru <jbq@google.com> Use the new download manager APIs introduced in change 7400
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
c6f5aad265cfc36a64cd2bdb5adf3cc9736bbd80 20-Jan-2009 Jean-Baptiste Queru <jbq@google.com> Match the official code style guide.

This fixes a number of style violations that weren't caught by automated
tools and brings those files closer to compliance with the official style
guide for this language.
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
1fbad9cfa532f13f6cf03f542febf2e4689edec5 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java
57f55b3cb4f7e4136cde8d1ea12c1e70ec903362 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/packages/providers/DownloadProvider/src/com/android/providers/downloads/DownloadThread.java