OSDN Git Service

skip non Android VT events
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 4 Feb 2014 16:48:17 +0000 (00:48 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 27 Aug 2014 10:18:42 +0000 (18:18 +0800)
The patch is modified for KitKat from

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

services/input/EventHub.cpp

index fc65734..2585dfa 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 = 7;
+
 static const char *WAKE_LOCK_ID = "KeyEvents";
 static const char *DEVICE_PATH = "/dev/input";
 
@@ -716,6 +720,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) {
@@ -770,6 +782,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);