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
MediaProvider: MediaScanner behavior on boot (2/3)

Lets you enable/disable/ask (with a notification) media scanning on boot.
Can speed up boot and reduce initial boot lag from MediaScanner
Skip albumart when the size of image file bigger than maximal heap size.

When the audio doesn't contain embedded art, MediaProvider
will help to look for a suitable image file in the same
directory as the media file, excpet if that directory is
the root directory of the sd card or download directory.

MediaProvider looks for, in order of preference:
 1 AlbumArt.jpg
 2 AlbumArt*Large.jpg
 3 Any other jpg image with 'albumart' anywhere in the name
 4 Any other jpg image
 5 any other png image

If we put a image file and a audio file in same directory of
sdcard, and the size of a image should large than maximal heap size.
It will cause hte process android.process.media stop because OOM.
As a result, we need catch OutOfMemoryError exception to avoid this issue.

Change-Id: I4131188b4b75454f5bdb20c50b930ff8b7a370fa

Change-Id: I4131188b4b75454f5bdb20c50b930ff8b7a370fa
Merge "Skip albumart when the size of image file bigger than maximal heap size."
Merge "Avoid multiple extraction of thumbnails"
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>
Merge "Fix possible deadlock in media provider"
avoid SQLiteConstraintException in MediaProvider when external storage ejected

When external storage is ejected, the _data column is updated with empty string.
Then, SQLiteConstraintException occurs because the _data column is modified to be unique.
So, to avoid SQLiteConstraintException, the _data column should be updated with NULL.

Change-Id: I2b00b5327c37f584970261789c5462626a5a4ea7
Merge "avoid SQLiteConstraintException in MediaProvider when external storage ejected"
Merge remote-tracking branch 'android/master'