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
libstagefright: Added suspend-resume support for 3D clips

On suspend-resume, 3D clips were not being detected as 3D and were being
played on 2D.  As we never send the frame with 3D SEI (typically the first
frame) on resume, it is necessary to store state in between.  Due to the
loss of the suspend-resume APIs in stagefright, mediaplayer can no longer
store state between s/r.  As a result, we have to make VideoView hold state.

This change sends a notification (MEDIA_INFO_3D_ATTRIBUTES)to the upper layer
with the appropriate 3D flags.  On resume, the upper layer is expected
to pass these flags back to stagefright via the setParameters call. This
in turn sets the appropriate key in metadata. In processSEI, if we
happen to see this key, we pass the value associated with the key to
NativeWindow.

CRs-Fixed: 355006
(cherry picked from commit 931ab52420061c10120d658058e9926e75f6338f)

Change-Id: I08f0c8fbf4febc6a6dbc1d2f4125b2d59fbb6e42

Conflicts:

	media/libstagefright/OMXCodec.cpp
libstagefright: dynamic port reconfig handling

- Add support for dynamic port reconfiguration handling in OMXCodec

Change-Id: I41747522e41d3e92fbacd9c457cb83ba9e46480e
CRs-Fixed: 331504, 351640
(cherry picked from commit 2ee46f4f2a3fcc1e0aa149b68be28c9a5ddbd082)
opengl/libs/EGL: mark software configs as non-conformant

CRs-fixed: 357894 351582
Change-Id: I5a38c5d1b3814abfa5cf0e9a02f650416bd72b80
SurfaceTextureClient : Reset buffer size to 0 after setting geometry

Buffer size has to be reset to 0 after setting geometry , otherwise
the new request may get the buffer with wrong size.

Change-Id: I4eff45023fbc5751aa98b5b573345c54ebd2abb4
CRs-Fixed: 337041
framework/base: Fix codenomicon image open fail

Add code to handle OutOfMemory exception.

CRs-Fixed: 333162

(cherrypicked from commit Ib9552bfa0d99da6ed395767a4db3ceb1a099c3a2)

Change-Id: Id9263c8ad96a2af0488a75e3a9ce67174c784ff4
Input: Fix some Applications ANR issue in monkey test

Issue Description:
When do monkey test on some applications, there is big probability get ANR issue. one example is as following:
    adb shell monkey -p com.google.android.street -v 500000

Root Cause:
situation 1. InputDispatcher Thread calls findTouchedWindowTargetsLocked routine, there is a AMOTION_EVENT_ACTION_DOWN event
             and it can find a splittable touched window for this event , then mTouchState.split set to true.

situation 2. WMS Thread calls setInputWindows routine and all TouchedWindows associated with mTouchState are removed ,
             mTouchState.split status still keep true.

situation 3. InputDispatcher Thread calls findTouchedWindowTargetsLocked routine, there is a AMOTION_EVENT_ACTION_POINTER_DOWN event
             and it can find found touched window, exit window loop in following code :
                  if (windowInfo->visible) {
                    if (! (flags & InputWindowInfo::FLAG_NOT_TOUCHABLE)) {
                        isTouchModal = (flags & (InputWindowInfo::FLAG_NOT_FOCUSABLE
                                | InputWindowInfo::FLAG_NOT_TOUCH_MODAL)) == 0;
                        if (isTouchModal || windowInfo->touchableRegionContainsPoint(x, y)) {
                            if (! screenWasOff
                                    || (flags & InputWindowInfo::FLAG_TOUCHABLE_WHEN_WAKING)) {
                                newTouchedWindowHandle = windowHandle;
                            }
                            break; // found touched window, exit window loop
                        }
                    }

situation 4. The following code will have problem after situation 3 in below conditions:
             newTouchedWindowHandle doesn't support split , isSplit is true ( last time touched window is splittable )
             mTempTouchState.getFirstForegroundWindowHandle will always return NULL due to situation 2

            // Figure out whether splitting will be allowed for this window.
            if (newTouchedWindowHandle != NULL
                    && newTouchedWindowHandle->getInfo()->supportsSplitTouch()) {
                // New window supports splitting.
                isSplit = true;
            } else if (isSplit) {
                // New window does not support splitting but we have already split events.
                // Assign the pointer to the first foreground window we find.
                // (May be NULL which is why we put this code block before the next check.)
                newTouchedWindowHandle = mTempTouchState.getFirstForegroundWindowHandle();
            }

            The window says it does not want to support splitting, so the touches should go to one of the previously split windows except
            that there are none, which result to "goto Unresponsive" in findtouchedWindowTargetsLocked routine.
            This is not the correct behavior because the user did actually touch something.

situation 5. InputDispatcher Thread will call dispatchOnce repeated to try to dispatch this AMOTION_EVENT_ACTION_POINTER_DOWN event,
             then ANR timeout ( 5000ms ) will be exceeded after several times "goto Unresponsive"in findtouchedWindowTargetsLocked routine.

Solution:
In situation 4 we should drop the touch. If the newly touched window was splittable then we wouldn't drop the touch.
It's only when the newly touched window was not splittable where we will drop the touch.

Change-Id: Iab2c06ce0597ac77eb886ccd9d84646c86723bdb
Author: Jeffrey Brown <jeffbrown@android.com>
Author: Erjun Ding <erjunx.ding@intel.com>
Author: Zhenghua Wang <zhenghua.wang@intel.com>
Author: Jack Ren <jack.ren@intel.com>
Author: Bruce Beare <bruce.j.beare@intel.com>

Conflicts:

	services/input/InputDispatcher.cpp
Revert "webkit: Reduce processing in WebCore thread while scrolling and zooming"

This reverts commit 5e89c08e3ea581a959cdf706d1b12321ecd19de2.
Revert changes I631ac720,I21421742,Icae49df0

This reverts commit 4edfed8dbafb9b785cc08a1f501db0332906763e.

Revert "BrowserManagement"

This reverts commit 0263109f7f83d78cd56024ebb116224229165991.

Revert "BrowserManagement"

This reverts commit 8489124ab3a92c7671d2ecbcf984559111fc94c6.

Change-Id: I962f98b06d25c9c93a10d3784a4dcbaf7d1506bd
frameworks/base: Enable LPA for music stream only.

Enable LPA playback for music streams only. There are no
significant power savings for using LPA with other modes like
ringtone.

CRs-Fixed: 357327

(cherry picked from commit 75484628e5a915422f822b9759cb3ce8f9c4f0ad)

Change-Id: Ibd3940f74bd6b0cf2446e1159640d39a107c2929