Fix race conditions around filename claiming.
authorJeff Sharkey <jsharkey@android.com>
Fri, 1 Mar 2013 19:18:38 +0000 (11:18 -0800)
committerJeff Sharkey <jsharkey@android.com>
Fri, 1 Mar 2013 19:18:40 +0000 (11:18 -0800)
commit5ba69740a47857fcebd36866e07963ba798269d5
tree676f2501844882633a9b9f14324397cb8a8411c8
parent80a535d83ea9ed21f443fdc701c743569ae53eec
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
src/com/android/providers/downloads/Helpers.java
tests/src/com/android/providers/downloads/ThreadingTest.java