thermal: remove redundant cdev_to_watch registration

cdev_to_watch fd causes pollOnce function return immediatly.
Because thermalhal does not monitor cdev status now,
so remove cdev_to_watch fd to avoid threadLoop busy problem.

Bug: 151897840
Test: Verified thermalhal notifythrottling via emul_temp
      thermalhal will not keep busy.
Change-Id: I999c9b843dde5870d83d8305d5517196188fa819
Signed-off-by: TeYuan Wang <kamewang@google.com>
tirimbino
TeYuan Wang 5 years ago committed by Francescodario Cuzzocrea
parent 998e4cfbfb
commit e2737f7c4e
  1. 13
      hidl/thermal/thermal-helper.cpp
  2. 13
      hidl/thermal/utils/thermal_watcher.cpp
  3. 4
      hidl/thermal/utils/thermal_watcher.h

@ -199,17 +199,6 @@ ThermalHelper::ThermalHelper(const NotificationCallback &cb)
if (!is_initialized_) {
LOG(FATAL) << "ThermalHAL could not be initialized properly.";
}
std::set<std::string> cdev_paths;
std::transform(cooling_device_info_map_.cbegin(), cooling_device_info_map_.cend(),
std::inserter(cdev_paths, cdev_paths.begin()),
[this](std::pair<std::string, const CoolingType> const &cdev) {
std::string path =
cooling_devices_.getThermalFilePath(std::string_view(cdev.first));
if (!path.empty())
return path;
else
return std::string();
});
std::set<std::string> 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();

@ -36,20 +36,7 @@ namespace implementation {
using std::chrono_literals::operator""ms;
void ThermalWatcher::registerFilesToWatch(const std::set<std::string> &sensors_to_watch,
const std::set<std::string> &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;

@ -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<std::string> &sensors_to_watch,
const std::set<std::string> &cdev_to_watch, bool uevent_monitor);
void registerFilesToWatch(const std::set<std::string> &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<int, std::string> watch_to_file_path_map_;
std::vector<android::base::unique_fd> fds_;
// The callback function. Called whenever thermal uevent is seen.
// The function passed in should expect a string in the form (type).

Loading…
Cancel
Save