• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Révisione0241a9418ab7df3af4d4a7c22ed666b948e011d (tree)
l'heure2014-08-27 19:18:36
AuteurDaniel Leung <daniel.leung@inte...>
CommiterChih-Wei Huang

Message de Log

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>

Change Summary

Modification

--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -998,8 +998,17 @@ static const int32_t GAMEPAD_KEYCODES[] = {
998998 };
999999
10001000 status_t EventHub::openDeviceLocked(const char *devicePath) {
1001+ return openDeviceLocked(devicePath, false);
1002+}
1003+
1004+status_t EventHub::openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened) {
10011005 char buffer[80];
10021006
1007+ if (ignoreAlreadyOpened && (getDeviceByPathLocked(devicePath) != 0)) {
1008+ ALOGV("Ignoring device '%s' that has already been opened.", devicePath);
1009+ return 0;
1010+ }
1011+
10031012 ALOGV("Opening device: %s", devicePath);
10041013
10051014 int fd = open(devicePath, O_RDWR | O_CLOEXEC);
@@ -1492,7 +1501,7 @@ status_t EventHub::readNotifyLocked() {
14921501 if(event->len) {
14931502 strcpy(filename, event->name);
14941503 if(event->mask & IN_CREATE) {
1495- openDeviceLocked(devname);
1504+ openDeviceLocked(devname, true);
14961505 } else {
14971506 ALOGI("Removing device '%s' due to inotify event\n", devname);
14981507 closeDeviceByPathLocked(devname);
--- a/services/input/EventHub.h
+++ b/services/input/EventHub.h
@@ -369,6 +369,7 @@ private:
369369 };
370370
371371 status_t openDeviceLocked(const char *devicePath);
372+ status_t openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened);
372373 void createVirtualKeyboardLocked();
373374 void addDeviceLocked(Device* device);
374375