summaryrefslogtreecommitdiff
path: root/modules/sensors/dynamic_sensor/ConnectionDetector.h
diff options
context:
space:
mode:
authorPeng Xu <pengxu@google.com>2017-04-26 17:17:55 -0700
committerPeng Xu <pengxu@google.com>2017-04-27 00:22:56 -0700
commit172c4014f30c6d77586b1c8617682110b2b74f95 (patch)
tree064a0b3019b0b69d1c01b3bf1a28a4667d0610dd /modules/sensors/dynamic_sensor/ConnectionDetector.h
parentcc2a92de7bc37ab4514a17e1d0c1f9b05c26f86e (diff)
Correct inotify usage and fix strong count accounting error
Fix an error in polling of inotify fd to avoid 100% CPU usage. Refactored code to use android Looper. Fix a string count accounting error that causes unpaired decStrong crashing sensor hidl service. Bug: 37719320 Bug: 37714835 Test: no longer have 100% CPU usage. Test: tested connection of a few mouse/keyboard/usb disk/gnubby no crash observed. Test: cts still working properly after fix. Change-Id: Ibaa026151e5e4919d8dd134c16f5865d5e30ef8a
Diffstat (limited to 'modules/sensors/dynamic_sensor/ConnectionDetector.h')
-rw-r--r--modules/sensors/dynamic_sensor/ConnectionDetector.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/sensors/dynamic_sensor/ConnectionDetector.h b/modules/sensors/dynamic_sensor/ConnectionDetector.h
index 712d832f..0ee1df29 100644
--- a/modules/sensors/dynamic_sensor/ConnectionDetector.h
+++ b/modules/sensors/dynamic_sensor/ConnectionDetector.h
@@ -19,6 +19,7 @@
#include "BaseDynamicSensorDaemon.h"
#include <utils/Thread.h>
+#include <utils/Looper.h>
#include <regex>
@@ -62,17 +63,20 @@ public:
BaseDynamicSensorDaemon *d, const std::string &path, const std::string &regex);
virtual ~FileConnectionDetector();
private:
+ static constexpr int POLL_IDENT = 1;
// implement virtual of Thread
virtual bool threadLoop();
bool matches(const std::string &name) const;
void processExistingFiles() const;
+ void handleInotifyData(ssize_t len, const char *data);
+ bool readInotifyData();
std::string getFullName(const std::string name) const;
std::string mPath;
std::regex mRegex;
+ sp<Looper> mLooper;
int mInotifyFd;
- struct pollfd mPollFd;
};
} // namespace SensorHalExt