Avoid multiple extraction of thumbnails

When inserting a new memory card containing images, or taking a camera
picture, several requests for a thumbnail for the same picture are made.
At the time the requests are made, no thumbnail exists, so each of the
requests result in the full image being decoded and encoded to a
thumbnail, an operation taking about 100ms per thumbnail. Fixing this
cuts times for image thumbnails in half. Also improves Camera
shot-to-shot times.

When a thumbnail request is completed, scan the queue for identical
requests, and update those requests to avoid having to decode the same
image several times.

Change-Id: I53d720779925de882b0e2f080b0b87ec318e08a9
am 0e3b0e89: (-s ours) Merge "Import translations. DO NOT MERGE" into klp-dev

* commit '0e3b0e899fdf0ca2fe2e87ae701ebce6183b42ae':
  Import translations. DO NOT MERGE
am f89e9bc7: (-s ours) Import translations. DO NOT MERGE

* commit 'f89e9bc71e5790b2cbe680a91bd77473fab7d59a':
  Import translations. DO NOT MERGE
am 2e1179c4: (-s ours) Import translations. DO NOT MERGE

* commit '2e1179c424ac1b97fa40bfd74a3684685998dd02':
  Import translations. DO NOT MERGE
am 9d3d6827: Merge "Publish thumbnails for image buckets." into klp-dev

* commit '9d3d682754043c09c0b99f9535cd6154d2f32f92':
  Publish thumbnails for image buckets.
am 3e6a4288: Check for path-permissions when opening a file.

* commit '3e6a42887a17a93b8906ff05693587e25158f2b1':
  Check for path-permissions when opening a file.
am 7de35fed: (-s ours) Merge "Import translations. DO NOT MERGE" into klp-dev

* commit '7de35fed1ca2e6642dcedef7cdf7df2e33374d4c':
  Import translations. DO NOT MERGE
am 22ef7920: Merge "Fix up path from scan file intent before scanning" into klp-dev

* commit '22ef79205b96f48e7e9b56ed7232d08710fa3a6f':
  Fix up path from scan file intent before scanning
am 885c9ee2: Merge "Follow stronger DocumentsProvider contract." into klp-dev

* commit '885c9ee2bb76c4a1b0b139b301797d55a4178c73':
  Follow stronger DocumentsProvider contract.
am f93ada13: (-s ours) Merge "Import translations. DO NOT MERGE" into klp-dev

* commit 'f93ada13ec0f01ddee3f76d38a617fd3f49f6375':
  Import translations. DO NOT MERGE
am 716368c8: Merge "Follow refactoring of DocumentsContract." into klp-dev

* commit '716368c85ae14a5f821421a52c5eba50b28304cc':
  Follow refactoring of DocumentsContract.
am 6142b201: Merge "New recent documents behavior." into klp-dev

* commit '6142b201ef9d0876dda28ec87680b4dc20ef49ce':
  New recent documents behavior.
Merge "Avoid multiple extraction of thumbnails"
am 41d19e54: Merge "Avoid multiple extraction of thumbnails"

* commit '41d19e5490a7502ba5847d41a596527345e0c057':
  Avoid multiple extraction of thumbnails
am aa4a824f: am 41d19e54: Merge "Avoid multiple extraction of thumbnails"

* commit 'aa4a824f247856532342d111bd8af57cf768f555':
  Avoid multiple extraction of thumbnails
am 4f1a0108: Merge "Check permissions when deleting files." into klp-dev

* commit '4f1a01080324669d64fbb94282f07e60a627bc62':
  Check permissions when deleting files.
am 03273a91: (-s ours) Merge "Import translations. DO NOT MERGE" into klp-dev

* commit '03273a910622108ead53d3f07ec48a3bd10c1e99':
  Import translations. DO NOT MERGE
Fix possible deadlock in media provider

Because of the execution sequences below,
receiving ACTION_MEDIA_EJECT intent during bulk inserting
can lead to media provider deadlock.

bulkInsert()
-> db.beginTransaction()
-> insertInternal()
-> getDatabaseForUri()
-> synchronized(mDatabases)

mUnmountReceiver.onReceive()
-> synchronized(mDatabases)
-> db.update()

beginTransaction() blocks any other operations on the database
until endTransaction() is called.
Therefore, db.update() method can be blocked in the synchronized block
and bulk inserting also can be blocked simultaneously to enter
the synchronized block.

This patch resolves the problem above by restricting the scope
of the synchronized block in mUnmountReceiver.

Change-Id: Ibb65ac82ea389145a6a3e44942928b7548c53b22
Signed-off-by: Sangkyu Lee <sk82.lee@lge.com>
am dba66f24: Merge "Advertise supported MIME types." into klp-dev

* commit 'dba66f242de7aa1c13b55da9790cbf3c0f59a7ae':
  Advertise supported MIME types.
am cf88e9a9: Merge "Relay content change notifications to documents." into klp-dev

* commit 'cf88e9a9b8df520c53f7192df0aa0661a1058a26':
  Relay content change notifications to documents.