Fix shutdown sequence to avoid SIGSEGV when running am command

When the app_process is shutting down the main thread will close the
binder fd while pool threads are executing an ioctl (in
IPCThreadState::stopProcess called by AppRuntime::onStarted in
app_main.c).

The binder driver will then return all pending calls in ioctl
without any error and with a command. One of the threads gets a
BR_SPAWN_LOOPER which will create a new thread (the other thread
gets a BR_NOOP). This new thread then calls
vm->AttachCurrentThread. Usually this results in a log entry with
"AndroidRuntime: NOTE: attach of thread 'Binder Thread #3' failed",
but sometimes it also causes a SIGSEGV. This depends on the timing
between the new thread an the main thread that calls DestroyJavaVM
(in AndroidRuntime::start).

If IPCThreadState.cpp is compiled with "#define LOG_NDEBUG 0" the
pool thread will loop and hit the
ALOG_ASSERT(mProcess->mDriverFD >= 0) in
IPCThreadState::talkWithDriver.

Crashes like this has been seen when running the am command and
other commands that use the app_process.

This fix makes sure that any command that is received when the driver
fd is closed are ignored and IPCThreadState::talkWithDriver instead
returns an error which will cause the pool thread to exit and detach
itself from the vm. A check to avoid calling ioctl to a fd with -1
was also added in IPCThreadState::threadDestructor.

Another solution might be to change the binder driver so that it
returns an error when the fd is closed (or atleast not a
BR_SPAWN_LOOPER command). It might also be possible to call exit(0)
which is done when System.exit(0) is called from java.

Change-Id: I3d1f0ff64896c44be2a5994b3a90f7a06d27f429
Fix error trap in SurfaceTexture Client

There was an issue in Surface::lock where failure to lock a surface
resulted in two bad things happening:
- success was returned to the caller (it was apparently locked).
- an uninitialised pointer was returned as the buffer.

Change-Id: I8b0df81400e0fa0542a8bb993d76923ac96b686e
libagl: Transform the vertex if using eye space lighting with point lights

This fixes lighting when using point lights, when eye space
lighting is used (which is the default).

Change-Id: I0cd0d2329893d6b5f8af3b1e595274c2076fc322
Fixed sample video corrupted in MediaCodec mode.

Change-Id: Ibe11a83199f3db1ba6266a1a9e11c7fc24ceb554
related-to-bug: 6732061
EGL: do not use sparse files for shader

- Process is killed by system with SIGBUS signal if it writes
  data to mapped sparse file on full filesystem.
- Allocate space using write() function instead of ftruncate()
  to avoid creation of sparse files on full filesystem.
  Catch write() errors to handle out-of-space case during allocation.

Bug: http://code.google.com/p/android/issues/detail?id=35376
Change-Id: Ifc366454f34e71a43a0973eda4f591a920ea3a14
Signed-off-by: Kirill Artamonov <kartamonov@nvidia.com>
Fixed clang build error for libgui

Fixed the order of the statements in ANDROID_SINGLETON_STATIC_INSTANCE
macro so that the templated static member variable initialization
comes before the instantiation of the Singleton class. This
fixes the clang compile error.

Change-Id: Ic47d17e152b657f2dff3191ccc3770753fdf002b
Author: Tareq A. Siraj <tareq.a.siraj@intel.com>
Reviewed-by: Edwin Vane <edwin.vane@intel.com>
egl: Reintroduce eglGetRenderBufferANDROID

eglGetRenderBufferANDROID was removed as it had no users. This commit
reintroduces this extensions as it's used by Qualcomm graphics HAL.

Change-Id: I493306830a0d4f8722a42bcc84fb49236afdabeb
Return back-end result from eglDestroyImageKHR

Change-Id: I0e972b778f9802c28f52092bb9af087285833e0b
Allow disable of dumpstate vibrate

Change-Id: I747b757f4b5e2d6a472b7b2a19f8c1ca8a4b7fdd
frameworks/native: Increase EGL blob cache size limits

Increase the size of the EGL Blob Cache to 2MB and the key size to 4K.
This helps improve the performance of OpenGL apps, especially Open GLESv1.1
apps whose shaders are generated on the fly.

CRs-fixed: 393074

Change-Id: Ic3772a9722b63351c940d40794cf54073a8b5eed
Revert "Fixed clang build error for libgui"

This breaks HTC and Sony MSM8960 hwcomposer and surfaceflinger.

Possible that more QCOM devices are broken - at least that's the way it looks on get.cm and Jenkins

This reverts commit 07cc02d5f8efb3d3e51b8215bb5ab5e4353460af.

Change-Id: If0812df57a060999ac8c5f4ba12f2c23199afbc4
graphics: Add directives for compatibility with older EGL blobs (2/2)

Port from CM9.
Original author Ricardo Cerqueira (commit
fc496c0607d0d2863ff9587019e890ab806ea49d)

Change-Id: If30f10f1d4b26547d1219e2ba05f6a831b8fbff8
libui

Change-Id: I1f449b21aaa6384580ded2560d804087610f3a19
Always return true for eglSwapBuffers

Change-Id: I1940f0b9062856a69958372635dee207288cbf99
EGL_ALWAYS_ASYNC

Change-Id: I539ae83385a572c4599f482ff9dca3d39128e76e
SurfaceTexture: dequeueBuffer hack for older EGL blobs

Port from CM9

If MISSING_GRALLOC_BUFFERS is defined (i.e., we're already hacking
around the lack of native buffers), allow retrying buffer dequeues
when the operation returns an error.
Based on work by "rapmv78" at xda-developers
(http://forum.xda-developers.com/showpost.php?p=20342919&postcount=1)

Change-Id: I5b1584b583a3a48ceca058f4d7113af3787aba7a
surfaceflinger: Add support for LGE's HDMI rotation

Use BOARD_USES_LGE_HDMI_ROTATION to align the HDMI output orientation
with the device's, on LGE phones (p990/p999, at least)

Change-Id: I69b9d5de2449df915710f1e2a6df8dcf6a04d06a
ALLOW_DEQUEUE_CURRENT_BUFFER

Change-Id: Idf55b178b3e26c9a2e527db8df566cc3462c98f8