Fix deletion of least-recently-used external databases.

The present external database LRU garbage collector mistakenly includes
SQLite temporary files, including those associated with the internal
database, as distinct external databases.  This leads to a number of
problems, including partial deletion of databases and/or their temporary
files and early deletion of databases before the MAX_EXTERNAL_DATABASES
limit is reached.  In short, the present code works only, and
coincidentally, in a single circumstance: when there is an internal
database and _exactly one_ external database.

This fixes the above problem by removing SQLite temporary files from the
list of candidate databases.

Note, the actual bug here is in the android.app.ContextImpl::databaseList
method, which return SQLite temporary files as part of a context's
"database list" instead of hiding them and handling their deletion
internally.  However, since these methods are part of the Android public
API and used by third-party apps, the present fix is implemented in
MediaProvider only.  Should the Context database API be altered, this fix
will be made redundant but remain unharmful.

Change-Id: I222255babf02b437d9ab7109a5fb1396bd38a9dd
MediaScanner: Don't delete entries of secondary storage on shutdown

MediaScanner deletes the entries of secondary storage whenever it
is ejected by the user. However, a shutdown also sends this eject
events. This patch ignores the eject event if the system is being
shutdown.

Patch Set 2: Fix compile error

Change-Id: I0dfe4bd750c563e99b59ad6e9155b241c3228e0d
AlbumArt image of songs in the non-primary storage root dir are images in the same dir

MediaProvider will fall back to the image in the same folder of music,
if MetadataRetriver failed to extract the AlbumArt image from those mp3 files.
MediaProvider will only bypass the albumArt image search if the music located
in the root director of the primary external storage. Add this bypass for all
external storages.

Change-Id: I972586b2f92bd439f51ee932f09e824fc5507236
Signed-off-by: guoyin.chen <guoyin.chen@freescale.com>
Notify change of movePlaylistEntry after transaction ends

When a client asks the Media Provider to rearrange a playlist
the notifyChange callback function is called before the database
transaction is ended resulting in that listeners can't get the
new data when they get the callback.

notifyChange() is called before the database transaction is ended
resulting in that listeners can't get the new data when they get the
callback.

This fix will wait until the database transaction is finished
to do the callback.

Change-Id: Ifdfbb047b809bd5fba4752bcdd299927f9082eee
Column in log table is not unique

DATETIME was set as primary key but that value is not always unique.
This solution is to remove primary key constraint from column "time"
to avoid SQLiteConstraintException caused in case same DATETIME value
is attempted to be inserted into log table.

Change-Id: I06f1cd36a6f4f7becdb444599e4de7866813c9cd
Delete the code that does not use

Collator.getInstance() returns new Collator object.
But, new Collator object is not used in function.

Change-Id: Ie6ef4ecb5de8e47ac797aebed58fe5c8a0693cc0
Default ringtone cannot be previewed as alarm stream type.

When choosing a ringtone for alarm use by "Android System"
ringtone picker (RingtonePickerActivity), default ringtone is
not played for preview with volume of alarm stream type but
with that of normal stream type.

It is because stream type is not reflected on mDefaultRingtone
instance of RingtonePickerActivity.

Change-Id: Idc71c9b620e40e4109604b2337677134bb74a8cd
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

Change-Id: Iad0b72f8b653b3d567b27de3ccf5c6cfb07e40ed
Commit Iad0b72f8b653b3d567b27de3ccf5c6cfb07e40ed translated to Russian

Change-Id: I6ecfdab4f6a36cdd65f4b2ef191924a9cf079350
"isMediaDatabaseName" API has to return true only if a parameter is database file path.

But it check only prefix with 'external-'.
Media provider uses Write Ahead Logging that makes wal and shm files.
In case of wal and shm files, the API can also return true.
So additionally, the API has to confirm that the file path has '.db' extension.

Signed-off-by : kwangjung kim <kwangjung.kim@lge.com>

Change-Id: Ibc394ab5dac169b126bce58d9416d2196b1afe61
Fix logic that delete "-wal" file.

"databaseList()" method, All files in database folder are returned.
Such as "-wal" file, "-shm" file and so on.

In case of media provider, it uses WAL mode.
If "-wal" file is deleted, side effects appear to SQLITE_IOERR_SHORT_READ and user data is deleted.
Therefore, When deleting a database file, ".db" extension should be checked.

Signed-off-by : kwangjung kim <kwangjung.kim@lge.com>

Change-Id: Ie833d3990f1988929665d4c1b2ea77ad92bd2ded
Simplify DB query with "COLLATE nocase" instead of "LIKE" and "substr"

Nocase comparation with "LIKE" and "substr" DB query can be changed to
"COLLATE nocase" on SQLite.

Change-Id: I66e4e22758d1cf8fbb3e3e3eb3920576eb61d93d
Change titile from Ringtone to Notification sound

- check the ringtone type
- according to sound type, select the title

Change-Id: I5708bccb79733cb9720911270b5060d21a5fc1e2
Commit I5708bccb79733cb9720911270b5060d21a5fc1e2 translated to Russian

Change-Id: I8501b13d48f0162d1c897f69d60e954c17813d19
Merge remote-tracking branch 'slim/jb4.2' into jb-mr1-mod