From 3c7a12d8f1764df734f74b486e57acf1f629dd5e Mon Sep 17 00:00:00 2001 From: Erik Staats Date: Fri, 24 Sep 2021 05:48:24 -0700 Subject: dynamic_sensor: Add sensor manager init to sub-HAL 2.1. Bug: 195964858 Test: Verified dynamic sensor manager is present in sensor list and that no SELinux violations occur on sc-v2-dev and master. $ make -j28 && \ vendor/google/tools/flashall -w -s 14281FDEE000A5 --disable_verity && \ sleep 90 && adb root . . . $ adb shell sensor_test list | grep "sensor_test\|Type\|Dynamic" sensor_test version 74 Type Subtype Name 32 0 Dynamic Sensor Manager $ adb logcat -d | grep avc | grep sensor $ Change-Id: Ib3da287e4f4118ad6b19498248e263f8c1662b3a --- modules/sensors/dynamic_sensor/ConnectionDetector.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'modules/sensors/dynamic_sensor/ConnectionDetector.cpp') 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); } -- cgit v1.2.3