Fix bug with deciding when to restart a download.
authorSteve Howard <showard@google.com>
Tue, 20 Jul 2010 19:04:02 +0000 (12:04 -0700)
committerSteve Howard <showard@google.com>
Tue, 20 Jul 2010 19:04:02 +0000 (12:04 -0700)
commit5180de23e77139dd6971dfd48269242e3e3562d9
treeebcf27563c2eb44e821437b459f99f3b150e1454
parent071bd7acb3185f4f1e807855605c5e6018e9742f
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
src/com/android/providers/downloads/DownloadInfo.java
src/com/android/providers/downloads/DownloadService.java
tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java