}
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 | O_NONBLOCK);
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);
};
status_t openDeviceLocked(const char *devicePath);
+ status_t openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened);
void createVirtualKeyboardLocked();
void addDeviceLocked(Device* device);
void assignDescriptorLocked(InputDeviceIdentifier& identifier);