Merge change 7709

* changes:
  Fix MT Call screen stuck issue.
diff --git a/cmds/keystore/keystore_get.h b/cmds/keystore/keystore_get.h
index a7fd9a5..7665e81 100644
--- a/cmds/keystore/keystore_get.h
+++ b/cmds/keystore/keystore_get.h
@@ -29,7 +29,7 @@
  * is returned. Otherwise it returns the value in dynamically allocated memory
  * and sets the size if the pointer is not NULL. One can release the memory by
  * calling free(). */
-static char *keystore_get(char *key, int *size)
+static char *keystore_get(const char *key, int *size)
 {
     char buffer[MAX_KEY_VALUE_LENGTH];
     char *value;
diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h
index d9c0af2..d62fd7d 100644
--- a/include/ui/EventHub.h
+++ b/include/ui/EventHub.h
@@ -75,7 +75,11 @@
     
     status_t scancodeToKeycode(int32_t deviceId, int scancode,
             int32_t* outKeycode, uint32_t* outFlags) const;
-    
+
+    // exclude a particular device from opening
+    // this can be used to ignore input devices for sensors
+    void addExcludedDevice(const char* deviceName);
+
     // special type codes when devices are added/removed.
     enum {
         DEVICE_ADDED = 0x10000000,
@@ -88,10 +92,9 @@
     virtual bool getEvent(int32_t* outDeviceId, int32_t* outType,
             int32_t* outScancode, int32_t* outKeycode, uint32_t *outFlags,
             int32_t* outValue, nsecs_t* outWhen);
-    
+
 protected:
     virtual ~EventHub();
-    virtual void onFirstRef();
     
 private:
     bool openPlatformInput(void);
@@ -139,7 +142,10 @@
     device_t        **mDevices;
     struct pollfd   *mFDs;
     int             mFDCount;
-    
+
+    bool            mOpened;
+    List<String8>   mExcludedDevices;
+
     // device ids that report particular switches.
 #ifdef EV_SW
     int32_t         mSwitches[SW_MAX+1];
diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp
index a72f055..59c9476 100644
--- a/libs/ui/EventHub.cpp
+++ b/libs/ui/EventHub.cpp
@@ -22,7 +22,6 @@
 #include <utils/Log.h>
 #include <utils/Timers.h>
 #include <utils/threads.h>
-#include <utils/List.h>
 #include <utils/Errors.h>
 
 #include <stdlib.h>
@@ -84,7 +83,7 @@
     : mError(NO_INIT), mHaveFirstKeyboard(false), mFirstKeyboardId(0)
     , mDevicesById(0), mNumDevicesById(0)
     , mOpeningDevices(0), mClosingDevices(0)
-    , mDevices(0), mFDs(0), mFDCount(0)
+    , mDevices(0), mFDs(0), mFDCount(0), mOpened(false)
 {
     acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
 #ifdef EV_SW
@@ -101,11 +100,6 @@
     // we should free stuff here...
 }
 
-void EventHub::onFirstRef()
-{
-    mError = openPlatformInput() ? NO_ERROR : UNKNOWN_ERROR;
-}
-
 status_t EventHub::errorCheck() const
 {
     return mError;
@@ -269,6 +263,12 @@
     return NAME_NOT_FOUND;
 }
 
+void EventHub::addExcludedDevice(const char* deviceName)
+{
+    String8 name(deviceName);
+    mExcludedDevices.push_back(name);
+}
+
 EventHub::device_t* EventHub::getDevice(int32_t deviceId) const
 {
     if (deviceId == 0) deviceId = mFirstKeyboardId;
@@ -306,7 +306,12 @@
 
     // Note that we only allow one caller to getEvent(), so don't need
     // to do locking here...  only when adding/removing devices.
-    
+
+    if (!mOpened) {
+        mError = openPlatformInput() ? NO_ERROR : UNKNOWN_ERROR;
+        mOpened = true;
+    }
+
     while(1) {
 
         // First, report any devices that had last been added/removed.
@@ -504,6 +509,20 @@
         //fprintf(stderr, "could not get device name for %s, %s\n", deviceName, strerror(errno));
         name[0] = '\0';
     }
+
+    // check to see if the device is on our excluded list
+    List<String8>::iterator iter = mExcludedDevices.begin();
+    List<String8>::iterator end = mExcludedDevices.end();
+    for ( ; iter != end; iter++) {
+        const char* test = *iter;
+        if (strcmp(name, test) == 0) {
+            LOGI("ignoring event id %s driver %s\n", deviceName, test);
+            close(fd);
+            fd = -1;
+            return -1;
+        }
+    }
+
     if(ioctl(fd, EVIOCGPHYS(sizeof(location) - 1), &location) < 1) {
         //fprintf(stderr, "could not get location for %s, %s\n", deviceName, strerror(errno));
         location[0] = '\0';
@@ -763,6 +782,7 @@
     int event_pos = 0;
     struct inotify_event *event;
 
+LOGD("EventHub::read_notify nfd: %d\n", nfd);
     res = read(nfd, event_buf, sizeof(event_buf));
     if(res < (int)sizeof(*event)) {
         if(errno == EINTR)
diff --git a/libs/utils/ZipUtils.cpp b/libs/utils/ZipUtils.cpp
index 5df94cb..9138878 100644
--- a/libs/utils/ZipUtils.cpp
+++ b/libs/utils/ZipUtils.cpp
@@ -210,7 +210,7 @@
             LOGV("+++ reading %ld bytes (%ld left)\n",
                 getSize, compRemaining);
 
-            int cc = fread(readBuf, getSize, 1, fp);
+            int cc = fread(readBuf, 1, getSize, fp);
             if (cc != (int) getSize) {
                 LOGD("inflate read failed (%d vs %ld)\n",
                     cc, getSize);
@@ -341,4 +341,3 @@
 
     return true;
 }
-
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index d1ed82e..2522656 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -38,7 +38,6 @@
 ifeq ($(LIBAGL_USE_GRALLOC_COPYBITS),1)
     LOCAL_CFLAGS += -DLIBAGL_USE_GRALLOC_COPYBITS
     LOCAL_SRC_FILES += copybit.cpp
-    LOCAL_C_INCLUDES += hardware/libhardware/modules/gralloc
 endif
 
 LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
diff --git a/opengl/libagl/copybit.cpp b/opengl/libagl/copybit.cpp
index 3331026..3c5bcdf 100644
--- a/opengl/libagl/copybit.cpp
+++ b/opengl/libagl/copybit.cpp
@@ -295,6 +295,9 @@
 
     clipRectRegion it(c);
     status_t err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it);
+    if (err != NO_ERROR) {
+        c->textures.tmu[0].texture->try_copybit = false;
+    }
     return err == NO_ERROR ? true : false;
 }
 
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 6f6656a..7afcae7 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -48,10 +48,6 @@
 #include "texture.h"
 #include "matrix.h"
 
-#ifdef LIBAGL_USE_GRALLOC_COPYBITS
-#include "gralloc_priv.h"
-#endif // LIBAGL_USE_GRALLOC_COPYBITS
-
 #undef NELEM
 #define NELEM(x) (sizeof(x)/sizeof(*(x)))
 
@@ -622,11 +618,10 @@
 
 #ifdef LIBAGL_USE_GRALLOC_COPYBITS
     gl->copybits.drawSurfaceBuffer = 0;
-    if (supportedCopybitsDestinationFormat(buffer.format)) {
-        buffer_handle_t handle = this->buffer->handle;
-        if (handle != NULL) {
-            private_handle_t* hand = private_handle_t::dynamicCast(handle);
-            if (hand != NULL && hand->usesPhysicallyContiguousMemory()) {
+    if (gl->copybits.blitEngine != NULL) {
+        if (supportedCopybitsDestinationFormat(buffer.format)) {
+            buffer_handle_t handle = this->buffer->handle;
+            if (handle != NULL) {
                 gl->copybits.drawSurfaceBuffer = handle;
             }
         }
diff --git a/opengl/libagl/primitives.cpp b/opengl/libagl/primitives.cpp
index f164c02..769ec40 100644
--- a/opengl/libagl/primitives.cpp
+++ b/opengl/libagl/primitives.cpp
@@ -369,7 +369,7 @@
         int32_t c0, int32_t c1, int32_t c2) const
 {
     int64_t it64[3];
-    iterators0032(it, c0, c1, c2);
+    iterators0032(it64, c0, c1, c2);
     it[0] = it64[0];
     it[1] = it64[1];
     it[2] = it64[2];
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index d767c31..4d3c2f4 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -27,7 +27,6 @@
 
 #ifdef LIBAGL_USE_GRALLOC_COPYBITS
 #include "copybit.h"
-#include "gralloc_priv.h"
 #endif // LIBAGL_USE_GRALLOC_COPYBITS
 
 namespace android {
@@ -1540,20 +1539,9 @@
     sp<EGLTextureObject> tex = getAndBindActiveTextureObject(c);
     tex->setImage(native_buffer);
 
-    /*
-     * Here an implementation can retrieve the buffer_handle_t of this buffer
-     * which gives it access to an arbitrary-defined kernel resource
-     * (or anything else for that matter).
-     * There needs to be an intimate knowledge between GLES and buffer_handle_t,
-     * so make sure to validate the handle before using it.
-     * Typically, buffer_handle_t comes from the gralloc HAL which is provided
-     * by the implementor of GLES.
-     *
-     */
 #ifdef LIBAGL_USE_GRALLOC_COPYBITS
     tex->try_copybit = false;
-    private_handle_t* hnd = private_handle_t::dynamicCast(native_buffer->handle);
-    if (hnd && hnd->usesPhysicallyContiguousMemory()) {
+    if (c->copybits.blitEngine != NULL) {
         tex->try_copybit = true;
     }
 #endif // LIBAGL_USE_GRALLOC_COPYBITS