History log of /packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
3a5f5eafb34eaa4963c801882148e8f61514a61b 21-Apr-2016 Jeff Sharkey <jsharkey@android.com> Move DownloadManager to use JobScheduler.

JobScheduler is in a much better position to coordinate tasks across
the platform to optimize battery and RAM usage. This change removes
a bunch of manual scheduling logic by representing each download as
a separate job with relevant scheduling constraints. Requested
network types, retry backoff timing, and newly added charging and
idle constraints are plumbed through as job parameters.

When a job times out, we halt the download and schedule it to resume
later. The majority of downloads should have ETag values to enable
resuming like this.

Remove local wakelocks, since the platform now acquires and blames
our jobs on the requesting app.

When an active download is pushing updates to the database, check for
both paused and cancelled state to quickly halt an ongoing download.

Shift DownloadNotifier to update directly based on a Cursor, since we
no longer have the overhead of fully-parsed DownloadInfo objects.

Unify a handful of worker threads into a single shared thread.

Remove legacy "large download" activity that was thrown in the face
of the user; the UX best-practice is to go through notification, and
update that dialog to let the user override and continue if under
the hard limit.

Bug: 28098882, 26571724
Change-Id: I33ebe59b3c2ea9c89ec526f70b1950c734abc4a7
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.java
dffbb9c4567e9d29d19964a83129e38dceab7055 31-Jan-2014 Jeff Sharkey <jsharkey@android.com> Many improvements to download storage management.

Change all data transfer to occur through FileDescriptors instead of
relying on local files. This paves the way for downloading directly
to content:// Uris in the future.

Rewrite storage management logic to preflight download when size is
known. If enough space is found, immediately reserve the space with
fallocate(), advising the kernel block allocator to try giving us a
contiguous block regions to reduce fragmentation. When preflighting
on internal storage or emulated external storage, ask PackageManager
to clear private app caches to free up space.

Since we fallocate() the entire file, use the database as the source
of truth for resume locations, which requires that we fsync() before
each database update.

Store in-progress downloads in separate directories to keep the OS
from deleting out from under us. Clean up filename generation logic
to break ties in this new dual-directory case.

Clearer enforcement of successful download preconditions around
content lengths and ETags. Move all database field mutations to
clearer DownloadInfoDelta object, and write back through single
code path.

Catch and log uncaught exceptions from DownloadThread. Tests to
verify new storage behaviors. Fixed existing test to reflect correct
RFC behavior.

Bug: 5287571, 3213677, 12663412
Change-Id: I6bb905eca7c7d1a6bc88df3db28b65d70f660221
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.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
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.java
58eee87b70862a7ced85eabc3c225fad24664065 29-Jan-2013 Jeff Sharkey <jsharkey@android.com> Tests for max retries/redirects, ETag switches.

Verify that servers responding with many retries or redirects result
in failed download, instead of spinning out of control. Test to
verify that changed ETag results in download failing.

Also fix handling of HTTP 301 to update Uri in database.

Change-Id: Iff2948d79961a245b7900117d107edaa356618c9
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.java
8ac10e0e0667a4fe35191deebb5fa9786bf4226c 04-Jan-2013 Jeff Sharkey <jsharkey@android.com> Clean up DownloadManager threading tests.

Change runUntilStatus() methods to polling with timeout instead of
requiring internal knowledge about threading.

Fix notification tests, and move opening of InputStream until after
handling headers to avoid FNFE. Always reset facade to defaults
before each test.

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

Bug: 4726601
Change-Id: Ibe537bd5c2a092dbf974360cd454751881f7f4ea
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.java
a1448628237471a7a2aeb67b560b1502c2bd5ba8 28-Sep-2010 Steve Howard <showard@google.com> Manual merge: Moved DownloadManager to android.app

Change-Id: Id1de44459ec1bf53e928cae826047467b355823d
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.java
e6a05a1aa4697440e9630d12b741b3bae321fe49 27-Jul-2010 Steve Howard <showard@google.com> Serialize threading for download manager testing.

The download manager uses threading in a simple way -- it launches two
threads, UpdateThread and DownloadThread, and both are "fire and
forget". This is fortunate for testing, since it means we can
eliminate multithreading and simply run each thread in order, and
everything still works.

This change does just that, abstracting Thread.start() behind
SystemFacade and making FakeSystemFacade put new threads into a queue
and then run through them serially. This simplifies much of the test
code and makes it all much more predictable.

I've simplified the test code as much as possible here and moved a few
more tests over to PublicApiFunctionalTest, leaving only a minimum in
DownloadManagerFunctionalTest, which will eventually be deleted
altogether. I've also improved testing in some areas -- for example,
we can now test that running notifications get cancelled after the
download completes in a robust way.

There is one test case that checks for race conditions and requires
multithreading. I've moved this into a new ThreadingTest class, which
uses a custom FakeSystemFacade that allows multithreading. I've
extracted AbstractPublicApiTest for the newly shared code.

Change-Id: Ic1d5c76bfa9913fe053174c3d8b516790ca8b25f
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/ThreadingTest.java