summaryrefslogtreecommitdiff
path: root/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-25 01:07:08 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-25 01:07:08 +0000
commiteb40a971c3c5736a5ca445ef009928215c84d9b5 (patch)
treee71c14d8d618bc471344ff3430d42e281b769a16 /modules/sensors/dynamic_sensor/ConnectionDetector.cpp
parent46756e9e4f9371a3fb8b79e639148b23c3fbca9b (diff)
parent3c7a12d8f1764df734f74b486e57acf1f629dd5e (diff)
Snap for 7766737 from 3c7a12d8f1764df734f74b486e57acf1f629dd5e to sc-v2-release
Change-Id: Ie7f9b61f2e0cb7382712849223e8100c727d9c6d
Diffstat (limited to 'modules/sensors/dynamic_sensor/ConnectionDetector.cpp')
-rw-r--r--modules/sensors/dynamic_sensor/ConnectionDetector.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
index c51e9125..c009a707 100644
--- a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
+++ b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
@@ -57,8 +57,6 @@ SocketConnectionDetector::SocketConnectionDetector(BaseDynamicSensorDaemon *d, i
std::ostringstream s;
s << "socket:" << port;
mDevice = s.str();
-
- run("ddad_socket");
}
SocketConnectionDetector::~SocketConnectionDetector() {
@@ -67,6 +65,12 @@ SocketConnectionDetector::~SocketConnectionDetector() {
}
}
+void SocketConnectionDetector::Init() {
+ // run adds a strong reference to this object, so it can't be invoked from
+ // the constructor.
+ run("ddad_socket");
+}
+
int SocketConnectionDetector::waitForConnection() {
return ::accept(mListenFd, nullptr, nullptr);
}
@@ -124,9 +128,6 @@ FileConnectionDetector::FileConnectionDetector (
ALOGE("Cannot setup watch on dir %s", path.c_str());
return;
}
-
- // mLooper != null && mInotifyFd added to looper
- run("ddad_file");
}
FileConnectionDetector::~FileConnectionDetector() {
@@ -138,6 +139,13 @@ FileConnectionDetector::~FileConnectionDetector() {
}
}
+void FileConnectionDetector::Init() {
+ // mLooper != null && mInotifyFd added to looper
+ // run adds a strong reference to this object, so it can't be invoked from
+ // the constructor.
+ run("ddad_file");
+}
+
bool FileConnectionDetector::matches(const std::string &name) const {
return std::regex_match(name, mRegex);
}