From af9e8d38184c6ba4d2d3eb5bde7014a66dd8a78b Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 12 Apr 2012 17:32:48 -0700 Subject: Notify applications when input devices change. This change allows the InputManager to keep track of what input devices are registered with the system and when they change. It needs to do this so that it can properly clear its cache of input device properties (especially the key map!) when changes occur. Added new API so that applications can register listeners for input device changes. Fixed a minor bug in EventHub where it didn't handle EPOLLHUP properly so it would spam the log about unsupposed epoll events until inotify noticed that the device was gone and removed it. Change-Id: I937d8c601f7185d4299038bce6a2934fe4fdd2b3 --- services/input/EventHub.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'services/input/EventHub.cpp') diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp index 2ba821e30e99..fbffc947aeb3 100644 --- a/services/input/EventHub.cpp +++ b/services/input/EventHub.cpp @@ -720,6 +720,11 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz break; } } + } else if (eventItem.events & EPOLLHUP) { + ALOGI("Removing device %s due to epoll hang-up event.", + device->identifier.name.string()); + deviceChanged = true; + closeDeviceLocked(device); } else { ALOGW("Received unexpected epoll event 0x%08x for device %s.", eventItem.events, device->identifier.name.string()); -- cgit v1.2.3-59-g8ed1b