• Home
  • History
  • Annotate
  • only in /packages/providers/DownloadProvider/src/
History log of /packages/providers/DownloadProvider/src/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e24609e8f2aada5cb8ac1c3e93141b260e201efe 16-Oct-2014 Jeff Sharkey <jsharkey@android.com> Trim stale downloads from third-party apps.

Buggy third-party apps can enqueue lots of downloads and then
forget to remove them, causing DownloadManager to stop functioning.

This change removes any downloads that match _all_ of the following
conditions:

1. Download status is in a terminal (non-pending) state, usually a
concrete success or failure.
2. Download hasn't been touched in over a week.
3. Download is not visible in UI.

Bug: 17785419
Change-Id: Id82752fd6935371c1af682205d35f7ba35169473
om/android/providers/downloads/DownloadIdleService.java
52d35ed20edec2b5086459f1d5d64309c421f3b2 27-Aug-2014 Selim Cinek <cinek@google.com> Colored notifications

Bug: 17128331
Change-Id: Ie2529189e4d62c7dc385f9d36c70ac412fb4159c
om/android/providers/downloads/DownloadNotifier.java
629eed8893ba5ef978a9f777047d560e95e43456 26-Aug-2014 Jeff Sharkey <jsharkey@android.com> fallocate() returning ENOSYS is okay.

Fall back just like ENOTSUP.

Bug: 17285472
Change-Id: Ice4954726c14a0e84c39c5469d573644588934ae
om/android/providers/downloads/DownloadThread.java
2e16979a9133ef83f6e513eaa4b84de40350a2dd 06-Aug-2014 Jeff Sharkey <jsharkey@android.com> Whoops, clear identity to get internal columns.

Bug: 16822344
Change-Id: Ib90e171cbb7babc7a3eea59de5cb899c79fadf94
om/android/providers/downloads/DownloadProvider.java
495edec1d9f7659923c71b009db66c1bd4782034 05-Aug-2014 Jeff Sharkey <jsharkey@android.com> Scan after writing download files.

Kicks off media scanner after files are written, usually through a
DocumentsProvider.

Bug: 13557203
Change-Id: I4e29b778b4e19a217f60c1e415c4d814724752d3
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadStorageProvider.java
be3aa64469e8d1806250318808f79f41fb4c7cbd 17-Jun-2014 Christopher Tate <ctate@google.com> Transition the Download Service's cleanup work to a scheduled Job

...preparatory to finally removing the scratchpad "idle maintenance"
infrastructure from the product.

Bug 14993295

Change-Id: I1e84247de19e616910db1781b2c399a8b15a805c
om/android/providers/downloads/DownloadIdleService.java
om/android/providers/downloads/DownloadService.java
d308640acf7179eb4b16f7067edc64da55a12521 10-May-2014 Jeff Sharkey <jsharkey@android.com> am f04a7690: am 90e7485d: am 02562d30: Merge "Avoid leaking cursors"

* commit 'f04a7690b53288c98c07e0aa05214cceebea1331':
Avoid leaking cursors
02562d300310909e30782b907a8c0cbdf76f14af 10-May-2014 Jeff Sharkey <jsharkey@android.com> Merge "Avoid leaking cursors"
6ea35f0acc28b9ede6b49fcbd456d6eacfe3f55b 29-Apr-2014 Elliott Hughes <enh@google.com> OsConstants is moving.

Change-Id: Ie72e18f539cbad593c489bf52b9afea5330f62c1
om/android/providers/downloads/DownloadThread.java
ad93688d65c6f5898a8b2e8b324d9e8adf39dd65 29-Apr-2014 Torne (Richard Coles) <torne@google.com> Fix reference to moved ErrnoException.

ErrnoException has moved to android.system; fix reference in
DownloadIdleService.

Change-Id: I8a08d3f8074d0ec5a4e8314db173139a109abb33
om/android/providers/downloads/DownloadIdleService.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
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageUtils.java
792abb95c0dd02ebbb90f9d362637ae610ccea93 28-Apr-2014 Elliott Hughes <enh@google.com> Track API package change.

Change-Id: Ie2f35386e48894a9c9afb9717af90a5628dcd79b
om/android/providers/downloads/StorageManager.java
a2aad3aa41402afe88a2bf7b820f3459f795d079 27-Mar-2014 Mattias Nilsson <mattias.nilsson@sonymobile.com> Avoid leaking cursors

Adding try/finally blocks to make sure that cursor
resources are let go

Change-Id: I596074aa9ab5752f91a26b5a03e1f39c23c64a5f
om/android/providers/downloads/DownloadProvider.java
b9e36b4f5390c9100d567cbe6e61a3304e37e680 15-Mar-2014 Nick Kralevich <nnk@google.com> resolved conflicts for merge of 2ca55fd3 to master

Change-Id: I59df74b902c95299ae9adda2ddddb6bad4260159
470a6a6806ebacee69f8e820cdb2ee307d58f11a 12-Mar-2014 Stephen Smalley <sds@tycho.nsa.gov> Drop restorecon call from DownloadProvider.

It is not necessary/useful to place this directory into a separate
type from other app data files, so remove this restorecon.

Change-Id: Iabd643a515c134ab2a62e82866a3f72530f795ba
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/DownloadIdleService.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageUtils.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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/StopRequestException.java
om/android/providers/downloads/StorageManager.java
om/android/providers/downloads/StorageUtils.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.
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadScanner.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadScanner.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.java
12f656962b644268a02cecd370b1ea35fa22cf4e 03-Jan-2014 Roger Chen <cxr514033970@gmail.com> Creates parent directories before creates file

Change-Id: I124f7ce2b731b100e9572d7c5d95206e243ee316
Signed-off-by: Roger Chen <cxr514033970@gmail.com>
om/android/providers/downloads/Helpers.java
c9b683f739017c2f5e86661753f0ab1c44f359fa 10-Oct-2013 Jeff Sharkey <jsharkey@android.com> No directories in Downloads.

Bug: 11166290
Change-Id: I29c9cf53c77d03d1bcf408edd693b9c24d5665b6
om/android/providers/downloads/DownloadStorageProvider.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
om/android/providers/downloads/DownloadThread.java
1225c34df262ece7a9f95ee5fe61c1985bf16df1 05-Oct-2013 Jeff Sharkey <jsharkey@android.com> Always update notifications, media scanner.

insert() was trying to be too clever, and it would end up delaying
the media scanner until the next download happened. This resulted
in duplicate photos in DocumentsUI.

Bug: 11081685
Change-Id: Ic9549ede38118372849119dd3a21415a4723e9f5
om/android/providers/downloads/DownloadProvider.java
dfb6502136dc6683166f2104d93c22e1b72e1818 04-Oct-2013 Jeff Sharkey <jsharkey@android.com> Ensure Downloads directory exists before create.

Bug: 11080980
Change-Id: Iffa5402ae632ceda06e0aec6bdc73c0c4fcbeaa1
om/android/providers/downloads/DownloadStorageProvider.java
04c1c2afb7481e7fb9b66f96023c79d19cad8c90 01-Oct-2013 Jeff Sharkey <jsharkey@android.com> Allow all downloads to be writable.

Bug: 10943812
Change-Id: Ib0cb3e608c1f40a2e2fcd6e493c8f920d8b4221b
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadStorageProvider.java
om/android/providers/downloads/OpenHelper.java
3d1eb366ef744a8790d89535a585bb50bcc7c113 28-Sep-2013 Jeff Sharkey <jsharkey@android.com> Follow API changes.

Bug: 10964412
Change-Id: Ia452bd056b6e01aace33acc5f1aa741af4d77c5f
om/android/providers/downloads/DownloadStorageProvider.java
afaf53bd2b1322167b6f31eda941e38335c4a952 26-Sep-2013 Jeff Sharkey <jsharkey@android.com> Revoke grants when downloads are deleted.

When deleting downloads, revoke any Uri permission grants, which
removes from getPersistedUriPermissions().

Bug: 10928851
Change-Id: I3e90c4071385832dcb3e0cf9ca3fdccafbe30037
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadStorageProvider.java
776e4f7991c4f5637f9a945ed9190a26ff295446 25-Sep-2013 Jeff Sharkey <jsharkey@android.com> Always check against canonical paths.

Bug: 10920351
Change-Id: I8c7e5344d9fd9d15565eaf93b91ce457a98ab98c
om/android/providers/downloads/Helpers.java
c067c8be21dc4a6dc5f49b2b1aed7f91aab47063 23-Sep-2013 Jeff Sharkey <jsharkey@android.com> Allow saving to Downloads.

Add column to mark downloads as being writable, and allow documents
to be created under Downloads backend. Update database when writing
is finished, and generate unique filenames when they already exist.

Check canonical path on incoming _DATA paths.

Bug: 10667164, 10892621, 10893268
Change-Id: I8c203b96ff042a895b58686903fcd07fc755a00f
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadStorageProvider.java
om/android/providers/downloads/Helpers.java
8ec87ea5a5c191554d6205d4c779768664b1724b 18-Sep-2013 Jeff Sharkey <jsharkey@android.com> Unified handling of errors around opening.

Handle both missing downloads and missing activities.

Bug: 10799449, 10713636
Change-Id: I592b07fc5cf530526803379d7f7a99e8a6b207c4
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/OpenHelper.java
1aad6c663ee188b02449e5e4d3e40e5c09c8fc14 11-Sep-2013 Jeff Sharkey <jsharkey@android.com> Omit duplicate images, query for management UI.

When returning recent files, omit images that have been scanned and
provided by the Images backend.

Return in-progress files when queried for management UI, otherwise
only return complete files.

Bug: 10659651
Change-Id: I8f05e6fcf53422905d7f51cc55611ca00af301bf
om/android/providers/downloads/DownloadStorageProvider.java
66bdbe486e572aee1b06e3dbea9daf87ceb0e1bb 09-Sep-2013 Jeff Sharkey <jsharkey@android.com> Hint sorting, remove XML, follow refactor.

Bug: 10672973, 10577809
Change-Id: I92314c35b37ac590830e881489e6a88afd860de4
om/android/providers/downloads/DownloadStorageProvider.java
3c03d1b8b7d96209d7b83b6881421ddfc17ccc52 06-Sep-2013 Jeff Sharkey <jsharkey@android.com> Extend trampoline to show dialogs.

Handle incoming manage requests by launching finished downloads,
or showing various retry dialogs. Pipe through summary, show
percentage when in progress, and always show total size and MIME type.

Bug: 10531347, 10599641
Change-Id: I3be2bc67ea3c0ef795146177200f5be77ad5114e
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadStorageProvider.java
om/android/providers/downloads/TrampolineActivity.java
e4b402b205fd958f28ffcf32262f485d2a78e3d0 05-Sep-2013 Jeff Sharkey <jsharkey@android.com> Relay content change notifications to documents.

Bug: 10531347
Change-Id: Ia704b233623e913da3a5cb7c8aa5e024900e1d3a
om/android/providers/downloads/DownloadStorageProvider.java
d311f51e57dbd9c9c98d5f363f6db4ccae3a37f4 03-Sep-2013 Jeff Sharkey <jsharkey@android.com> Remove content flags to indicate */* support.

Bug: 10597317
Change-Id: Ia32f4ec34847680135c300dfe8fe73694da4c57a
om/android/providers/downloads/DownloadStorageProvider.java
db9020e34a49a3eedc42d67ada0ae98ee29e813f 03-Sep-2013 Jeff Sharkey <jsharkey@android.com> New recent documents behavior.

Bug: 10593596
Change-Id: I708d2396266d083a494e57eab2637471e54e1cdc
om/android/providers/downloads/DownloadStorageProvider.java
a80bb06d5563377253906adebdc3ff9ef64d6500 01-Sep-2013 Jeff Sharkey <jsharkey@android.com> Follow refactoring of DocumentsContract.

Bug: 10567557
Change-Id: If03f352f865073b0e332a6a1c40cc34d83425b62
om/android/providers/downloads/DownloadStorageProvider.java
ec62bdf20cbfa709c9dea9101fe668fec315c103 29-Aug-2013 Jeff Sharkey <jsharkey@android.com> Follow stronger DocumentsProvider contract.

Provides same functionality, but follows updated DocumentsProvider
contract in framework.

Bug: 10497206
Change-Id: Ie1f6180047ff7bad289679a14f3368238d47b1d6
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadStorageProvider.java
om/android/providers/downloads/TrampolineActivity.java
90aacc868d1a20e477f934a5bfdb10bb29846d93 19-Aug-2013 Jeff Sharkey <jsharkey@android.com> Trampoline APK installation to use raw file.

PackageInstaller requires raw file:// Uris, and refuses to accept
content:// Uris, so create a trampoline that uses the raw file and
also splices in referrer extras.

Bug: 10391254
Change-Id: I12a06862069479de5dee140d0065479ce79eb494
om/android/providers/downloads/DownloadStorageProvider.java
om/android/providers/downloads/TrampolineActivity.java
ed08089f6dccae69eabfaa3383c5007f0dddc6a5 19-Aug-2013 Jeff Sharkey <jsharkey@android.com> Clear identity when deleting downloads.

Bug: 10329983
Change-Id: Iff3db6e5210ae9f33ec13af91561475b269dcc40
om/android/providers/downloads/DownloadStorageProvider.java
af760c0b5d892441540bc462fd6ee1ae98fee636 18-Aug-2013 Jeff Sharkey <jsharkey@android.com> Support custom documents query projections.

Uses new MatrixCursor.RowBuilder.offer() to support custom
projections. Also query MIME types directly so they're always
consistent.

Bug: 10329983
Change-Id: I724b26e008f6ffb85940e009a916b969ead42fcd
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadStorageProvider.java
8c9cef79df1ddcd971a0a0775cef774c17a5081c 16-Aug-2013 Jeff Sharkey <jsharkey@android.com> Delegate to documents UI; improve contents.

When Downloads app is launched, delegate to new documents management
UI. Use DownloadManager public API to match the contents of the
existing Downloads UI.

Bug: 10329983
Change-Id: Iaa1a1dc013cfe3b17d31ecc764d4c4cc13f62258
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadStorageProvider.java
6a09c3294997dc9e3c83b8431f7b496b19670014 08-Aug-2013 Jeff Sharkey <jsharkey@android.com> First pass at Downloads storage provider.

Offers a view of Downloads through the lens of DocumentsContract
for surfacing in new storage UI.

Change-Id: I4373c2498b4b82bfee2300a00f8d0bb734bf574c
om/android/providers/downloads/DownloadStorageProvider.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
om/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
om/android/providers/downloads/DownloadThread.java
64a9e6cb3628db724e04492cf207757348960eb7 29-Apr-2013 Jeff Sharkey <jsharkey@android.com> Completed downloads should clear when touched.

Bug: 8744610
Change-Id: I135a3acbc819fd725f00ba57461e21db1fe24850
om/android/providers/downloads/DownloadNotifier.java
62608885d3d8a7b88776084040f666bd1304b811 06-Apr-2013 Geremy Condra <gcondra@google.com> Merge "Restore the appropriate SELinux context to the downloads dir." into jb-mr2-dev
af49093b1554fdc55977e9281505e05865f33813 03-Apr-2013 Danny Baumann <dannybaumann@web.de> Fix download notification click behaviour.

PendingIntent.getBroadcast() doesn't update the intent extras if not
explicitly given something to distinguish the intents. This caused the
notification on-click to do nothing on everything but the first
download.

Change-Id: I29544ae5b04f8304cbbe720066a26ff90e422107
om/android/providers/downloads/DownloadNotifier.java
498f62e2da65df9e11e8da6feb959ed0d513f792 04-Apr-2013 Geremy Condra <gcondra@google.com> Restore the appropriate SELinux context to the downloads dir.

Change-Id: I4839fd07abdd1c6b866f1d94dc36567df047e30c
om/android/providers/downloads/DownloadProvider.java
5048492e352be8134d92178d757a60117491e292 26-Mar-2013 Jeff Sharkey <jsharkey@android.com> New PendingIntents when extras change.

Otherwise notifications end up launching with stale download IDs.

Bug: 8417220
Change-Id: Ie72a2f4ac7b72213678ac6001af45709034492dd
om/android/providers/downloads/DownloadNotifier.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
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.java
0f2f63932bd8d963764d37527b3237d219fdaa4d 26-Mar-2013 Fabrice Di Meglio <fdimeglio@google.com> Revert "Avoid sending messages after HandlerThread.quit()."

This reverts commit 97d507d95f9885ceb12f2ce2483361b5ed265f9f

Change-Id: I20374301561b3a1c79c2d986292af50049de2aac
om/android/providers/downloads/DownloadService.java
97d507d95f9885ceb12f2ce2483361b5ed265f9f 26-Mar-2013 Jeff Sharkey <jsharkey@android.com> Avoid sending messages after HandlerThread.quit().

Bug: 8470658
Change-Id: I4cfd6a01c2c2d845a72d3f58c29eec8b44176537
om/android/providers/downloads/DownloadService.java
703bc3a83056a878a83e263b992fb5331b84535f 25-Mar-2013 Jeff Sharkey <jsharkey@android.com> Reduce logging, dump stacks before wtf().

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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotifier.java
om/android/providers/downloads/DownloadService.java
11787c02ad60f681af2cf4ef5d0fbf89efdbc4c2 21-Mar-2013 Jeff Sharkey <jsharkey@android.com> Merge "Increase timeout for domains with many DNS entries." into jb-mr2-dev
a9917b41429e3e18074d8a8a709894e488883686 21-Mar-2013 Jeff Sharkey <jsharkey@android.com> Increase timeout for domains with many DNS entries.

Bug: 8233041
Change-Id: Ifb70273474c391ef687ba018d9ef809a359c7149
om/android/providers/downloads/DownloadService.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
om/android/providers/downloads/DownloadThread.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
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
dd1179c09fb6ac2420292e52ea3ced395f76a7be 21-Feb-2013 Jeff Sharkey <jsharkey@android.com> Ack, we actually need to UpdateThread.quit().

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
om/android/providers/downloads/DownloadService.java
71a53040699e713bcae839a01b7f8abd9e13bab6 21-Feb-2013 Jeff Sharkey <jsharkey@android.com> Only use single UpdateThread.

Since DownloadService starts and stops frequently, recycle a single
UpdateThread across invocations.

Bug: 8233041
Change-Id: I07756fb6bfdbad811cbd58e628fdfdbf63d71bf8
om/android/providers/downloads/DownloadService.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
om/android/providers/downloads/DownloadService.java
om/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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.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
om/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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadScanner.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
1ad10ce731d1b54692d7d5ee32601e965f503fa4 08-Feb-2013 Jeff Sharkey <jsharkey@android.com> Active notifications only for running downloads.

Bug: 8145142
Change-Id: I9119796f809aa967f7ec6bb2a3d2b815e86eaf1b
om/android/providers/downloads/DownloadNotifier.java
1d0a0aa2cc5bfed8107aa70f7e890fde9a7ea2b4 30-Jan-2013 Jeff Sharkey <jsharkey@android.com> Dump recent downloads from provider.

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
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/DownloadHandler.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotifier.java
om/android/providers/downloads/DownloadService.java
om/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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/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
om/android/providers/downloads/DownloadInfo.java
om/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
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StopRequestException.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/StopRequestException.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
om/android/providers/downloads/DownloadHandler.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
701d66efeff513a7509eeaafab6e47f4f6edb857 05-Jan-2013 Jeff Sharkey <jsharkey@android.com> Remove singleton StorageManager.

Now DownloadService creates and owns the lifecycle of its own
StorageManager instance.

Change-Id: I8f6bedc02f1dbe610a8e6a25d55383a12716d344
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/StorageManager.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
om/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
om/android/providers/downloads/DownloadThread.java
3b3bbfe2cdd1988a38bcf780191e5273f9a62024 14-Dec-2012 Jeff Sharkey <jsharkey@android.com> Merge "Cleaner I/O."
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
om/android/providers/downloads/DownloadDrmHelper.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/DrmConvertSession.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/OpenHelper.java
226c76b54ed0c1ad1b8a858abbe94551e47476c3 13-Dec-2012 Jeff Sharkey <jsharkey@android.com> am 195b46b8: am b0bb182a: Cancel stale notifications when starting.

* commit '195b46b8a59eb522fc91ac6f498f359a337d3f3e':
Cancel stale notifications when starting.
b0bb182a1b52b31ccf1ec5e0be82308ebb4857e2 13-Dec-2012 Jeff Sharkey <jsharkey@android.com> Cancel stale notifications when starting.

Bug: 7693834
Change-Id: I5e212be321cccae0f7c76f80049c4e09f0867694
om/android/providers/downloads/DownloadNotifier.java
om/android/providers/downloads/DownloadService.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
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/DownloadHandler.java
om/android/providers/downloads/DownloadNotifier.java
om/android/providers/downloads/DownloadThread.java
f818eecf1b60ddba2854314863243d6aa87707b0 27-Nov-2012 Jeff Sharkey <jsharkey@android.com> Update extras for in-progress download.

Follow move to EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS extras, which
was missing during refactoring.

Bug: 7617373
Change-Id: I26203a2bc6fc0e211a1aa602c0de018332d76f60
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadReceiver.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
om/android/providers/downloads/DownloadHandler.java
om/android/providers/downloads/DownloadNotifier.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.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
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadNotifier.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
169ab531ca6bb2f43ed18fe2b03f66c808f12b81 19-Oct-2012 Jeff Sharkey <jsharkey@android.com> Bring back DRM mimetypes.

I don't like DRM, but other people do.

Bug: 7370549
Change-Id: I44220404eab6e6cc85ea16cfcf58474135c03f83
om/android/providers/downloads/OpenHelper.java
70b5c30db87b3405e2e001c06c4a4a5dd6e25b72 06-Oct-2012 Jeff Sharkey <jsharkey@android.com> Skip scanning a file which will be deleted.

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
om/android/providers/downloads/DownloadService.java
b92aa3a88dd25a798bbedc860d9b29aef42bbb0f 03-Oct-2012 Jeff Sharkey <jsharkey@android.com> Handle not fully connected networks.

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
om/android/providers/downloads/DownloadInfo.java
f161f8b6ab4ddf3dbedd1731771b1eacc628c48c 28-Sep-2012 Ruben Brunk <rubenbrunk@google.com> Merge "Remove FLAG_ACTIVITY_NEW_TASK from the VIEW intent." into jb-mr1-dev
46bb7dd18c9b092d352d76ab44a4e52951941b2c 27-Sep-2012 Ben Gruver <bgruv@google.com> Send uid of the application that initiated the download

Bug: 6923241
Change-Id: Idf4037b4e360cb6453b315d1cc95608762c9e0c8
om/android/providers/downloads/OpenHelper.java
a2304fb28026f3da1bb91931c4cdd52110c82577 24-Sep-2012 Ruben Brunk <rubenbrunk@google.com> Remove FLAG_ACTIVITY_NEW_TASK from the VIEW intent.

Bug: 7164238
Bug: 7237908

Got rid of FLAG_ACTIVITY_NEW_TASK for proper back behavior

Change-Id: I50af9aeafb27d6079bda4f81f4a116b6bb600676
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/OpenHelper.java
c0622bf896c1af62b0e69b18cd84c7de3b67beb3 28-Aug-2012 Jeff Sharkey <jsharkey@android.com> Send ORIGINATING_URI and REFERRER to installer.

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
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/OpenHelper.java
5cae217e7c6c8b043eada8041b224e713104f141 08-Aug-2012 Jean-Baptiste Queru <jbq@google.com> am d7dd6019: Merge "Adds missing Bluetooth as network type."

* commit 'd7dd6019baf12961dce722d33003e238cdd72f6a':
Adds missing Bluetooth as network type.
36612d27b67ff2e79ffff8eb12d95d2058abde02 25-Jul-2012 Jeff Sharkey <jsharkey@android.com> Move notification tests to LittleMock.

Directly mock NotificationManager instead of using SystemFacade.

Change-Id: If932d26e23816e8674469c275a828701cce5fc2d
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
ebcc93801eb9545004536587d10f82db378aeab5 21-Jul-2012 Jeff Sharkey <jsharkey@android.com> Reduce deletion logging.

Bug: 6544953
Change-Id: I4157c67b9b9cddab4ade795c328a202f6a230f95
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.java
61dc320aa883a2fcf68d44ef0bbe4cd7c51a7655 08-Feb-2012 HÃ¥kan3 Johansson <hakan3.johansson@sonyericsson.com> Adds missing Bluetooth as network type.

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
om/android/providers/downloads/DownloadInfo.java
c5b582cebe167264106df5fa7b2ae7312cd456ce 07-Jun-2012 Jeff Sharkey <jsharkey@android.com> am f918429d: Uniform "when" to avoid flashing notifications.

* commit 'f918429d0c1927a19d688baa26a07c2c65765580':
Uniform "when" to avoid flashing notifications.
f918429d0c1927a19d688baa26a07c2c65765580 07-Jun-2012 Jeff Sharkey <jsharkey@android.com> Uniform "when" to avoid flashing notifications.

When showing a download, remember the first timestamp when we showed
a notification, and use that time as "when" for all future updates
to avoid flashing.

Also bring back icon animation that had regressed.

Bug: 6596416, 6237256
Change-Id: Ifdc5dc6870dac047515151c1b088e6e379b6a063
om/android/providers/downloads/DownloadNotification.java
c1df0651e86ab6d0918cfac86ff54d3fb3781a69 21-May-2012 Jean-Baptiste Queru <jbq@google.com> am 0acd13fe: Merge "avoid repetition of retrying download"

* commit '0acd13fed2f4d0857ce89565fe94674c09b1e844':
avoid repetition of retrying download
0acd13fed2f4d0857ce89565fe94674c09b1e844 21-May-2012 Jean-Baptiste Queru <jbq@google.com> Merge "avoid repetition of retrying download"
15ea8d69f74735e2013cc11bc4899e0edc945b8a 25-Apr-2012 Jeff Sharkey <jsharkey@android.com> Only delete spurious files belonging to us.

When multiple users are active, this can accidentally delete files
belonging to other users. Checking owner also helps us avoid
deleting recover and lost+found.

Bug: 6362988
Change-Id: Ifc165acc9a9b3ab253a4b6257f370836b98b3a74
om/android/providers/downloads/Constants.java
om/android/providers/downloads/StorageManager.java
2f5fe598e53fc7bb3e8d6e1848ab62953866fb11 20-Apr-2012 Jeff Sharkey <jsharkey@android.com> Avoid NPE when _DATA column is empty.

Bug: 6371718
Change-Id: Id661210101b01daf8f5d46a318c32dbb9de9a4fb
om/android/providers/downloads/StorageManager.java
f8b1f373fd884fffe384acf564d0a4e374de8e02 20-Apr-2012 Jeff Sharkey <jsharkey@android.com> More slogging around download deletion.

Bug: 6362988
Change-Id: Iab4b86cfcaa6aeed6466f88ff49eb935f96db495
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.java
c3f3d992e415185a8e2d89ab8f8dfbcb538ec21e 19-Apr-2012 Jeff Sharkey <jsharkey@android.com> Report MIME type for individual downloads.

Bug: 6358473
Change-Id: Ied4a6c8194d0cbb735e43cf7d7759f4674efe535
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
9b606340a0b5b88436505651dbe3cdaf60117604 16-Apr-2012 Jeff Sharkey <jsharkey@android.com> View file downloads through DownloadsProvider.

When viewing file://-style downloads, open through DownloadsProvider
so that FLAG_GRANT_READ_URI_PERMISSION works. Add support for
OpenableColumns to support external apps probing for metadata.

Bug: 6343461
Change-Id: I630405406321ea1871c62cbcded55a4ee024ef6e
om/android/providers/downloads/DownloadProvider.java
6da2d0a2e1d046cd39270a46c3c77f8234f4cfaa 13-Apr-2012 Jeff Sharkey <jsharkey@android.com> Locking around downloads, and more dump info.

Bug: 4997552
Change-Id: I3c612acb5145a7638c9345a376a99958851a0891
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadService.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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadThread.java
d078f62f67821576199aefc02a77fdc0d5b5b3ff 06-Apr-2012 Jeff Sharkey <jsharkey@android.com> Move to new NetworkPolicyManager accessor.

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

Bug: 4726601
Change-Id: Ibe537bd5c2a092dbf974360cd454751881f7f4ea
om/android/providers/downloads/DownloadThread.java
579be0d0d0de6af307ee94af07720a568ed2e7d1 14-Feb-2012 Hideki Hayami <hayami.hideki@sharp.co.jp> avoid repetition of retrying download

If isReadyToStart returns 'true' for STATUS_INSUFFICIENT_SPACE_ERROR,
DownloadProvider retries downloading after it gets requests from
browser to download contents. The retrying loop won't stop until
its completion (recovering from space error), or user stops
downloading. This retry loop impacts to network traffic, battery
consumption and packet charge. So, change this method to return
'false' for the error in order to stop the loop.

Change-Id: Ia3466db60d86c5900842c7c28d294898ae3ff2bc
om/android/providers/downloads/DownloadInfo.java
50c85944bf5e949ad5116fec9564318b3be90f24 08-Feb-2012 Jeff Sharkey <jsharkey@android.com> Match INetworkPolicyListener changes.

Change-Id: I78b6b0380a42b28f42334f93e0538ba7f32bc66d
om/android/providers/downloads/DownloadThread.java
515cf53eb94b8873aa6a1edcd6a962f0b0ca2170 30-Jan-2012 Jeff Sharkey <jsharkey@android.com> Move away from deprecated NetworkInfo extra.

Because the NetworkInfo included in CONNECTIVITY_ACTION broadcast
extra does not reflect the state applicable to the calling UID, and
the last sticky broadcast may have stale state, transition to calling
ConnectivityManager.getActiveNetworkInfo() directly.

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

Change-Id: Ideeb8cbeaa4b4d82d7c9fc8197a35bf3541a22d7
om/android/providers/downloads/DownloadThread.java
23bb4b4fb4076d09959b35f3e1247941ef7066c2 06-Jan-2012 Jeff Sharkey <jsharkey@android.com> am 380044a2: am f720bc68: Allow downloads when no network restriction set.

* commit '380044a236ffba16a800cb683fa648860dcfd573':
Allow downloads when no network restriction set.
f720bc684b1a8332eb4d5f8d25c5feaf7eb54433 05-Jan-2012 Jeff Sharkey <jsharkey@android.com> Allow downloads when no network restriction set.

Fixes bug where DownloadManager would block downloads on WiMAX,
bluetooth, and ethernet networks, even when no network restrictions
had been set.

Bug: 5689335
Change-Id: I6d1bb78cbccb3c5eb1fce40a13b0689be0c3fa13
om/android/providers/downloads/DownloadInfo.java
bff4fe9b858d95e984298d4863a5199f1ee2c54e 11-Nov-2011 Jeff Sharkey <jsharkey@android.com> Use UID instead of PID.

Bug: 5606426
Change-Id: I9b9cee142c360da2a30a4bb8be8dcf40b8c7e43e
om/android/providers/downloads/DownloadProvider.java
36deb30d94eb7e76a8d5139a9ef73a023d00437c 25-Oct-2011 Ed Heyl <ed@google.com> Merge remote branch 'goog/ics-mr0' into ics-mr1
7a3050291cbf3e8f379548063409233e93926edf 25-Oct-2011 Jeff Sharkey <jsharkey@android.com> Merge "Sanity check only after updating from file size." into ics-mr0
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
om/android/providers/downloads/DownloadThread.java
3e149d56b94639aef98c11e0f857d5329c2acc18 19-Oct-2011 Doug Zongker <dougz@android.com> am 3074179d: Merge "add more logging when download manager deletes files" into ics-mr0

* commit '3074179d22e9d7e1f506b85dca866301a6206156':
add more logging when download manager deletes files
3074179d22e9d7e1f506b85dca866301a6206156 19-Oct-2011 Doug Zongker <dougz@android.com> Merge "add more logging when download manager deletes files" into ics-mr0
e8e10c1604f65dd6878f1336fafa7cfc71647aff 19-Oct-2011 Doug Zongker <dougz@android.com> add more logging when download manager deletes files

Change-Id: I4d402e28996887fc1dba89b2764575c91c2c523b
om/android/providers/downloads/StorageManager.java
2265a12d45bdb16f6d9905681e8ccb63bee63446 11-Oct-2011 Doug Zongker <dougz@android.com> log when DownloadManager deletes files

Change-Id: I39bcb3c7c4625659b0e8b0f3e2971beabb017b48
om/android/providers/downloads/DownloadService.java
5daf15ebb799fa78cfe134bbdb7d69e3cb7244d3 17-Oct-2011 Jeff Sharkey <jsharkey@android.com> am c5c30ba1: NPE check before finalizeDestinationFile().

* commit 'c5c30ba14d411b3e23c983912e7fea4f449c9f54':
NPE check before finalizeDestinationFile().
c5c30ba14d411b3e23c983912e7fea4f449c9f54 14-Oct-2011 Jeff Sharkey <jsharkey@android.com> NPE check before finalizeDestinationFile().

Bug: 5461417
Change-Id: I16f1e8594162b006b80bf7f2cdc6630d0dedfa38
om/android/providers/downloads/DownloadThread.java
35b3fef25fc2509bb59371f0a1d2d2332db62487 12-Oct-2011 Jeff Sharkey <jsharkey@android.com> Merge "Check canonical path when download requested."
d195a5c677e575ba7e96e9366d0823c3c822231d 12-Oct-2011 Jeff Sharkey <jsharkey@android.com> Check canonical path when download requested.

Bug: 5449870
Change-Id: I3219273be9b796b123545c811e5f39fa83b5768e
om/android/providers/downloads/DownloadProvider.java
f4411b0e2255b9abe56e227225398b2aec2a7427 11-Oct-2011 Doug Zongker <dougz@android.com> log when DownloadManager deletes files

Change-Id: Id4800401c16811df9c4ee78ee9636c77b4c95756
om/android/providers/downloads/DownloadService.java
c21507f025f7422429975442792a6c7e279378da 30-Aug-2011 Jeff Davidson <jpd@google.com> Don't change extensions for explicitly set download locations.

This regression from GB was introduced by 38f1711910715538d6b64e505fe8fb9a0cd40475,
which was intended to allow duplicate downloads of the same file, adding -<n> to
the end of file names. As a side effect, this also activated extension validation
logic, which adds/changes an extension to match the Mimetype.

This change keeps the unique filename logic but prevents extension changes when an
explicit filename is set. Thus, it is still possible for the actual download
location to differ from the requested one, but only if the file already exists.

Bug: 5196436
Change-Id: I198dc2a819c5d839a05b72c25e0830d889a9c5a3
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/DownloadThread.java
c18b41eef6da088ed968f2efeda55efcc62d80f5 05-Aug-2011 Jeff Sharkey <jsharkey@android.com> Move to Notification.Builder progress API.

Instead of using custom layout to surface progress information, use
new Builder API. Also use resources to build percent string.

Bug: 4022082
Change-Id: I556a666771e9103ce5d7ddb60faa879b8777b284
om/android/providers/downloads/DownloadNotification.java
715d0c9297bc3d290e983c3f365bf9226e0a7556 20-Jul-2011 Dongwon Kang <dwkang@google.com> Bugfix:5033349
- Checking download data dir instread of /cache.
- Trying to remove stale files regardless of the low space thereshold.
(Note: This bug happens when download dir size is 100mb and there is a
file > 100mb in /cache.)

Change-Id: Iacded74eaadb2aa7f0af8d1b7e0f922e81c7e07c
om/android/providers/downloads/StorageManager.java
12c7bd488afe3a611d665e364e361f04f4a8c8d8 09-Jul-2011 Jeff Brown <jeffbrown@google.com> Eliminate single-process mode.
Bug: 5010576

Change-Id: I2f9bcad41cf50ed0b17dd487d0389f7b38500fd7
om/android/providers/downloads/DownloadProvider.java
f21edd015711fc2bdb1c2ab5aed15f44bcc0cee7 25-Jun-2011 Jeff Sharkey <jsharkey@android.com> Migrate setThreadStatsTag() from String to int.

Bug: 4948913
Change-Id: I831b9149208f0cc007cf3ebede3ef433b2636600
om/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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.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
om/android/providers/downloads/DownloadThread.java
665f4105ea68a05d85dcd22cc9d823f45f7e6a37 12-Apr-2011 Jeff Sharkey <jsharkey@android.com> Output DownloadInfo state in Service.dump()

Bug: 3136228
Change-Id: I77c4f998c9718c7630800dec152779ff59186187
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadService.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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadDrmHelper.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/DrmConvertSession.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/StorageManager.java
51cc2143feeed748c62544c7f1a57415bd90c7af 13-Apr-2011 Jeff Sharkey <jsharkey@android.com> Allow VISIBLE_NOTIFY_COMPLETED on Request.

Updates list of allowed visibility values to enable Request builders
to use Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED.

Bug: 4283223
Change-Id: I8ebe4a13f95a58f25f6025946a6d4725261717f2
om/android/providers/downloads/DownloadProvider.java
d98856047ea256f3e8576405bd2ebae3a3da7c2a 08-Apr-2011 Joe Onorato <joeo@google.com> Remove the deprecated things from Config.java. These havent been working since before 1.0.

Change-Id: Iba18a18547a161c1aa432a434b6c8f64693fb194
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/Constants.java
om/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
om/android/providers/downloads/DownloadHandler.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
88c91dd256f9ba37bdb0dbb7c81928f22e25336c 09-Mar-2011 Vasu Nori <vnori@google.com> bug:4081088 NPE in DownloadProvider

Change-Id: I033ba6abeed55c5ac76142c7a2e4849b8e044680
om/android/providers/downloads/StorageManager.java
9b2576f9181fc177dbbc9033c435b1d4049fc2e0 07-Mar-2011 Vasu Nori <vnori@google.com> bug:3513950 fix the comments

Change-Id: I6192a829c7cac86c55a0f67364ebd722504d5dc7
om/android/providers/downloads/DownloadProvider.java
3ff0baf4ed8eaba1b21979335ff1b9d8b2fede70 02-Mar-2011 Vasu Nori <vnori@google.com> remove log spew from downloadmanager

Change-Id: Iad8cfe0da389a70ff679cf6d3378f50e945d03a6
om/android/providers/downloads/DownloadService.java
2c02577af19bf11714220d14cfc96d2c017ac1ab 11-Feb-2011 Vasu Nori <vnori@google.com> bug:3425749 if adding completed download to db, send completion notif

Change-Id: I9f9f6f2e0b2bd18f3767574fc51301b75bb1b76d
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.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
om/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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
7806290088fbd6f802288021ec551ddd9469892a 04-Feb-2011 Vasu Nori <vnori@google.com> am 6e9abd8e: am d119d3cb: Revert "bug:3414192 if otaupdate column is set, don\'t check mobile download limits"

* commit '6e9abd8e04c4aaafb8493a25efc34f4dd4fa6013':
Revert "bug:3414192 if otaupdate column is set, don't check mobile download limits"
580871b3950761a39a69e3cb4db9fbdfb96f3917 04-Feb-2011 Vasu Nori <vnori@google.com> am 49663f1f: am f20af912: Revert "Merge "bug:3341145 if ignore_size_limits flag set, validate caller\'s perms" into honeycomb"

* commit '49663f1ffe58a546fb0d2ab84898843ef5e89eb5':
Revert "Merge "bug:3341145 if ignore_size_limits flag set, validate caller's perms" into honeycomb"
27478475ac5fd6f1b141b18b8b49f41beb8fce87 04-Feb-2011 Vasu Nori <vnori@google.com> am afefa43d: am cac5bbb5: Revert "bug:3420722"

* commit 'afefa43d9919f9284885f7080111c54a50c4fc90':
Revert "bug:3420722"
a29b942fe0f868b9d94299877f39a4ddcc3e85cc 04-Feb-2011 Vasu Nori <vnori@google.com> resolved conflicts for merge of 73642748 to master

Change-Id: I477599f16db5ea64e4fbc4d2be68dcedf2c80269
d119d3cbae976e791c9093cc5bea91ab9145a993 03-Feb-2011 Vasu Nori <vnori@google.com> Revert "bug:3414192 if otaupdate column is set, don't check mobile download limits"

This reverts commit ea245800c69d6bc10dc2680e6a242f59e9cb49b6.
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
f20af91262fecce05928167123c8d335b4cfd33d 03-Feb-2011 Vasu Nori <vnori@google.com> Revert "Merge "bug:3341145 if ignore_size_limits flag set, validate caller's perms" into honeycomb"

This reverts commit 3e7bb1c5d7e7d1a013df959c1a6947b33df0a0fd, reversing
changes made to b2085f61b37ad4a70c799012f25ff62a38173f68.
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
cac5bbb5f0c0d16fb8f3dd0a811c162ef7ba743b 03-Feb-2011 Vasu Nori <vnori@google.com> Revert "bug:3420722"

This reverts commit 1cccc19b596f168ed34126db38b046ab164e063b.
om/android/providers/downloads/DownloadProvider.java
1cccc19b596f168ed34126db38b046ab164e063b 03-Feb-2011 Vasu Nori <vnori@google.com> bug:3420722

Change-Id: Id40d2dbbefe5fa2546f8c5231be5f7fe9a7b43d6
om/android/providers/downloads/DownloadProvider.java
ed4870094f53bcd19c0542400389a1f56636ce5a 03-Feb-2011 Vasu Nori <vnori@google.com> resolved conflicts for merge of 43d649e9 to master

Change-Id: I27a615509269f256cf66de2dd217d8c4667caab4
3e7bb1c5d7e7d1a013df959c1a6947b33df0a0fd 03-Feb-2011 Vasu Nori <vnori@google.com> Merge "bug:3341145 if ignore_size_limits flag set, validate caller's perms" into honeycomb
86c04344cd871e0a443ab3dee86f8f7994f6d429 03-Feb-2011 Vasu Nori <vnori@google.com> bug:3341145 if ignore_size_limits flag set, validate caller's perms

and then of course ignore the mobile network size limits

Change-Id: I6765be9255187f93bd51acecc19a15db4f324204
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
a7f7882cd06aff28de27f00d5d5cc9aa0afaba0e 02-Feb-2011 Adam Powell <adamp@google.com> am 6a601663: am b2085f61: Bug 3341145 - Holo styling for download dialog

* commit '6a60166341f38841e9fc2c97da40423528f16d7d':
Bug 3341145 - Holo styling for download dialog
b2085f61b37ad4a70c799012f25ff62a38173f68 02-Feb-2011 Adam Powell <adamp@google.com> Bug 3341145 - Holo styling for download dialog

Change-Id: I20049f8affe7e2ff919ecf8f6b1b7dd220143111
om/android/providers/downloads/SizeLimitActivity.java
d0b57887912ff7bc0fc3c2976fecc062136465d5 02-Feb-2011 Leon Scroggins <scroggo@google.com> Check for null before accessing pckg.

Prevents null pointer exception when using
DownloadManager.completedDownload

Change-Id: I53859705c5e925f2320491451e41a631e4fed715
om/android/providers/downloads/DownloadProvider.java
93842036405d99a1c26471d5d06fe3f1b5048b2d 02-Feb-2011 Vasu Nori <vnori@google.com> am 8db8fba2: am ea245800: bug:3414192 if otaupdate column is set, don\'t check mobile download limits

* commit '8db8fba215a981edd24ad1f7118d3397be0114d2':
bug:3414192 if otaupdate column is set, don't check mobile download limits
ea245800c69d6bc10dc2680e6a242f59e9cb49b6 02-Feb-2011 Vasu Nori <vnori@google.com> bug:3414192 if otaupdate column is set, don't check mobile download limits

this allows OTA update to work without being subject to download limits
on mobile networks.

Change-Id: I92c60ba3ecbde615bd93778b391a5fe067dbd2fe
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/Constants.java
om/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
om/android/providers/downloads/DownloadThread.java
b18ed519040c1ecd98f8cb139adcc315a3f4eedc 21-Jan-2011 Vasu Nori <vnori@google.com> bug:3048327 (master) ability to add completed download to dnload mgr

Change-Id: Ib9d4df107787191a5349365908cbe096b67770dc
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
9b4371da26f27cfa85d78e0bd4728309f9a445c9 18-Jan-2011 Vasu Nori <vnori@google.com> use DownloadManager's new public API instead of localcode

after Change-Id: I7380964c6098d5ca6396b17980f78457c23d1a87
remove localcoding in DownloadProvider for those newly introduced
API methods

Change-Id: I2e42f9c1d1de5e414eaac6354930cec98c7d2947
om/android/providers/downloads/RealSystemFacade.java
3022abb31ad80a5e4b263ac078709e91b97bf226 16-Jan-2011 Vasu Nori <vnori@google.com> manual merge of GB change Change-Id: I1acf2fb9491d24f5e109206a91dda3eea429e447

Change-Id: Ibaf889d78fc99a32038a77671036fc6a5068580f
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
47cb8be0fea98c2f9d96b269278f2e011e810413 13-Jan-2011 Vasu Nori <vnori@google.com> bug:3332449 downloadmanager deleting downloaded files sometimes

removeSpuriousFiles() method in StorageManager.java is removing
files because of it incorrectly thought a given file has NO entry
in downloads db.

more details:
List<File> files;
String filename;
files.remove(filename)
remove should be new File(filename)

most probably this fix also addresses bug:3324673

Change-Id: I22c58398fe874fa81939b575c782b6700a2cac4e
om/android/providers/downloads/StorageManager.java
597bbd96431ca1fb655a21285cfd5411a67bad16 11-Jan-2011 Vasu Nori <vnori@google.com> bug:3338089 NPE in downloadthread

Change-Id: I95b4c52598092e9f6ffa1713b36ac11d44e26279
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.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
om/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.
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.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
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/StorageManager.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
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/StopRequestException.java
om/android/providers/downloads/StorageManager.java
6bf8b8d183ef3fa118ad9fb8eb35c2ee101e46a1 21-Dec-2010 olly <olly@google.com> Fixing Helpers to correctly parse file names / extensions in the case where the filename does not have a file extension but there are one or more dots in the parent directory names.

e.g. /mnt/sdcard/Android/data/com.google.android.youtube/files/file

Change-Id: I5aad1625a9f36135e947c0f929ee740fc66eb0d3
om/android/providers/downloads/Helpers.java
0ecf66c946cb4fdf2dd4763023f4320b41eedd24 17-Dec-2010 Vasu Nori <vnori@google.com> Merge "when download-complete-notif is clicked on, don't show notif anymore"
d7e576be9f8a5520fcd7c233b76f8f91d361aac7 16-Dec-2010 Vasu Nori <vnori@google.com> fix a bug in one of the downloadmanager queries

Change-Id: Ie8148af67507bdc1d12307ce0d957343d2a28af0
om/android/providers/downloads/Helpers.java
5c8e74088882d6253a29e6b695a5936c038d4842 16-Dec-2010 Vasu Nori <vnori@google.com> when download-complete-notif is clicked on, don't show notif anymore

bug:3272589
in HC, when using public API, if the downloaded file is in downloads data
dir, wrong intent action is set when the user clicks on download-complete
notification.
fix this by sending the correct intent action if the download is
in downloads data dir or any other location specified by the app.

Change-Id: I72621be5f1d6a5caecb8ec85634b351e08b66c31
om/android/providers/downloads/DownloadNotification.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/DownloadThread.java
69dc9ec8838db86c10493c1cf3c0d7bbd2953f8a 03-Dec-2010 Vasu Nori <vnori@google.com> Merge "bug:3144642 fix is to treat empty strings as nulls"
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
1dc416983a4638a250b67b11564466088cfa41f6 02-Dec-2010 Vasu Nori <vnori@google.com> bug:3144642 fix is to treat empty strings as nulls

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
aThis 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.

Change-Id: Ifea1544737023008eff44aef9acd976902a0c143
om/android/providers/downloads/DownloadInfo.java
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
om/android/providers/downloads/DownloadThread.java
d2ce7f387eace18b625018b21ee3ae50e9cf8c2f 01-Dec-2010 Kenny Root <kroot@google.com> am 5c29cce0: am e1823c84: Don\'t filter by UID for apps with ACCESS_ALL_DOWNLOADS

* commit '5c29cce0bac00a7a32cd92210825a789e140cf94':
Don't filter by UID for apps with ACCESS_ALL_DOWNLOADS
5c29cce0bac00a7a32cd92210825a789e140cf94 01-Dec-2010 Kenny Root <kroot@google.com> am e1823c84: Don\'t filter by UID for apps with ACCESS_ALL_DOWNLOADS

* commit 'e1823c84698006aa26a8c5dcfa5c4034858dfbe3':
Don't filter by UID for apps with ACCESS_ALL_DOWNLOADS
e1823c84698006aa26a8c5dcfa5c4034858dfbe3 01-Dec-2010 Kenny Root <kroot@google.com> Don't filter by UID for apps with ACCESS_ALL_DOWNLOADS

Old platform behavior of DownloadProvider would allow anyone with
special access to access all the downloads. New behavior is to return
/my_downloads/ on an .insert() call. For things that aren't using the
new API where DownloadInfo.getAllDownloadsUri() is accessible, make any
application with ACCESS_ALL_DOWNLOADS permission bypass the calling UID
check for /my_downloads/

Bug: 3242328
Change-Id: I536fde4525dd74066879f7c7da7fa609ff344645
om/android/providers/downloads/DownloadProvider.java
01d0182d86db003b2da5b831cb26820093888d9a 09-Nov-2010 Vasu Nori <vnori@google.com> provider changes due to CL: Ief1693785f0484c1b434fb41a68693f9aff96492

Change-Id: I8940778292d0a9166cfcfb92d37ea568b8f6ceef
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadThread.java
3f276dc044f533d54392c7385ab5f3b1dcb44594 09-Nov-2010 Vasu Nori <vnori@google.com> if any exceptions encountered while trimming downloads db, ignore 'em.

bug:3176990
Change-Id: I182331cbd63b6524a18d19e4d8567210886f8c16
om/android/providers/downloads/DownloadService.java
3002e1870d4ad76c260b4729a8d86212c8db3e78 05-Nov-2010 Vasu Nori <vnori@google.com> allow the column "scanned" from DownloadManager. bug:3169437

Change-Id: I96f0b51295611b67735c1b726bcd46bbeaa90613
om/android/providers/downloads/DownloadProvider.java
3ca67748bc92eac89f731796c5597ff1fbe9217b 04-Nov-2010 Vasu Nori <vnori@google.com> changes to support CL: I1f5dd734e394db0056579a3a0c26862fee27981e

1. if an application designates a downloaded file to be mediascanner
scannable or not, store that fact in database.
2. use the above to determine whether a file shoudl be mediascanned or not
in DownloadService
3. implement code to return mimetype for the new Uri "/public_downloads"
introduced in CL: I1f5dd734e394db0056579a3a0c26862fee27981e

Change-Id: I5c062ad6d1b58306044cee49ff3827e908d27fd9
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
971525cbe68f83a4f05cfe942f774486702947a7 03-Nov-2010 Vasu Nori <vnori@google.com> downloadmanager public API usage can cause non-scanning of media files

bug:3162073
Change-Id: I13b80fedd7658c8574f33b43b74b5aa28a2895bc
om/android/providers/downloads/DownloadInfo.java
2e6672d1249a0fcb147632ecb97133d15076d9e8 27-Oct-2010 Vasu Nori <vnori@google.com> in DM public API, sending notifications on clicks should include data

receiving application needs to know WHAT items the clicks occurred on -
not just the fact that *something* was clicked on.
this is duplicating the behavior as it exists today in the non-public API.

depends on Change-Id: Ibe53ccd9934c73175459e42e3d417eee69ae6735

Change-Id: I924f85bd5faf443ac5648839b68390ec4de1f677
om/android/providers/downloads/DownloadReceiver.java
b3ae94915d68e4c3f325ea02bab32d00cccb4f1a 29-Oct-2010 Vasu Nori <vnori@google.com> make sure filename is non-null before delting it.

if a download fails for some reason, then filename could be null.
move Helpers.deleteFile() code into private method in DownloadService

Change-Id: Ifb12a84b6185e19c70d62392e102950c07f56a01
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/Helpers.java
38f1711910715538d6b64e505fe8fb9a0cd40475 28-Oct-2010 Vasu Nori <vnori@google.com> when using DM public API, allow duplicate downloads of same file

bug:3132790
this mimics the behavior that exists today (in non-public API)

Change-Id: I722b3bc23fe8c9b0bf66a088c5f6a3130be2129f
om/android/providers/downloads/Helpers.java
fdb8fb155914bba44351b41911c54d34d8cdfaae 27-Oct-2010 Vasu Nori <vnori@google.com> Merge "reduce number of times mediascanner is invoked by downloadservice"
fcac9514de88b995356499c7eacd6194ff93378a 27-Oct-2010 Vasu Nori <vnori@google.com> allow run-time verbose debugging option on downloadmanager code.

otherwise, one has to recompile and reflash to get debug output

Change-Id: I1d89d7cca3363fa793f74ba805136667e1ce3091
om/android/providers/downloads/Constants.java
fdbeea8d2eb7566bbd556d42960995cfc695c983 27-Oct-2010 Vasu Nori <vnori@google.com> reduce number of times mediascanner is invoked by downloadservice

this is one of the 2 bugs mentioned in bug:3129943
sometimes MediaProvider returns null for returned param Uri.
in such cases, mark the file as 'scanned' in the downloads db
so that it is NOT scanned again later by DownlaodService.

depends on Change-Id: I92514e1a11f5119229c0c7292e410e352a9dbcdd

Change-Id: Ie9d839581f656c929a77bd5f244ad6b2fb1585e6
om/android/providers/downloads/DownloadService.java
04f09085f85d094207d22ae8969102bd48178180 20-Oct-2010 Vasu Nori <vnori@google.com> remove usage of hidden public constants.

Change-Id: I2edf1bef5e741de8193cb293807e3ace42003b0c
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
d1140df2630b5a262efa1cbf4cb3361d0dd56aa8 18-Oct-2010 Jean-Baptiste Queru <jbq@google.com> am 9f6654cf: Merge 216736d2 from gingerbread

Merge commit '9f6654cfec6e6d8d1e3de9a8adeba46137a22105'

* commit '9f6654cfec6e6d8d1e3de9a8adeba46137a22105':
bug:3099994 NPE in DownloadManager when deleting non-media file
9f6654cfec6e6d8d1e3de9a8adeba46137a22105 16-Oct-2010 Jean-Baptiste Queru <jbq@google.com> Merge 216736d2 from gingerbread

Change-Id: I404d1a66d337b1dade181ade92dc21fc0e819aa7
1e82f310a9ee461690a2e05265348c8e8e26c05d 15-Oct-2010 Vasu Nori <vnori@google.com> am 3e759e21: am a53c21ed: fix broken build bug:3095237

Merge commit '3e759e21291d6ca1a49ded3f24f3be0a26af4e2b'

* commit '3e759e21291d6ca1a49ded3f24f3be0a26af4e2b':
fix broken build bug:3095237
f9360e2fdc28e98d2f5c0fb25c18d2f1e6b32645 15-Oct-2010 Vasu Nori <vnori@google.com> am 57c4e918: am e00c3120: bug:3069735 in Download UI app, handle deletes correctly

Merge commit '57c4e9180e3a339dba984f1c8dff76ef18443a7a'

* commit '57c4e9180e3a339dba984f1c8dff76ef18443a7a':
bug:3069735 in Download UI app, handle deletes correctly
be2eaa55bb3dca3422da25fe907b50a4ad70df17 15-Oct-2010 Vasu Nori <vnori@google.com> bug:3099994 NPE in DownloadManager when deleting non-media file

DownloadService always scans files and assumes MediaProvider
returns a valid Uri. But MediaProvider returns null for
return param 'uri'
if the file is not audio/video/image etc media type file
(for example, pdf)

Change-Id: If32bd1895b00b5406973a5e240ad3558d46f9f4a
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/Helpers.java
3e759e21291d6ca1a49ded3f24f3be0a26af4e2b 14-Oct-2010 Vasu Nori <vnori@google.com> am a53c21ed: fix broken build bug:3095237

Merge commit 'a53c21edb5dc57d97dcddd03fbfa2022abf43787' into gingerbread-plus-aosp

* commit 'a53c21edb5dc57d97dcddd03fbfa2022abf43787':
fix broken build bug:3095237
a53c21edb5dc57d97dcddd03fbfa2022abf43787 14-Oct-2010 Vasu Nori <vnori@google.com> fix broken build bug:3095237

Change-Id: I7e1fe99cc482fc270894a820049275fc0c64233e
om/android/providers/downloads/DownloadProvider.java
57c4e9180e3a339dba984f1c8dff76ef18443a7a 14-Oct-2010 Vasu Nori <vnori@google.com> am e00c3120: bug:3069735 in Download UI app, handle deletes correctly

Merge commit 'e00c31208405bd2e4c88e069df7a2b15237f70bf' into gingerbread-plus-aosp

* commit 'e00c31208405bd2e4c88e069df7a2b15237f70bf':
bug:3069735 in Download UI app, handle deletes correctly
e00c31208405bd2e4c88e069df7a2b15237f70bf 13-Oct-2010 Vasu Nori <vnori@google.com> bug:3069735 in Download UI app, handle deletes correctly

gingerbread.
High-level details
1. When a file is downloaded by DownloadManager, metadata about the file
is stored in 2 databases: DownloadProvider and MediaProvider.

2. So, when it is to be deleted, its metadata needs to be cleaned up from
both the databases.

3. But the 2 databases use differnt content-uri's as "primary keys" and
DownloadProvider loses the "primary-key" of the row in MediaProvider
database.

4. Easiest thing would have been to have DownloadProvider give filepath
to MediaProvider and let MediaProvider linearly scan its database
to locate the row and delete it.

5. The other - faster but more coding for now - option is to have
DownloadProvider store the "primary-key" of the MediaProvider's
row. implemented in this CL.

Low-level details
1. add 2 new columns to downloads table in downloads.db:
mediaprovider_uri = downloaded file's content_uri in mediaprovider db
this column is null for downloads that finished before this column is
added to the database.
deleted = flag is set to true if a file is to be deleted
2. download UI app shows only those files whose 'deleted' flag is not set.
3. when the user deletes downloads from download UI app,
3.1. if mediaprovider_uri is NOT null, then the row is deleted from
downloads table AND from the mediaprovider database.
3.2 if mediaprovider_uri is NULL, then its row in downloads database
is marked 'tp be deleted' by setting 'deleted' column to '1'.
4. When DownloadService (in DownloadProvider) processes all rows from
downloads table, if it sees any rows wth 'deleted' = 1, then
it uses MediaScanner Service to re-scan the file,
get the mediaprovider_uri from MediaProvider
and update the row in downloads table with this mediaprovider_uri value
and then delete the row by doing the following
1. delete it from MediaProvider database using mediaprovider_uri
2. delete it from DownloadProvider database

Problem with this solution:
There is a small window where it is deleted by the user on the Download app
(and the row disappears from the display) but it is still present in
Gallery app.
Thats due to the following asynchronous operations
1. DownladService which processes rows-to-be-deleted is not always up
2. DownloadService uses asynchronous call to have the file re-scanned
by MediaScanner to get mediaprovider_uri

Change-Id: Ib90eb9e647f543312c865d3bbf9a06fb867a648b
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
137f02d0e961b5fb761868db85e7f43966f35d52 11-Oct-2010 Steve Howard <showard@google.com> am 1f262cf3: am cd990514: Merge "Make DownloadProvider use parameterized queries." into gingerbread

Merge commit '1f262cf3af0512e0d621b7818aab9bb79527f01f'

* commit '1f262cf3af0512e0d621b7818aab9bb79527f01f':
Make DownloadProvider use parameterized queries.
1f262cf3af0512e0d621b7818aab9bb79527f01f 08-Oct-2010 Steve Howard <showard@google.com> am cd990514: Merge "Make DownloadProvider use parameterized queries." into gingerbread

Merge commit 'cd990514feb2b17848809d9262e0d73a828b2142' into gingerbread-plus-aosp

* commit 'cd990514feb2b17848809d9262e0d73a828b2142':
Make DownloadProvider use parameterized queries.
e610c0502c00689411624c00c3f81497df93b202 08-Oct-2010 Steve Howard <showard@google.com> Make DownloadProvider use parameterized queries.

This avoids filling up the query cache unnecessary, but required some
structural changes to ease the passing around of a selection along
with its arguments.

Change-Id: I724185763b94146d17573cab68f675c24e49634e
om/android/providers/downloads/DownloadProvider.java
1083ba743ad796570add9713cf979e10d811f7c4 01-Oct-2010 Steve Howard <showard@google.com> am ace1d5da: am d4dc8501: Merge "Seriously improve error reporting in DownloadThread." into gingerbread

Merge commit 'ace1d5da2b288f6166224cf2164731ae0fa2de61'

* commit 'ace1d5da2b288f6166224cf2164731ae0fa2de61':
Seriously improve error reporting in DownloadThread.
b00b6560382d2b51ab2741f710738a281128dbea 01-Oct-2010 Steve Howard <showard@google.com> am 42469fa4: am 5d81e244: Avoid NPE when checking file URI in DownloadProvider

Merge commit '42469fa405c7aa891e7c431cd65edd424803979c'

* commit '42469fa405c7aa891e7c431cd65edd424803979c':
Avoid NPE when checking file URI in DownloadProvider
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.
42469fa405c7aa891e7c431cd65edd424803979c 01-Oct-2010 Steve Howard <showard@google.com> am 5d81e244: Avoid NPE when checking file URI in DownloadProvider

Merge commit '5d81e2447ed77860afecd71583e137178c2c6807' into gingerbread-plus-aosp

* commit '5d81e2447ed77860afecd71583e137178c2c6807':
Avoid NPE when checking file URI in DownloadProvider
d4dc8501ecb89b91f865510207297dd960afe031 01-Oct-2010 Steve Howard <showard@google.com> Merge "Seriously improve error reporting in DownloadThread." into gingerbread
5d81e2447ed77860afecd71583e137178c2c6807 01-Oct-2010 Steve Howard <showard@google.com> Avoid NPE when checking file URI in DownloadProvider

Change-Id: Ic937b05308cecce244725e25767a3a1310a8463d
om/android/providers/downloads/DownloadProvider.java
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
om/android/providers/downloads/DownloadFileInfo.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
14a74fe20f2a5f1666deb6fd8ea52d5d68d7104c 30-Sep-2010 Steve Howard <showard@google.com> am ed2f1150: resolved conflicts for merge of b108a273 to gingerbread-plus-aosp

Merge commit 'ed2f11502fb02509d9efec1dbda7981c86f37fbd'

* commit 'ed2f11502fb02509d9efec1dbda7981c86f37fbd':
Improve how the download manager reports paused statuses.
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
d86179caadc6f70fd382d7cdc75c51ee84e260f7 29-Sep-2010 Brad Fitzpatrick <bradfitz@android.com> am fce7a5e8: am d01ccf8e: Merge "Trim the database & check spurious files off the UI thread." into gingerbread

Merge commit 'fce7a5e8547d4ea53700f37b87752e26a39e4cc4'

* commit 'fce7a5e8547d4ea53700f37b87752e26a39e4cc4':
Trim the database & check spurious files off the UI thread.
a1448628237471a7a2aeb67b560b1502c2bd5ba8 28-Sep-2010 Steve Howard <showard@google.com> Manual merge: Moved DownloadManager to android.app

Change-Id: Id1de44459ec1bf53e928cae826047467b355823d
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadReceiver.java
fce7a5e8547d4ea53700f37b87752e26a39e4cc4 28-Sep-2010 Brad Fitzpatrick <bradfitz@android.com> am d01ccf8e: Merge "Trim the database & check spurious files off the UI thread." into gingerbread

Merge commit 'd01ccf8ef98aba424a49c44ed6db39435c6d6d77' into gingerbread-plus-aosp

* commit 'd01ccf8ef98aba424a49c44ed6db39435c6d6d77':
Trim the database & check spurious files off the UI thread.
d01ccf8ef98aba424a49c44ed6db39435c6d6d77 28-Sep-2010 Brad Fitzpatrick <bradfitz@android.com> Merge "Trim the database & check spurious files off the UI thread." into gingerbread
ee215b3df5482b9051364d99411f70132734be21 28-Sep-2010 Steve Howard <showard@google.com> am 14961f94: Moved DownloadManager to android.app (DO NOT MERGE)

Merge commit '14961f94d762e733a733e3268fca1074d8da5f8c' into gingerbread-plus-aosp

* commit '14961f94d762e733a733e3268fca1074d8da5f8c':
Moved DownloadManager to android.app (DO NOT MERGE)
ad017bfbbb549cbbaa522038fa46450f0cedf413 28-Sep-2010 Brad Fitzpatrick <bradfitz@android.com> Trim the database & check spurious files off the UI thread.

Change-Id: I92180fc4344579b93361d5584243688a1cfdd091
om/android/providers/downloads/DownloadService.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadReceiver.java
7704d598c451c1a2615a8910d65c593de1757d19 23-Sep-2010 Steve Howard <showard@google.com> am 04d70252: am 36f06f4c: Merge "DB migration to eliminate some null fields in old downloads" into gingerbread

Merge commit '04d7025262d7f6c5c372ec699d78b18d05b0400b'

* commit '04d7025262d7f6c5c372ec699d78b18d05b0400b':
DB migration to eliminate some null fields in old downloads
4292815e4e1cb17ed312a6f7f3f881e58a511742 23-Sep-2010 Steve Howard <showard@google.com> am 5dbaa73a: am ebb555c0: Support multi-valued HTTP headers, handle new API changes

Merge commit '5dbaa73a7f356f67810becbf3ad258a7dd765e59'

* commit '5dbaa73a7f356f67810becbf3ad258a7dd765e59':
Support multi-valued HTTP headers, handle new API changes
04d7025262d7f6c5c372ec699d78b18d05b0400b 23-Sep-2010 Steve Howard <showard@google.com> am 36f06f4c: Merge "DB migration to eliminate some null fields in old downloads" into gingerbread

Merge commit '36f06f4c8497ab47e64bcc5d8cea12a109fede5e' into gingerbread-plus-aosp

* commit '36f06f4c8497ab47e64bcc5d8cea12a109fede5e':
DB migration to eliminate some null fields in old downloads
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
36f06f4c8497ab47e64bcc5d8cea12a109fede5e 23-Sep-2010 Steve Howard <showard@google.com> Merge "DB migration to eliminate some null fields in old downloads" into gingerbread
73f5f223477795e10079d25c1eb5f796af1f00a9 23-Sep-2010 Steve Howard <showard@google.com> DB migration to eliminate some null fields in old downloads

The DownloadProvider now ensures that current bytes, total bytes,
title and description are never null in the DB. Some new code relies
on this assumption for simplicity. That means we need to ensure this
invariant is true for pre-existing downloads as well.

Change-Id: Iea2289516d2636edf3394678ab08aa9cea31dc69
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
b157649a5620aba3ad65750d1044100b62c65d9c 21-Sep-2010 Steve Howard <showard@google.com> am 7b96b251: am d3197296: Implement dialogs for wifi required + recommended limits.

Merge commit '7b96b251c0404ed3f05652bd7d5209910fb999cc'

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

Merge commit '2031fa7bad5ef3e31cf0ea73d0b9bf4670842cf0'

* commit '2031fa7bad5ef3e31cf0ea73d0b9bf4670842cf0':
Improve file error reporting + new detailed error messages in UI
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
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
31eb4c1b778686307c3d217577dd304ea475064a 20-Sep-2010 Steve Howard <showard@google.com> am b9115af1: am 3398db8f: Fix notification bugs, cleanup DownloadService + DownloadReceiver

Merge commit 'b9115af1e7b39a25c00aed7c9d3bb413ecef9eda'

* commit 'b9115af1e7b39a25c00aed7c9d3bb413ecef9eda':
Fix notification bugs, cleanup DownloadService + DownloadReceiver
b9115af1e7b39a25c00aed7c9d3bb413ecef9eda 20-Sep-2010 Steve Howard <showard@google.com> am 3398db8f: Fix notification bugs, cleanup DownloadService + DownloadReceiver

Merge commit '3398db8f3b195959faa2a7cf09918f364432ac28' into gingerbread-plus-aosp

* commit '3398db8f3b195959faa2a7cf09918f364432ac28':
Fix notification bugs, cleanup DownloadService + DownloadReceiver
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
a5e23ea33b415bca6ca7572e3286d4ea04b62c8a 18-Sep-2010 Steve Howard <showard@google.com> am e8027017: am 4bebe75b: Temporary fix to support old URIs for Market

Merge commit 'e80270177d1b504525d1f4ea4139b0c213fea891'

* commit 'e80270177d1b504525d1f4ea4139b0c213fea891':
Temporary fix to support old URIs for Market
e80270177d1b504525d1f4ea4139b0c213fea891 18-Sep-2010 Steve Howard <showard@google.com> am 4bebe75b: Temporary fix to support old URIs for Market

Merge commit '4bebe75b3e2361d7fb0aa966598c41c45ad9317f' into gingerbread-plus-aosp

* commit '4bebe75b3e2361d7fb0aa966598c41c45ad9317f':
Temporary fix to support old URIs for Market
4bebe75b3e2361d7fb0aa966598c41c45ad9317f 18-Sep-2010 Steve Howard <showard@google.com> Temporary fix to support old URIs for Market

Market has its own copies of the download manager URIs. This change
bring back support for those so Market will keep working until they
can properly update their code.

Change-Id: I283ea65931085c0f083a182842d362c113427537
om/android/providers/downloads/DownloadProvider.java
21b7855b2a6411bacbe27a91527fa2d68d14b8fa 16-Sep-2010 Steve Howard <showard@google.com> am 176a7442: resolved conflicts for merge of 3d55d829 to gingerbread-plus-aosp

Merge commit '176a74426f750dc56e7d200a4cdc3b6ed75fe6cd'

* commit '176a74426f750dc56e7d200a4cdc3b6ed75fe6cd':
New URI structure with "my_downloads" and "all_downloads"
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
eda6f9794c883f8aa209369083e90913df01545f 13-Sep-2010 Steve Howard <showard@google.com> am d5c0120a: am 13db2005: Merge "Fix silly bug with completed notifications." into gingerbread

Merge commit 'd5c0120af6eae66f15e83ef61eb61ea19542b097'

* commit 'd5c0120af6eae66f15e83ef61eb61ea19542b097':
Fix silly bug with completed notifications.
81bbddb5086163ebc9d388a6cca852ed4a16d203 13-Sep-2010 Steve Howard <showard@google.com> am 7fa71b17: am 71e7fda9: Further work on the new downloads UI.

Merge commit '7fa71b17d1bcaceb4688cb4b0e6982d1db4a0538'

* commit '7fa71b17d1bcaceb4688cb4b0e6982d1db4a0538':
Further work on the new downloads UI.
d5c0120af6eae66f15e83ef61eb61ea19542b097 13-Sep-2010 Steve Howard <showard@google.com> am 13db2005: Merge "Fix silly bug with completed notifications." into gingerbread

Merge commit '13db200521cf8ead0d96173bccd7e141182eeccd' into gingerbread-plus-aosp

* commit '13db200521cf8ead0d96173bccd7e141182eeccd':
Fix silly bug with completed notifications.
7fa71b17d1bcaceb4688cb4b0e6982d1db4a0538 13-Sep-2010 Steve Howard <showard@google.com> am 71e7fda9: Further work on the new downloads UI.

Merge commit '71e7fda9135a0915af1fd419d07ebf85ad09beb4' into gingerbread-plus-aosp

* commit '71e7fda9135a0915af1fd419d07ebf85ad09beb4':
Further work on the new downloads UI.
13db200521cf8ead0d96173bccd7e141182eeccd 13-Sep-2010 Steve Howard <showard@google.com> Merge "Fix silly bug with completed notifications." into gingerbread
cae0c3610fce7336c06377698e22878d110b19d2 11-Sep-2010 Steve Howard <showard@google.com> Fix silly bug with completed notifications.

This functionality isn't part of the public API, hence it lacks test
coverage. Rather than adding tests, I'm inclined to leave it and
hopefully we'll be able to migrate existing apps to the public API
soon enough.

Change-Id: I1210c6525dfb7cb12c1b8e35c04684060d3ad87e
om/android/providers/downloads/DownloadNotification.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
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/Helpers.java
158ca55d77dd84974cedef138464b1f379f8dbf6 30-Aug-2010 Andreas Sandblad <andreas.sandblad@sonyericsson.com> am caab8ef3: am 89e4816f: Added support for downloading files with unicode characters

Merge commit 'caab8ef3d5eac4b64aef7042078a542bb52f3bda'

* commit 'caab8ef3d5eac4b64aef7042078a542bb52f3bda':
Added support for downloading files with unicode characters
caab8ef3d5eac4b64aef7042078a542bb52f3bda 30-Aug-2010 Andreas Sandblad <andreas.sandblad@sonyericsson.com> am 89e4816f: Added support for downloading files with unicode characters

Merge commit '89e4816fe5f06f4bc2c2fe0e38e63c7fbe468cd7' into gingerbread-plus-aosp

* commit '89e4816fe5f06f4bc2c2fe0e38e63c7fbe468cd7':
Added support for downloading files with unicode characters
89e4816fe5f06f4bc2c2fe0e38e63c7fbe468cd7 25-Aug-2010 Andreas Sandblad <andreas.sandblad@sonyericsson.com> Added support for downloading files with unicode characters

Currently only certain ASCII characters are allowed in a filename, all
other characters are replaced with an underscore. This gives bad
usability for foreign languages (e.g. japanese). This fix replaces the
current regexp with a method which replaces only those characters unsafe
to be used on VFAT filesystems (should work on most other
filesystems as well).

Change-Id: I114d47b4b35f28490e6b12493138355532fda499
om/android/providers/downloads/Helpers.java
140fcdcda4d1ff10eff86704f20700e83bf60b7e 24-Aug-2010 Steve Howard <showard@google.com> am 9877c7f8: am 97d590d5: Add UI message when queued for wifi due to size.

Merge commit '9877c7f8414bfa1feb49b2afe166f99fff678794'

* commit '9877c7f8414bfa1feb49b2afe166f99fff678794':
Add UI message when queued for wifi due to size.
000e1a78010c54849022937c587f3af76937c815 21-Aug-2010 Steve Howard <showard@google.com> am b14c9649: am 1df61f0e: Avoid endless restarts when waiting for connectivity.

Merge commit 'b14c9649a85152aaf87117fa376bbcd46e754cde'

* commit 'b14c9649a85152aaf87117fa376bbcd46e754cde':
Avoid endless restarts when waiting for connectivity.
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
b14c9649a85152aaf87117fa376bbcd46e754cde 19-Aug-2010 Steve Howard <showard@google.com> am 1df61f0e: Avoid endless restarts when waiting for connectivity.

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

* commit '1df61f0e1a275961ad9762ffc1d141adb91870e0':
Avoid endless restarts when waiting for connectivity.
1df61f0e1a275961ad9762ffc1d141adb91870e0 19-Aug-2010 Steve Howard <showard@google.com> Avoid endless restarts when waiting for connectivity.

Adding an extra check for usable network connectivity to avoid an endless
restart-pause loop while waiting for usable connectivity.

Change-Id: If4da9ad222993b5479ada658508f445d10a42013
om/android/providers/downloads/DownloadInfo.java
99a9c8fbffc70670553ded9bfb4b08c89c67fc7e 19-Aug-2010 Steve Howard <showard@google.com> resolved conflicts for merge of 2f3c8c7e to master

Change-Id: Idcaa37fc828bfae41a150f2cce7b55fa152987be
2f3c8c7eba7d1109cfb5a1886f094f6821376f11 18-Aug-2010 Steve Howard <showard@google.com> am 7bdfb134: Merge "Fix and test handling of null/empty download fields." into gingerbread

Merge commit '7bdfb134c6c1c4e3d4c5da61327e62bc38407c95' into gingerbread-plus-aosp

* commit '7bdfb134c6c1c4e3d4c5da61327e62bc38407c95':
Fix and test handling of null/empty download fields.
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
om/android/providers/downloads/DownloadProvider.java
3e93fd3ebd5c04c867619853434f5eaebbdc824f 17-Aug-2010 Steve Howard <showard@google.com> am fa5175e5: am adb6887d: Clean up error codes returned by download manager.

Merge commit 'fa5175e572258fba0cd55e1c8a01b654178e3f1e'

* commit 'fa5175e572258fba0cd55e1c8a01b654178e3f1e':
Clean up error codes returned by download manager.
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.
a69384858be6b58739b4ce759ec8db3883283d3e 17-Aug-2010 Steve Howard <showard@google.com> am e80c3555: am e61798da: Extend PublicApiAccessTest to exercise DownloadManager.

Merge commit 'e80c35557bd72489323303af9d93c2c33c88cce9'

* commit 'e80c35557bd72489323303af9d93c2c33c88cce9':
Extend PublicApiAccessTest to exercise DownloadManager.
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
e80c35557bd72489323303af9d93c2c33c88cce9 16-Aug-2010 Steve Howard <showard@google.com> am e61798da: Extend PublicApiAccessTest to exercise DownloadManager.

Merge commit 'e61798da80558450f580ed948d0d469bd6423d8e' into gingerbread-plus-aosp

* commit 'e61798da80558450f580ed948d0d469bd6423d8e':
Extend PublicApiAccessTest to exercise DownloadManager.
e61798da80558450f580ed948d0d469bd6423d8e 02-Aug-2010 Steve Howard <showard@google.com> Extend PublicApiAccessTest to exercise DownloadManager.

This change adds a new test case to PublicApiAccessTest to enqueue a
request through DownloadManager, ensuring that the values constructed
by DownloadManager fit within the allowed bounds. It also fixes a bug
with allowing http header values exposed by the new test.

Change-Id: I94fec57d7a41298ac42ddaab338516e6a60c4e75
om/android/providers/downloads/DownloadProvider.java
e5c19fcdb4ed7da8f594b49efeb11dc33f0ca9a3 07-Aug-2010 Steve Howard <showard@google.com> am 1d332ceb: am da5a4183: Merge "Make all public API downloads visible." into gingerbread

Merge commit '1d332ceb5756ef2e09ae97f1735aa9b529063874'

* commit '1d332ceb5756ef2e09ae97f1735aa9b529063874':
Make all public API downloads visible.
1d332ceb5756ef2e09ae97f1735aa9b529063874 07-Aug-2010 Steve Howard <showard@google.com> am da5a4183: Merge "Make all public API downloads visible." into gingerbread

Merge commit 'da5a4183312f520cf35b154d33cb7205e6ba5557' into gingerbread-plus-aosp

* commit 'da5a4183312f520cf35b154d33cb7205e6ba5557':
Make all public API downloads visible.
fd3cf7d8582054a128fc16b6ee82bcb3de546b02 04-Aug-2010 Steve Howard <showard@google.com> am 3253c05a: am 0d4f9f10: Get wifi limit from secure settings.

Merge commit '3253c05afccc0cb62c29958d023d863222a5845c'

* commit '3253c05afccc0cb62c29958d023d863222a5845c':
Get wifi limit from secure settings.
3253c05afccc0cb62c29958d023d863222a5845c 03-Aug-2010 Steve Howard <showard@google.com> am 0d4f9f10: Get wifi limit from secure settings.

Merge commit '0d4f9f105c3a31475a36e9a1edfa868c66ff455f' into gingerbread-plus-aosp

* commit '0d4f9f105c3a31475a36e9a1edfa868c66ff455f':
Get wifi limit from secure settings.
40389839299240d63a734a1403529a1ee4a8c091 30-Jul-2010 Steve Howard <showard@google.com> am 92ae639f: am dea0a5f8: Add test for many interruptions to a single download.

Merge commit '92ae639f324084a23a54812ab92304b009a93340'

* commit '92ae639f324084a23a54812ab92304b009a93340':
Add test for many interruptions to a single download.
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.
486a854af88ce157057b42f37e5d6b2d5b03835a 30-Jul-2010 Steve Howard <showard@google.com> am 915912de: resolved conflicts for merge of f85aa9ef to gingerbread-plus-aosp

Merge commit '915912de0373b78de4cd7cc1f45dad760ef94243'

* commit '915912de0373b78de4cd7cc1f45dad760ef94243':
Improved support for 302/307 redirects.
915912de0373b78de4cd7cc1f45dad760ef94243 30-Jul-2010 Steve Howard <showard@google.com> resolved conflicts for merge of f85aa9ef to gingerbread-plus-aosp

Change-Id: I0adb03f16a6f0cc648886e02c79ffde63e18f99f
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
om/android/providers/downloads/DownloadProvider.java
0d4f9f105c3a31475a36e9a1edfa868c66ff455f 28-Jul-2010 Steve Howard <showard@google.com> Get wifi limit from secure settings.

Change-Id: I750654c28cb3d9f9aa67bd56e4d8d770dbfde4b4
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.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.
om/android/providers/downloads/DownloadThread.java
19161bd7add08748c1559f40452d26ded6045b4d 28-Jul-2010 Steve Howard <showard@google.com> am 7a8bf08f: am f6b4c24b: Fix bug with closing output stream for external downloads.

Merge commit '7a8bf08fe936a1fdb0408dea1ec2f39b83acc5d7'

* commit '7a8bf08fe936a1fdb0408dea1ec2f39b83acc5d7':
Fix bug with closing output stream for external downloads.
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
om/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
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
21bb2b72765a0e7996b8631dea9a9a4300462d2e 28-Jul-2010 Steve Howard <showard@google.com> am b6ba0582: am e6a05a1a: Serialize threading for download manager testing.

Merge commit 'b6ba05828ace9546e5e27d3745e7cbcba323b66d'

* commit 'b6ba05828ace9546e5e27d3745e7cbcba323b66d':
Serialize threading for download manager testing.
b6ba05828ace9546e5e27d3745e7cbcba323b66d 28-Jul-2010 Steve Howard <showard@google.com> am e6a05a1a: Serialize threading for download manager testing.

Merge commit 'e6a05a1aa4697440e9630d12b741b3bae321fe49' into gingerbread-plus-aosp

* commit 'e6a05a1aa4697440e9630d12b741b3bae321fe49':
Serialize threading for download manager testing.
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
f96dd7bd942e6c1363ad2c4028c71c31b947ba2c 26-Jul-2010 Steve Howard <showard@google.com> am f5373e6b: am 93155e1d: Stub out and test system notifications.

Merge commit 'f5373e6ba917cc60db4ee796aed8bc0e37a3f5e9'

* commit 'f5373e6ba917cc60db4ee796aed8bc0e37a3f5e9':
Stub out and test system notifications.
59554027a29a0ad2bcc6ce641cccb0b214be000b 26-Jul-2010 Steve Howard <showard@google.com> am 0a450da1: am 71aab521: Support for non-purgeable downloads through the public API.

Merge commit '0a450da1d9e95f27f479aa45b442960baac49bb1'

* commit '0a450da1d9e95f27f479aa45b442960baac49bb1':
Support for non-purgeable downloads through the public API.
1e5f9f05bcc378a30445483b7ef02654ca75fe20 26-Jul-2010 Steve Howard <showard@google.com> am 8667ebd1: am b06b739b: Make DownloadProvider accessible for public API usage.

Merge commit '8667ebd109ea212a7645ad6c214d4d765bb70b75'

* commit '8667ebd109ea212a7645ad6c214d4d765bb70b75':
Make DownloadProvider accessible for public API usage.
f5373e6ba917cc60db4ee796aed8bc0e37a3f5e9 26-Jul-2010 Steve Howard <showard@google.com> am 93155e1d: Stub out and test system notifications.

Merge commit '93155e1da7e89d4925e244f5afa94afb8ada7381' into gingerbread-plus-aosp

* commit '93155e1da7e89d4925e244f5afa94afb8ada7381':
Stub out and test system notifications.
0a450da1d9e95f27f479aa45b442960baac49bb1 26-Jul-2010 Steve Howard <showard@google.com> am 71aab521: Support for non-purgeable downloads through the public API.

Merge commit '71aab521efba9b28779541440c797220ec98ac97' into gingerbread-plus-aosp

* commit '71aab521efba9b28779541440c797220ec98ac97':
Support for non-purgeable downloads through the public API.
8667ebd109ea212a7645ad6c214d4d765bb70b75 26-Jul-2010 Steve Howard <showard@google.com> am b06b739b: Make DownloadProvider accessible for public API usage.

Merge commit 'b06b739b078ce4b00600487cfec31659647bf31f' into gingerbread-plus-aosp

* commit 'b06b739b078ce4b00600487cfec31659647bf31f':
Make DownloadProvider accessible for public API usage.
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
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
71aab521efba9b28779541440c797220ec98ac97 21-Jul-2010 Steve Howard <showard@google.com> Support for non-purgeable downloads through the public API.

This change adds a permission,
android.permission.DOWNLOAD_CACHE_NON_PURGEABLE. When an app has this
permission, any downloads it requests through the public API to the
download cache will automatically become non-purgeable, i.e. they'll
never be automatically deleted by the download manager to free up
space. This is intended for use only by the system updater.

Change-Id: I35cdd44f7e5d46bc70443d1a9743f61a51395ddb
om/android/providers/downloads/DownloadProvider.java
b06b739b078ce4b00600487cfec31659647bf31f 22-Jul-2010 Steve Howard <showard@google.com> Make DownloadProvider accessible for public API usage.

This change removes the requirement that apps have the
ACCESS_DOWNLOAD_MANAGER permission in order to access
DownloadProvider. This enables the public API to work. Instead,
DownloadProvider enforces the new permissions model for the public
API:
* insert() requires INTERNET permission
* insert() checks that input fits within the restricted input allowed
for the public API
* insert() also strictly checks the file URI provided with
DESTINATION_FILE_URI (and still requires WRITE_EXTERNAL_STORAGE
permission if that is supplied)

Note that if an app has the ACCESS_DOWNLOAD_MANAGER permission, legacy
behavior is retained.

I've added a test to cover this new access, and updated the existing
permissions tests.

I also fixed a bug in WHERE clause construction in update() and
delete(), and refactored the code to eliminate duplication.

Change-Id: I53a08df137b35c2788c36350276c9dff24858af1
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/Helpers.java
d91f26cc74666ed70b92a3026f09e91b93f10da5 22-Jul-2010 Steve Howard <showard@google.com> am c2448d48: am 0d8d8910: Make COLUMN_URI readable and tighten UID restrictions.

Merge commit 'c2448d488ff4e476762d0a07bb0757ca99c05445'

* commit 'c2448d488ff4e476762d0a07bb0757ca99c05445':
Make COLUMN_URI readable and tighten UID restrictions.
c2448d488ff4e476762d0a07bb0757ca99c05445 22-Jul-2010 Steve Howard <showard@google.com> am 0d8d8910: Make COLUMN_URI readable and tighten UID restrictions.

Merge commit '0d8d89105c00edbad95a268aaae65f2ff94ed5a1' into gingerbread-plus-aosp

* commit '0d8d89105c00edbad95a268aaae65f2ff94ed5a1':
Make COLUMN_URI readable and tighten UID restrictions.
95d3f8f9ba709ab8acaa05a6263118c88ebe5d31 22-Jul-2010 Steve Howard <showard@google.com> am 0bd0e0c9: am 0a77c62a: Public API support for broadcasts and connectivity control.

Merge commit '0bd0e0c9e4eec9d63b4e0f213e80fc9eee85fdf6'

* commit '0bd0e0c9e4eec9d63b4e0f213e80fc9eee85fdf6':
Public API support for broadcasts and connectivity control.
0bd0e0c9e4eec9d63b4e0f213e80fc9eee85fdf6 22-Jul-2010 Steve Howard <showard@google.com> am 0a77c62a: Public API support for broadcasts and connectivity control.

Merge commit '0a77c62a82503b38c484e0079648f0231dd85d53' into gingerbread-plus-aosp

* commit '0a77c62a82503b38c484e0079648f0231dd85d53':
Public API support for broadcasts and connectivity control.
0d8d89105c00edbad95a268aaae65f2ff94ed5a1 22-Jul-2010 Steve Howard <showard@google.com> Make COLUMN_URI readable and tighten UID restrictions.

I need to make COLUMN_URI readable by apps, since the public API
exposes that field. In order to avoid any possible security issues, I
got rid of the feature that potentially allowed apps to view downloads
from other UIDs. No one was using that feature and the public API
exposes no such feature (yet).

While at it, I cleaned up some related code in update() and delete().

Change-Id: I5384115d2a865255d009fbe37449488fd2269389
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
5f33f029b35bd10533cb77a0a8589325100f408a 21-Jul-2010 Steve Howard <showard@google.com> am 918f819a: resolved conflicts for merge of b5629da7 to gingerbread-plus-aosp

Merge commit '918f819abfb1da3661c1c604440666655e0c8909'

* commit '918f819abfb1da3661c1c604440666655e0c8909':
Major refactoring of DownloadThread.run().
918f819abfb1da3661c1c604440666655e0c8909 21-Jul-2010 Steve Howard <showard@google.com> resolved conflicts for merge of b5629da7 to gingerbread-plus-aosp

Change-Id: Icddfa080f43f882cce60af8a729436dcc2406384
fc39c8453c62989f8c8f615278badf6337ec003f 21-Jul-2010 Steve Howard <showard@google.com> am b607c31e: am 5180de23: Fix bug with deciding when to restart a download.

Merge commit 'b607c31e50fdd08258a489b881b2ad5ff5f75d0d'

* commit 'b607c31e50fdd08258a489b881b2ad5ff5f75d0d':
Fix bug with deciding when to restart a download.
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
b607c31e50fdd08258a489b881b2ad5ff5f75d0d 20-Jul-2010 Steve Howard <showard@google.com> am 5180de23: Fix bug with deciding when to restart a download.

Merge commit '5180de23e77139dd6971dfd48269242e3e3562d9' into gingerbread-plus-aosp

* commit '5180de23e77139dd6971dfd48269242e3e3562d9':
Fix bug with deciding when to restart a download.
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadService.java
89553b1c303d78739f8c7fa0d28970fecf22a48a 19-Jul-2010 Steve Howard <showard@google.com> am 7d4a4bc1: am 071bd7ac: Support for max download size that may go over mobile

Merge commit '7d4a4bc1f4bf92906598ede0160ff234d1179dd4'

* commit '7d4a4bc1f4bf92906598ede0160ff234d1179dd4':
Support for max download size that may go over mobile
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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
74e3e793cf01755d4b220b3e8b966d40eaacca7e 19-Jul-2010 Steve Howard <showard@google.com> am c45c8eb1: am 1aa26989: Merge "Introduce a seam to ConnectivityManager and TelephonyManager" into gingerbread

Merge commit 'c45c8eb1f9e8d93a02a7af2621a8fbcea1b2f6a7'

* commit 'c45c8eb1f9e8d93a02a7af2621a8fbcea1b2f6a7':
Introduce a seam to ConnectivityManager and TelephonyManager
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
89fb824c42c8ee1686439dab4ca42a69b19624f0 19-Jul-2010 The Android Open Source Project <initial-contribution@android.com> am 8e64adfe: merge from open-source master

Merge commit '8e64adfed603d808a712f0caad97425a5ef038f4'

* commit '8e64adfed603d808a712f0caad97425a5ef038f4':
Use proxy for downloads.
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
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.java
53356ad554f53a093434161cb494b8e818c294fb 15-Jul-2010 Steve Howard <showard@google.com> Fix build - remove reference to ReadOnlyCursorWrapper

Change-Id: I099c98e310039886990502d63566f3e217738b45
om/android/providers/downloads/DownloadProvider.java
99327c5d21c3886188f8ad263ca3abc833fdb7c5 15-Jul-2010 Steve Howard <showard@google.com> am d1bec343: am 88ea0b39: Merge "Support for custom HTTP headers on download requests" into gingerbread

Merge commit 'd1bec343dcbbc555837790119449ff7eea7c5312'

* commit 'd1bec343dcbbc555837790119449ff7eea7c5312':
Support for custom HTTP headers on download requests
88ea0b39bb74c7f8204ba74d3e83bce440a59d88 15-Jul-2010 Steve Howard <showard@google.com> Merge "Support for custom HTTP headers on download requests" into gingerbread
34bf81baf0397810696fb68eb982cd37e776b190 15-Jul-2010 Steve Howard <showard@google.com> am 06ed15cf: am ec910645: Cleanup whitespace in DownloadNotification

Merge commit '06ed15cf4f247171ed943754edd5ae08ac8e2264'

* commit '06ed15cf4f247171ed943754edd5ae08ac8e2264':
Cleanup whitespace in DownloadNotification
ec9106456e6d98b70a90ac4d7618cdfd05a5ba2b 15-Jul-2010 Steve Howard <showard@google.com> Cleanup whitespace in DownloadNotification

Change-Id: I598ece9690649573d44d3089e473612e25f2974b
om/android/providers/downloads/DownloadNotification.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
736f45c45b7c2b08814f70a5d23e2c8e7e09d1fa 14-Jul-2010 Steve Howard <showard@google.com> am 2c80c375: am 6d9b9828: Support for file URI destinations + last modified timestamp

Merge commit '2c80c37546b89dfd31875f6f6e977e9610cdb22b'

* commit '2c80c37546b89dfd31875f6f6e977e9610cdb22b':
Support for file URI destinations + last modified timestamp
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
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/Helpers.java
6de02c9ee3b38bb0322839ac50d6d83b05f8c99e 13-Jul-2010 Steve Howard <showard@google.com> am dc0655c6: am f413bd54: Improve error message when SQL parser gets illegal character

Merge commit 'dc0655c6dc744c17142c068faf9e2e7b07f8cf50'

* commit 'dc0655c6dc744c17142c068faf9e2e7b07f8cf50':
Improve error message when SQL parser gets illegal character
f413bd5422d918872e576c1c0c3e0b9227f15304 10-Jul-2010 Steve Howard <showard@google.com> Improve error message when SQL parser gets illegal character

Change-Id: Ife165361ebd75d558b311710e62abdfbdc355f1b
om/android/providers/downloads/Helpers.java
9b3731f7e361deb346c5117c2ff79b5e39ac3bc2 02-Jul-2010 Steve Howard <showard@google.com> am f674f312: am 23357198: Stub out the system clock in the download manager, add tests

Merge commit 'f674f3120a2e26dc3844211f0c9e1b5ad0478c5b'

* commit 'f674f3120a2e26dc3844211f0c9e1b5ad0478c5b':
Stub out the system clock in the download manager, add tests
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
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/RealSystemFacade.java
om/android/providers/downloads/SystemFacade.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
om/android/providers/downloads/DownloadThread.java
9c8e16f85d14ef4d5d55242a24a454ff549bc1f0 13-May-2010 Jeff Hamilton <jham@android.com> Stop using private APIs that are going away.

Change-Id: Ic675d13e70e8e18af44d71b590f4782559966396
om/android/providers/downloads/DownloadProvider.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
om/android/providers/downloads/DownloadThread.java
e7a7c7abf4ba5a2a5867205d75ad441e3996ee7d 25-Feb-2010 Dianne Hackborn <hackbod@google.com> Update to reflect android-common no longer in framework.
om/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.
om/android/providers/downloads/DownloadThread.java
6b9789795ced7bf05e2c592c8445722df500e279 10-Feb-2010 Per Edelberg <per.edelberg.x@sonyericsson.com> Show correct date for downloads in the statusbar

The date was not set properly in notifications when the text for
expanded view was created.

This fix sets the displayed time to the download time for each
individual file. The DownloadProvider recreates the notifications
several times but don't set the time before the expanded message
is created. The expanded message will therefore display the time
the notification was created and not the time a file was downloaded.
The displayed time will in most case be the time when the last file
was downloaded. This fix sets the displayed time to the downloaded
time for each individual file.
om/android/providers/downloads/DownloadNotification.java
a2028ed4141075da8199ba04a499be77734a85ae 28-Jan-2010 Leon Scroggins <scroggo@google.com> Create a new permission that allows apps to see downloads from other
applications to the SD card.

Necessary for http://b/issue?id=2384554

Also create names for files by default, so they do not display as
<Untitled>. Remove calls to createTitleFromFilename, which are
no longer necessary.

Requires a change to frameworks/base.
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
91e4522fa90d969a596058756c24e173df1a6196 26-Jan-2010 Suchi Amalapurapu <asuchitra@google.com> Grant access to downloaded packages to default container.
The package name is hardcoded for now but will eventually move to a separate gid
guarded by a permission.
om/android/providers/downloads/DownloadProvider.java
b3e1aaf3a330472114c9fe7c4d2c38ced5861370 26-Jan-2010 Attila Bodis <attila@google.com> b/2383073 Use new fine-grained download status codes.

Takes advantage of two new download status codes (STATUS_DEVICE_NOT_FOUND_ERROR
and STATUS_INSUFFICIENT_SPACE_ERROR) when reporting failed download attempts.
om/android/providers/downloads/Helpers.java
581abbbbeba49e64219e5f11f8a8474760a2f902 22-Jan-2010 Leon Scroggins <scroggo@google.com> Revert "Download files even if there is no activity to launch them."

This reverts commit 0f1aae327a9e4c68044d767e9bafbac747b6d985.

I misunderstood the bug. We do not want to be able to download
files for which there is currently no Activity to launch them.
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/Helpers.java
4d3a380d338b1f6ee120fb9de2001f138be398ff 21-Jan-2010 Leon Scroggins <scroggo@google.com> Update the title of the download based on the filename.

Now that the downloads page is not necessarily opened when a download
starts, we need to provide a name even if the downloads page isn't
shown. So when we create a notification, provide the title.

Depends on a change to frameworks/base
om/android/providers/downloads/DownloadNotification.java
0f1aae327a9e4c68044d767e9bafbac747b6d985 21-Jan-2010 Leon Scroggins <scroggo@google.com> Download files even if there is no activity to launch them.

Fixes http://b/issue?id=2367247
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/Helpers.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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
dc0accaaa66cdd7321505a8c42504b05a98ae341 14-Dec-2009 Paul Westbrook <pwestbro@google.com> Changed class paths for classes moved in unbundling effort
om/android/providers/downloads/DownloadThread.java
18c3040260907472a9e471e5707a5b2f8320d074 02-Nov-2009 Lixin Yue <L.X.YUE@motorola.com> Fix Download application notification timestamp not correct issue

Should set the value of Notification.when before calling
setLatestEventInfo(). On downloading an image without
exif information, the received file's timestamp is correct for main database field
but incorrect for temporary display field.

Root cause is that if Notification.when not set before calling setLatestEventInfo(),
the timestamp value in milliseconds unit will be directly set to a field as second
unit. Thus database will record the time as 1000 times forward as 2067, etc.
However from UI the file's time will be just shown like "10/10/67", misleading
people to think time is set backwards before system time 0(1969).
om/android/providers/downloads/DownloadNotification.java
cf79a11f9fee88daf48aa71b1d521fc5e07bf839 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadFileInfo.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
c04b1a0c79631ed8804475a1c4b144686bfaab15 24-Sep-2009 Jean-Baptiste Queru <jbq@google.com> Disable unnecessary logging

BUG=2134410
om/android/providers/downloads/Constants.java
4a977a52c3eb3ac08b94b81aef72fb618be39f81 24-Sep-2009 Jean-Baptiste Queru <jbq@google.com> Re-use the same random value to compute a download's restart time.

The restart time is used multiple times during the same pass,
and it needs to be consistent across calls. Otherwise, it's
possible for a download to not be restarted immediately and
to not be scheduled for a future restart.

BUG=2055624
om/android/providers/downloads/DownloadInfo.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
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
764844ebbb788cdde731abbacc89b9afcab8b49f 23-Sep-2009 Jean-Baptiste Queru <jbq@google.com> Log the service being launched

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

BUG=2055624
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/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
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadThread.java
5b8355b38197dbfe22e1b034950c4cb635a058f5 15-Jul-2009 Jean-Baptiste Queru <jbq@google.com> am d3403254: Enable full logging (for easier debugging)

Merge commit 'd3403254c3a290b6a68804c36c6876cb3787ec15'

* commit 'd3403254c3a290b6a68804c36c6876cb3787ec15':
Enable full logging (for easier debugging)
d3403254c3a290b6a68804c36c6876cb3787ec15 15-Jul-2009 Jean-Baptiste Queru <jbq@google.com> Enable full logging (for easier debugging)

See http://b/1973844
om/android/providers/downloads/Constants.java
4ed4c65f46f5d077bb40f82e7a4821bd47217fdd 06-Jul-2009 Jean-Baptiste Queru <jbq@google.com> Merge commit 'f0fa1cdc' into manualmerge

Fix crash in discardPurgeableFiles with proper selection syntax.

The basic crash is that this codepath was doing a query to the download
provider without properly quoting its selection arguments (which is
mandated by the download provider).

A secondary crash is that the DESTINATION column wasn't readable.

This fixes bug 1941125.

Tested by force-calling discardPurgeableFiles for each download
to /cache, locally adding a few debugging statements to be sure
that the codepath was getting executed, and doing a market download.

Conflicts:
src/com/android/providers/downloads/DownloadProvider.java
src/com/android/providers/downloads/Helpers.java
f0fa1cdc1a36cbe0abd57ef9cf9a636fd1d3e2c8 02-Jul-2009 Jean-Baptiste Queru <jbq@google.com> Fix crash in discardPurgeableFiles with proper selection syntax.

The basic crash is that this codepath was doing a query to the download
provider without properly quoting its selection arguments (which is
mandated by the download provider).

A secondary crash is that the DESTINATION column wasn't readable.

This fixes bug 1941125.

Tested by force-calling discardPurgeableFiles for each download
to /cache, locally adding a few debugging statements to be sure
that the codepath was getting executed, and doing a market download.
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/Helpers.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
496f051b28759df3d55afd6d617b5e65468b87e3 25-Mar-2009 Feng Qian <> Automated import from //branches/donutburger/...@140733,140733
om/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
om/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
om/android/providers/downloads/DownloadThread.java
977d38d21876fbc39598ff0a966a27db92ee1d59 18-Mar-2009 Jean-Baptiste Queru <jbq@google.com> Merge commit 'remotes/korg/cupcake' into merge

Conflicts:
docs/index.html
src/com/android/providers/downloads/DownloadProvider.java
src/com/android/providers/downloads/DownloadService.java
2dd83ce992eaaf3d44c32bc7468b47e3db014027 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadFileInfo.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
1edb39f280d23b3a87db45b63c2f26850d68eafe 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadFileInfo.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
f8e520e6b7ba9533117d4805a29fb7321534d6ce 28-Feb-2009 Jean-Baptiste Queru <jbq@google.com> Make the DownloadProvider work in the simulator
om/android/providers/downloads/DownloadProvider.java
da4093923903a53273c7ba86daaa5af0d1cf3d97 28-Feb-2009 Jean-Baptiste Queru <jbq@google.com> Optimize call to queryIntentActivities()

Replace a call to queryIntentActivities() with a calls to
resolveActivity(). This is done since the only purpose of the call
is to check if the returned list is empty or non-empty. It's
inefficient to move an entire list across the process boundary,
only to discard it.
om/android/providers/downloads/Helpers.java
c2fb15f7689a10c7fe3b6c1f1ed0ce1f5a95ba9b 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/Helpers.java
eaeda874c62a0ebc439894858e110160b7e2a212 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
om/android/providers/downloads/DownloadProvider.java
ce8813afb256269e9e223f72ebced92560201bbb 06-Feb-2009 Jean-Baptiste Queru <jbq@google.com> Refine interaction between destination and default visibility.

The previous code was hard to read, and relied on the fact that one of
the constants was 0 (which is also the default value when reading
back uninitialized columns).
om/android/providers/downloads/DownloadProvider.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.
om/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
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.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.
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadFileInfo.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
1fbad9cfa532f13f6cf03f542febf2e4689edec5 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java
57f55b3cb4f7e4136cde8d1ea12c1e70ec903362 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
om/android/providers/downloads/Constants.java
om/android/providers/downloads/DownloadFileInfo.java
om/android/providers/downloads/DownloadInfo.java
om/android/providers/downloads/DownloadNotification.java
om/android/providers/downloads/DownloadProvider.java
om/android/providers/downloads/DownloadReceiver.java
om/android/providers/downloads/DownloadService.java
om/android/providers/downloads/DownloadThread.java
om/android/providers/downloads/Helpers.java