Redesign of DownloadManager update loop.
authorJeff Sharkey <jsharkey@android.com>
Tue, 12 Feb 2013 00:19:39 +0000 (16:19 -0800)
committerJeff Sharkey <jsharkey@android.com>
Wed, 13 Feb 2013 04:24:16 +0000 (20:24 -0800)
commit925976230936a5177365dc24b50da8607a9af8d4
tree0266d0edd90fbdb967f5450dfba5677da6fa2a9a
parent1ad10ce731d1b54692d7d5ee32601e965f503fa4
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
src/com/android/providers/downloads/DownloadInfo.java
src/com/android/providers/downloads/DownloadScanner.java [new file with mode: 0644]
src/com/android/providers/downloads/DownloadService.java
src/com/android/providers/downloads/DownloadThread.java
tests/Android.mk
tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
tests/src/com/android/providers/downloads/MockitoHelper.java [new file with mode: 0644]