Check if /dev/input exists before accessing the path

It is possible that development platforms don't have any input devices,
hence /dev/input directory won't be created. Hence check if /dev/input exists
before adding inotify watch and scanDirLocked for /dev/input.
inotify_add_watch is also added for /dev/input when it is created. for e.g.
during EventHubTest.

Signed-off-by: Usama Arif <usama.arif@arm.com>
Change-Id: I8675921280e351dd8885becce79a7cb4a9936c10
Merged-In: I8675921280e351dd8885becce79a7cb4a9936c10
diff --git a/services/inputflinger/reader/include/EventHub.h b/services/inputflinger/reader/include/EventHub.h
index d0a6a3f..55f658e 100644
--- a/services/inputflinger/reader/include/EventHub.h
+++ b/services/inputflinger/reader/include/EventHub.h
@@ -426,6 +426,9 @@
     status_t mapLed(Device* device, int32_t led, int32_t* outScanCode) const;
     void setLedStateLocked(Device* device, int32_t led, bool on);
 
+    void addDeviceInputInotify();
+    void addDeviceInotify();
+
     // Protect all internal state.
     mutable Mutex mLock;
 
@@ -465,8 +468,8 @@
     int mWakeReadPipeFd;
     int mWakeWritePipeFd;
 
-    int mInputWd;
-    int mVideoWd;
+    int mDeviceInputWd;
+    int mDeviceWd = -1;
 
     // Maximum number of signalled FDs to handle at a time.
     static const int EPOLL_MAX_EVENTS = 16;