diff --git a/hidl/thermal/thermal-helper.cpp b/hidl/thermal/thermal-helper.cpp index dff45c29..269b1de7 100644 --- a/hidl/thermal/thermal-helper.cpp +++ b/hidl/thermal/thermal-helper.cpp @@ -199,17 +199,6 @@ ThermalHelper::ThermalHelper(const NotificationCallback &cb) if (!is_initialized_) { LOG(FATAL) << "ThermalHAL could not be initialized properly."; } - std::set cdev_paths; - std::transform(cooling_device_info_map_.cbegin(), cooling_device_info_map_.cend(), - std::inserter(cdev_paths, cdev_paths.begin()), - [this](std::pair const &cdev) { - std::string path = - cooling_devices_.getThermalFilePath(std::string_view(cdev.first)); - if (!path.empty()) - return path; - else - return std::string(); - }); std::set monitored_sensors; std::transform(sensor_info_map_.cbegin(), sensor_info_map_.cend(), std::inserter(monitored_sensors, monitored_sensors.begin()), @@ -220,7 +209,7 @@ ThermalHelper::ThermalHelper(const NotificationCallback &cb) return std::string(); }); - thermal_watcher_->registerFilesToWatch(monitored_sensors, cdev_paths, initializeTrip(tz_map)); + thermal_watcher_->registerFilesToWatch(monitored_sensors, initializeTrip(tz_map)); // Need start watching after status map initialized is_initialized_ = thermal_watcher_->startWatchingDeviceFiles(); diff --git a/hidl/thermal/utils/thermal_watcher.cpp b/hidl/thermal/utils/thermal_watcher.cpp index 08a7e390..31a89a05 100644 --- a/hidl/thermal/utils/thermal_watcher.cpp +++ b/hidl/thermal/utils/thermal_watcher.cpp @@ -36,20 +36,7 @@ namespace implementation { using std::chrono_literals::operator""ms; void ThermalWatcher::registerFilesToWatch(const std::set &sensors_to_watch, - const std::set &cdev_to_watch, bool uevent_monitor) { - int flags = O_RDONLY | O_CLOEXEC | O_BINARY; - - for (const auto &path : cdev_to_watch) { - android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), flags))); - if (fd == -1) { - PLOG(ERROR) << "failed to watch: " << path; - continue; - } - watch_to_file_path_map_.emplace(fd.get(), path); - looper_->addFd(fd.get(), 0, Looper::EVENT_INPUT, nullptr, nullptr); - fds_.emplace_back(std::move(fd)); - } monitored_sensors_.insert(sensors_to_watch.begin(), sensors_to_watch.end()); if (!uevent_monitor) { is_polling_ = true; diff --git a/hidl/thermal/utils/thermal_watcher.h b/hidl/thermal/utils/thermal_watcher.h index be94ab09..f8cd0449 100644 --- a/hidl/thermal/utils/thermal_watcher.h +++ b/hidl/thermal/utils/thermal_watcher.h @@ -58,8 +58,7 @@ class ThermalWatcher : public ::android::Thread { // Give the file watcher a list of files to start watching. This helper // class will by default wait for modifications to the file with a looper. // This should be called before starting watcher thread. - void registerFilesToWatch(const std::set &sensors_to_watch, - const std::set &cdev_to_watch, bool uevent_monitor); + void registerFilesToWatch(const std::set &sensors_to_watch, bool uevent_monitor); // Wake up the looper thus the worker thread, immediately. This can be called // in any thread. void wake(); @@ -76,7 +75,6 @@ class ThermalWatcher : public ::android::Thread { // Maps watcher filer descriptor to watched file path. std::unordered_map watch_to_file_path_map_; - std::vector fds_; // The callback function. Called whenever thermal uevent is seen. // The function passed in should expect a string in the form (type).