frameworks/base
Revision | c58caeec155bc307894d175124b8b6e0868d8b74 (tree) |
---|---|
Time | 2014-08-27 19:18:42 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
skip non Android VT events
The patch is modified for KitKat from
http://git.alwaysinnovating.com/cgit.cgi/ai.android/tree/preprocess/froyo/patches/noinput.patch
@@ -50,6 +50,8 @@ | ||
50 | 50 | #include <sys/limits.h> |
51 | 51 | #include <sys/sha1.h> |
52 | 52 | |
53 | +#include <linux/vt.h> | |
54 | + | |
53 | 55 | /* this macro is used to tell if "bit" is set in "array" |
54 | 56 | * it selects a byte from the array, and does a boolean AND |
55 | 57 | * operation with a byte that only has the relevant bit set. |
@@ -66,6 +68,8 @@ | ||
66 | 68 | |
67 | 69 | namespace android { |
68 | 70 | |
71 | +int android_vt = 7; | |
72 | + | |
69 | 73 | static const char *WAKE_LOCK_ID = "KeyEvents"; |
70 | 74 | static const char *DEVICE_PATH = "/dev/input"; |
71 | 75 |
@@ -716,6 +720,14 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz | ||
716 | 720 | } |
717 | 721 | } |
718 | 722 | |
723 | +#ifdef __i386__ | |
724 | + struct vt_stat vs; | |
725 | + int fd_vt = open("/dev/tty0", O_RDWR | O_SYNC); | |
726 | + if (fd_vt >= 0) { | |
727 | + ioctl(fd_vt, VT_GETSTATE, &vs); | |
728 | + close(fd_vt); | |
729 | + } | |
730 | +#endif | |
719 | 731 | // Grab the next input event. |
720 | 732 | bool deviceChanged = false; |
721 | 733 | while (mPendingEventIndex < mPendingEventCount) { |
@@ -770,6 +782,12 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz | ||
770 | 782 | } else if ((readSize % sizeof(struct input_event)) != 0) { |
771 | 783 | ALOGE("could not get event (wrong size: %d)", readSize); |
772 | 784 | } else { |
785 | +#ifdef __i386__ | |
786 | + if (vs.v_active != android_vt) { | |
787 | + ALOGV("Skip a non Android VT event"); | |
788 | + continue; | |
789 | + } | |
790 | +#endif | |
773 | 791 | int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id; |
774 | 792 | |
775 | 793 | size_t count = size_t(readSize) / sizeof(struct input_event); |