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>
};
status_t EventHub::openDeviceLocked(const char *devicePath) {
};
status_t EventHub::openDeviceLocked(const char *devicePath) {
+ return openDeviceLocked(devicePath, false);
+}
+
+status_t EventHub::openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened) {
+ 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);
ALOGV("Opening device: %s", devicePath);
int fd = open(devicePath, O_RDWR | O_CLOEXEC);
if(event->len) {
strcpy(filename, event->name);
if(event->mask & IN_CREATE) {
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);
} else {
ALOGI("Removing device '%s' due to inotify event\n", devname);
closeDeviceByPathLocked(devname);
};
status_t openDeviceLocked(const char *devicePath);
};
status_t openDeviceLocked(const char *devicePath);
+ status_t openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened);
void createVirtualKeyboardLocked();
void addDeviceLocked(Device* device);
void assignDescriptorLocked(InputDeviceIdentifier& identifier);
void createVirtualKeyboardLocked();
void addDeviceLocked(Device* device);
void assignDescriptorLocked(InputDeviceIdentifier& identifier);