SamsumgCDMAQualcommRIL: 'Phantom Ringtone' Fix

Import the fix from SamsungRIL to fix the 'Phantom ringtone' (or 'Ring of Death').
See source for comments about the fix.

Change-Id: I0da6586e6a5b47abc9a7ceba45c4c71a5c9052f6
libstagefright: Enable hardware thumbnail generation

Hardware video decoder will be used to generate
thumbnails if the software decoder fails.

- Enabled for 8660 and 8960
- Add property to disable use of sw decoders for thumbnail creation
- Additional debug logs in metadata retriever

Change-Id: I249d7be146b5d07468826f28f7843a208ed39c1b
libstagefright: Add HW thumbnail support for 8x55.

 Adding changes to support HW Thumbnail generation for 8x55
target.

Change-Id: If43ff1cd7764407890a86c555f3baebec8e99ae4
libstagefright: use hw codec only for thumbnail mode

     - Makes sure StagefrightMetadataRetriever use hw only codecs
       for thumbnail mode.
     - In cases where hw codec fails and exits without fully starting
       SFMetadataRetriever may allocate sw codecs further down the
       list
     - Attempting to start thumbnail mode for SW codecs will result
       in assertion fail

Change-Id: I6190d8c3190703ead44d20f4a988110fdb549ec7
(cherry picked from commit 798e5085870ed79764324fb9b22b0b1cfeeead7e)
libstagefright: Software decoder is the first choice for thumbnail generation

Set the flag to use software decoder only for the
first call to extract video thumbnail.

Change-Id: I09b3b3da5bfe57f21b0fecfbcc5aff7337bb91a2
CRs-Fixed: 323190
StagefrightMetadataRetriever - fixed source start assertion failure on MPEG4Source

 - OMXCodec calls start on MPEG4Source
 - in occasional cases during thumbnail generation when buffers cannot be allocated
   by OMXCodec, init() will fail along with start() with MPEG4Source still started.
   StagefrightMetadataRetriever will then attempt to start OMXCodec again which calls
   start on MPEG4Source, causing mStarted assertion failure in MPEG4Source start()
 - this patch calls stop on MPEG4Source in case when decoder->start() fails by calling
   destructor of MPEG4Source (which stops the source safely) and remaking the source
   using the getTrack() call in Extractor

CRs-Fixed: 326063, 325461, 323538
Change-Id: Ib16444f6d3a0589fdb26e79d8323ae1edf90a5a1
StagefrightMetadataRetriever: use cm platform naming

Change-Id: I8bd00396c6ba34237a4b6217e8a37f62a331df9d
frameworks/base: Handle Out of Memory Exception when creating video thumbnails.

Adds code to handle an out of memory exception when generating the thumbnail
from a recently recorded video clip.

Change-Id: Ifcbe007272ffef85744fca1414ea5eacccd0154c
CRs-Fixed: 277571
libstagefright: Fixing a crash in EOS for thumbnail generation.

Initializing an uninitialized variable and fixing
a crash. At EOS OMXCodec::read was returning OK and
a NULL buffer. This is not a valid return combination
as client expects buffer to be non-NULL when there
is no error. With this change OMXCodec::read
will return ERROR_END_OF_STREAM with a NULL buffer
which is a valid return combination. This change
is specific to hardware thumbnail generation.

Change-Id: I83ebdc69e2195b903ea652cb46bf91df48457eec
libstagefright: fix thumbnails for videos with non multiple of 4 width

- videos with width not a multiple of 4 will fail thumbnail
  generation
- this fix changes the dest width in converter routine to the
  rounded up nearest multiple of 4
- this fix will not impact already working videos as they are
  already at the nearest multiple of 4 in width

(cherry picked from commit 18720176cbd6b1817b1396e1c7768ce6f44db910)

Change-Id: I104c2f26706876c5314304508f87a8e35b6d4659
Crs-Fixed: 331371
libstagefright: Fix RGB565 buffer width calculation for thumbnail generation

- The width of the RGB565 output buffer is aligned to 4 to
  match the input requirements of the Tile4x2 to RGB565 color
  convertor.
- This extra padding is unnecessary for other color conversions
  (e.g. OMX_COLOR_FormatYUV420Planar, OMX_COLOR_FormatCbYCrY to RGB565).
- This fix restricts aligned output buffer width to some color formats.

Change-Id: I4dd78143b950f793d74499220d9aaf88656e87f2
CRs-Fixed: 346285
(cherry picked from commit eecec1238bb76f5a10b3732f226b06935ff57f08)
libstagefright: Set key mimetype for audio only ASF clips

- Parse function used while scanning the media information is
  not able to get the proper mimetype for ASF clips. Since
  ASF clips are considered as video clips by default based on
  the file extention audio only clips are also visible in
  video application and not in music application.
- Key Mimetype is not updated for ASF clips and retriever
  return mimetype as NULL.
- Check the track information for single track ASF clips and
  set key mimetype to wma for audio only clips so that parse
  function can detect them as audio clips while scanning.

Change-Id: I96857efbd65b77658b4b5ca02c21a2be718d4ab5
CRs-Fixed: 280999
frameworks/base: Fix for AAC clip with 3gp extension not detected as audio file

- Clip which has AAC audio data but with .3gp extension is not
  detected as audio file and shown as video file.

- MIMETYPE for audio only 3GPP is set to video/3gpp and hence shown
  as video clip.

- MIMETYPE for AAC audio clip with .3gpp extension is set to audio/aac
  to detect it as audio file.

CRs-Fixed: 337692
(cherry picked from commit dca241864a8af8c9edfa4b62f93c2052d5fca40a)

Change-Id: Icbb9b9ec9cb231be2208be2c2ceb12700f49d83d
libstagefright: Fix memory leak in video playback start failure

Output buffers are not freed when video playback fails
when starting playback, causing a memory leak.

In the case of a codec initialization failure, we now make
sure that the omx component is properly transitioned to
loaded state and that the buffers are freed.

CRs-Fixed: 360964
(cherry picked from commit 37fa976da8bbeff3d5edf55785224b1c389154d5)

Change-Id: I9a0efe80564a3fca1847f5e5c08b671fa78927af
ligstagefright: New flag GRALLOC_USAGE_PRIVATE_CP_BUFFER used for securing buffers.

GRALLOC_USAGE_PROTECTED is being used by Surface flinger for protecting screen
shot. For WV L3 secure buffers are not being used, so we need a different flag
to set use or not use secure buffers.

CRs-fixed: 348454
(cherry picked from commit 01c5d8e96c91905a7e9b3b7d36c81fd7ff103b24)

Change-Id: I71db905661b4d360a96853768dac8dc0c557346d
OMXCodec: Introducing a property to switch to hardware aac decoder.

New property enable testing of hardware aac codec through Music Player
if the default codec for aac is software based.

(cherry picked from commit 232cefbd5a1c98c80d793e7658ac347deeb605d6)

Change-Id: I6b08b5da3a71e23afdaa09d787ad05a0e4166811
libstagefright: Broadcasts intent for the start and end of secure playback.

Broadcasts intent for start and end of secure
playback so that other services (Wifi-Display)
can find out whether secure or non-secure
session is going on.

Change-Id: I1179ba92851da4628068ede41fa139c5ceefa912
libstagefright: Add display intents for secure session

CRs-Fixed: 367096
Change-Id: Idfa1729bccd4a18d66388ac038d8eecec365b1dc
libstagefright: Enable hardware decoder for mp3

Enable hardware decoder for mp3 audio format

Change-Id: I8c4fcc14dbfa5748db5ba9e93b1dc16565abee5f
libstagefright: Enable HW decoder for AAC playback

-Enable HW decoder for aac clip except adif and ltp
 for 7627 and 7627a target
-Enable SW decoder for adif and ltp clips.

Change-Id: Idf3cb58f38e55806a1279e232684b8b1ba07e1c8