OSDN Git Service

skip non Android VT events
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 22 Feb 2012 12:07:17 +0000 (20:07 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 25 Sep 2013 02:45:39 +0000 (10:45 +0800)
The patch is modified for ICS from

http://git.alwaysinnovating.com/cgit.cgi/ai.android/tree/preprocess/froyo/patches/noinput.patch

cmds/system_server/library/system_init.cpp
services/input/EventHub.cpp

index 745c34a..eabf7c6 100644 (file)
@@ -43,6 +43,8 @@ public:
     }
 };
 
+extern int android_vt;
+
 } // namespace android
 
 
@@ -64,6 +66,7 @@ extern "C" status_t system_init()
     if (strcmp(propBuf, "1") == 0) {
         // Start the SurfaceFlinger
         SurfaceFlinger::instantiate();
+        android_vt = 7;
     }
 
     property_get("system_init.startsensorservice", propBuf, "1");
index f4e1cec..52bb0f1 100644 (file)
@@ -50,6 +50,8 @@
 #include <sys/limits.h>
 #include <sys/sha1.h>
 
+#include <linux/vt.h>
+
 /* this macro is used to tell if "bit" is set in "array"
  * it selects a byte from the array, and does a boolean AND
  * operation with a byte that only has the relevant bit set.
@@ -66,6 +68,8 @@
 
 namespace android {
 
+int android_vt = 1;
+
 static const char *WAKE_LOCK_ID = "KeyEvents";
 static const char *DEVICE_PATH = "/dev/input";
 
@@ -709,6 +713,14 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
             }
         }
 
+#ifdef __i386__
+        struct vt_stat vs;
+        int fd_vt = open("/dev/tty0", O_RDWR | O_SYNC);
+        if (fd_vt >= 0) {
+            ioctl(fd_vt, VT_GETSTATE, &vs);
+            close(fd_vt);
+        }
+#endif
         // Grab the next input event.
         bool deviceChanged = false;
         while (mPendingEventIndex < mPendingEventCount) {
@@ -763,6 +775,12 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
                 } else if ((readSize % sizeof(struct input_event)) != 0) {
                     ALOGE("could not get event (wrong size: %d)", readSize);
                 } else {
+#ifdef __i386__
+                    if (vs.v_active != android_vt) {
+                        ALOGV("Skip a non Android VT event");
+                        continue;
+                    }
+#endif
                     int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id;
 
                     size_t count = size_t(readSize) / sizeof(struct input_event);