AudioService : Fix NPE

Initialize mVolumePanel prior to registering the receiver,
since 4.3 now invokes the layoutDirection call on it.

Change-Id: I8d00f0886b603d52bc55cba5fd3ba1d86f7ea56c
Prevent audio players starting on startup.

Previously, (at least) Apollo was started on startup (in that it
appeared in the notification bar) because it listens to the AUDIO_BECOMING_NOISY
intent to silence itself in that case. This intent is broadcast by
AudioService when there's a user switch to silence any potential audio
players for the old user. As the system also sends around a
USER_SWITCHED intent on startup, this led to the aforementioned player
startup.
As the intent of AudioService was to act on a user backgrounding anyway,
send out AUDIO_BECOMING_NOISY as reaction to a USER_BACKGROUND intent
instead of the USER_SWITCHED intent.

Change-Id: Iba35844a1274c9dd195f104068304e6a7ffa809e
Fix resource leak: When call MediaMetadataRetriever.setDataSource or getFrameAtTime should ensure call release in finally to avoid resource leak
                   Patch set 2: Remove unnecessary white spaces

Change-Id: I49a7f2fb99dc8b9560e7c17421125356e45a87ac
Remove unnecessary updateSurfaceScreenOn call.

This change stops updateSurfaceScreenOn() from being called one time
right after another. It's called at the end of stayAwake(boolean awake),
which is called right before updateSurfaceScreenOn() in release().
media: Configure audio encode parameters only for valid audio codec.

Added extra check for audio codec in profile
(Cherrypicked from commit eed39d0053dee6649424867418e511b918b3c634)

Change-Id: Ie1ac5252e3d544ce61af2b3ae5080ec9c6966e44
(cherry picked from commit 81dfde16ffb3fc8f6b110a3df2921a3d3361db10)
(cherry picked from commit 8069457a313853247f2017237e29bcf3b3eb2323)
(cherry picked from commit db4bf86a6b50ce84b5a678476ee08c12f0fe272b)
Bluetooth: Changes to support AVRCP 1.5

Provide support for AVRCP1.5 so that remote controller
is able to browse the list of available media players
on DUT and select the media player from the available
list of players, from remote.

Change-Id: Ia1a340d1efaa16091e684f6ff7c738ce0accaee3
(cherry picked from commit 22af77236fccc546c6bec3956b0027fc1642ba1c)
(cherry picked from commit c9bc05d824197921a44d862026b3bc352d0f6a27)
(cherry picked from commit 3fad1502e08b9ccc7ecfd3f35be4b38190d9aa81)
audio: Fix for LPCM surround sound recording

 - Format WAVE was defined as 10, which is getting
 over-ridden by format THREE_GPP2 (which holds value 10),
 because of which Media recorder failed for LPCM SSR.
 - Fix this by defining format WAVE to 11.

Change-Id: I4db84441b70b28da3579e2ff430b42b2711f9404
audio: Fix for volume level mismatch for AVRCP headset

-The volume level sent to AVRCP module from AudioService
 is incorrect.
-The volume level need to scale down for AVRCP module.
-Divide volume level by 10 to match AVRCP module volume
 levels.

Change-Id: Ieb8146797d0b552311b1a4782c45aea1be73e492
CRs-Fixed: 561649
Rework thumbnail handling

Since ids of media file are usually not continuous, the original file of thumbnail are
sparse. When there are big numbers files on ex\
ternal storage, the size of this file will be horrible.
Ex, when the id is 20000, then the .thumbnails/.thumbdata3-xx file will be 50000*10k = 488.28M.
Can refer http://stackoverflow.com/questions/12396715/android-huge-thumbdata4-file-in-dcim-folder
Because after 4.0, MediaProvider will scan any files, this will be a big problem. So I modify MiniThumbFile.java to avoid this.
According to the id, we now produce an index file. In this index file, one id will use BYTES_PER_MINTHUMB_INDEX(8) bytes in offset (i\
d+1)*BYTES_PER_MINTHUMB_INDEX. The data of these 8 bytes is the index of thumbnail file. The first BYTES_PER_MINTHUMB_INDEX bytes kee\
p next available index. And when you need insert a thumbnail, the index increase by 1. In this way, the block data in thumbnail file \
will be continuous. And thus unnecessary zero paddings will not be saved.

Change-Id: I66005dd69b0a5c8f4353bd7a8225d163a654fd2d
MiniThumbFile: Fix image/bitmap retrieval

Change I66005dd69b0a5c8f4353bd7a8225d163a654fd2d changed the insertion
and creation indexing mechanism, but the retrieval method was still
using the old sparse one. Fixit

Fixes android.provider.cts.MediaStore_Images_MediaTest#testInsertImageWithBitmap,
android.provider.cts.MediaStore_Images_MediaTest#testInsertImageWithImagePath,
android.provider.cts.MediaStore_Images_ThumbnailsTest#testQueryExternalMiniThumbnails,
and android.provider.cts.MediaStore_Video_ThumbnailsTest#testGetThumbnail

Change-Id: I41feea79fa304635f3908055fb95a8c85718a97f