summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Leung <daniel.leung@intel.com>2012-09-13 13:43:41 -0700
committerChih-Wei Huang <cwhuang@linux.org.tw>2016-05-06 01:55:11 +0800
commit8412d1775f206b6d73fa5459035a608d3ffc8650 (patch)
treedcc05c27d990e051968b0871625a169b749c2dd9
parent7356dc4bda49238315c90e3a586affbb378c4b86 (diff)
downloadframeworks_native-8412d1775f206b6d73fa5459035a608d3ffc8650.zip
frameworks_native-8412d1775f206b6d73fa5459035a608d3ffc8650.tar.gz
frameworks_native-8412d1775f206b6d73fa5459035a608d3ffc8650.tar.bz2
Prevent EventHub from adding input device twice
When Android first starts up, it scans /dev/input for input devices. In some rare instances, the EventHub gets another notification that some device nodes are created. It then proceeds to add the same input device again. This causes the system to get two events per touch or key stroke. This adds a check to prevent adding the same device if the operation is triggerd by inotify. Issue: AXIA-858 Change-Id: I68b02594f1c7f14067611735db0b3763378ec7ea Signed-off-by: Daniel Leung <daniel.leung@intel.com>
-rw-r--r--services/inputflinger/EventHub.cpp11
-rw-r--r--services/inputflinger/EventHub.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index 5859606..c811bac 100644
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -1066,8 +1066,17 @@ static const int32_t GAMEPAD_KEYCODES[] = {
};
status_t EventHub::openDeviceLocked(const char *devicePath) {
+ return openDeviceLocked(devicePath, false);
+}
+
+status_t EventHub::openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened) {
char buffer[80];
+ if (ignoreAlreadyOpened && (getDeviceByPathLocked(devicePath) != 0)) {
+ ALOGV("Ignoring device '%s' that has already been opened.", devicePath);
+ return 0;
+ }
+
ALOGV("Opening device: %s", devicePath);
int fd = open(devicePath, O_RDWR | O_CLOEXEC);
@@ -1617,7 +1626,7 @@ status_t EventHub::readNotifyLocked() {
if(event->len) {
strcpy(filename, event->name);
if(event->mask & IN_CREATE) {
- openDeviceLocked(devname);
+ openDeviceLocked(devname, true);
} else {
ALOGI("Removing device '%s' due to inotify event\n", devname);
closeDeviceByPathLocked(devname);
diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h
index 0f94c77..ed61319 100644
--- a/services/inputflinger/EventHub.h
+++ b/services/inputflinger/EventHub.h
@@ -379,6 +379,7 @@ private:
};
status_t openDeviceLocked(const char *devicePath);
+ status_t openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened);
void createVirtualKeyboardLocked();
void addDeviceLocked(Device* device);
void assignDescriptorLocked(InputDeviceIdentifier& identifier);