Lines Matching refs:std

38 constexpr std::string_view kCpuOnlineRoot("/sys/devices/system/cpu");
39 constexpr std::string_view kThermalSensorsRoot("/sys/devices/virtual/thermal");
40 constexpr std::string_view kCpuUsageFile("/proc/stat");
41 constexpr std::string_view kCpuOnlineFileSuffix("online");
42 constexpr std::string_view kCpuPresentFile("/sys/devices/system/cpu/present");
43 constexpr std::string_view kSensorPrefix("thermal_zone");
44 constexpr std::string_view kCoolingDevicePrefix("cooling_device");
45 constexpr std::string_view kThermalNameFile("type");
46 constexpr std::string_view kSensorPolicyFile("policy");
47 constexpr std::string_view kSensorTempSuffix("temp");
48 constexpr std::string_view kSensorTripPointTempZeroFile("trip_point_0_temp");
49 constexpr std::string_view kSensorTripPointHystZeroFile("trip_point_0_hyst");
50 constexpr std::string_view kUserSpaceSuffix("user_space");
51 constexpr std::string_view kCoolingDeviceCurStateSuffix("cur_state");
52 constexpr std::string_view kConfigProperty("vendor.thermal.config");
53 constexpr std::string_view kConfigDefaultFileName("thermal_info_config.json");
67 std::size_t getNumberOfCores() { in getNumberOfCores()
68 std::string file; in getNumberOfCores()
73 std::vector<std::string> pieces = android::base::Split(file, "-"); in getNumberOfCores()
78 auto min_core = std::stoul(pieces[0]); in getNumberOfCores()
79 auto max_core = std::stoul(pieces[1]); in getNumberOfCores()
84 return static_cast<std::size_t>(max_core - min_core + 1); in getNumberOfCores()
86 const std::size_t kMaxCpus = getNumberOfCores();
90 std::string cpu_name; in parseCpuUsagesFileAndAssignUsages()
91 std::string data; in parseCpuUsagesFileAndAssignUsages()
97 std::istringstream stat_data(data); in parseCpuUsagesFileAndAssignUsages()
98 std::string line; in parseCpuUsagesFileAndAssignUsages()
99 while (std::getline(stat_data, line)) { in parseCpuUsagesFileAndAssignUsages()
102 std::vector<std::string> words = android::base::Split(line, " "); in parseCpuUsagesFileAndAssignUsages()
104 cpu_num = std::stoi(cpu_name.substr(3)); in parseCpuUsagesFileAndAssignUsages()
107 user = std::stoi(words[1]); in parseCpuUsagesFileAndAssignUsages()
108 nice = std::stoi(words[2]); in parseCpuUsagesFileAndAssignUsages()
109 system = std::stoi(words[3]); in parseCpuUsagesFileAndAssignUsages()
110 idle = std::stoi(words[4]); in parseCpuUsagesFileAndAssignUsages()
113 std::string cpu_online_path = in parseCpuUsagesFileAndAssignUsages()
116 std::string is_online; in parseCpuUsagesFileAndAssignUsages()
135 std::map<std::string, std::string> parseThermalPathMap(std::string_view prefix) { in parseThermalPathMap()
136 std::map<std::string, std::string> path_map; in parseThermalPathMap()
137 std::unique_ptr<DIR, int (*)(DIR *)> dir(opendir(kThermalSensorsRoot.data()), closedir); in parseThermalPathMap()
153 std::string path = android::base::StringPrintf("%s/%s/%s", kThermalSensorsRoot.data(), in parseThermalPathMap()
155 std::string name; in parseThermalPathMap()
178 std::bind(&ThermalHelper::thermalWatcherCallbackFunc, this, std::placeholders::_1))), in ThermalHelper()
201 std::set<std::string> monitored_sensors; in ThermalHelper()
202 std::transform(sensor_info_map_.cbegin(), sensor_info_map_.cend(), in ThermalHelper()
203 std::inserter(monitored_sensors, monitored_sensors.begin()), in ThermalHelper()
204 [](std::pair<std::string, SensorInfo> const &sensor) { in ThermalHelper()
208 return std::string(); in ThermalHelper()
220 bool ThermalHelper::readCoolingDevice(std::string_view cooling_device, in readCoolingDevice()
223 std::string data; in readCoolingDevice()
234 out->value = std::stoi(data); in readCoolingDevice()
239 bool ThermalHelper::readTemperature(std::string_view sensor_name, Temperature_1_0 *out) const { in readTemperature()
241 std::string temp; in readTemperature()
260 out->currentValue = std::stof(temp) * sensor_info.multiplier; in readTemperature()
271 std::string_view sensor_name, Temperature_2_0 *out, in readTemperature()
272 std::pair<ThrottlingSeverity, ThrottlingSeverity> *throtting_status) const { in readTemperature()
274 std::string temp; in readTemperature()
289 out->value = std::stof(temp) * sensor_info.multiplier; in readTemperature()
291 std::pair<ThrottlingSeverity, ThrottlingSeverity> status = in readTemperature()
292 std::make_pair(ThrottlingSeverity::NONE, ThrottlingSeverity::NONE); in readTemperature()
298 std::shared_lock<std::shared_mutex> _lock(sensor_status_map_mutex_); in readTemperature()
317 bool ThermalHelper::readTemperatureThreshold(std::string_view sensor_name, in readTemperatureThreshold()
320 std::string temp; in readTemperatureThreshold()
321 std::string path; in readTemperatureThreshold()
338 std::pair<ThrottlingSeverity, ThrottlingSeverity> ThermalHelper::getSeverityFromThresholds( in getSeverityFromThresholds()
352 if (!std::isnan(hot_thresholds[i]) && hot_thresholds[i] <= value && in getSeverityFromThresholds()
356 if (!std::isnan(hot_thresholds[i]) && (hot_thresholds[i] - hot_hysteresis[i]) < value && in getSeverityFromThresholds()
360 if (!std::isnan(cold_thresholds[i]) && cold_thresholds[i] >= value && in getSeverityFromThresholds()
364 if (!std::isnan(cold_thresholds[i]) && (cold_thresholds[i] + cold_hysteresis[i]) > value && in getSeverityFromThresholds()
376 return std::make_pair(ret_hot, ret_cold); in getSeverityFromThresholds()
379 bool ThermalHelper::initializeSensorMap(const std::map<std::string, std::string> &path_map) { in initializeSensorMap()
381 std::string_view sensor_name = sensor_info_pair.first; in initializeSensorMap()
386 std::string path = android::base::StringPrintf( in initializeSensorMap()
398 bool ThermalHelper::initializeCoolingDevices(const std::map<std::string, std::string> &path_map) { in initializeCoolingDevices()
400 std::string_view cooling_device_name = cooling_device_info_pair.first; in initializeCoolingDevices()
405 std::string path = android::base::StringPrintf( in initializeCoolingDevices()
420 bool ThermalHelper::initializeTrip(const std::map<std::string, std::string> &path_map) { in initializeTrip()
423 std::string_view sensor_name = sensor_info.first; in initializeTrip()
424 std::string_view tz_path = path_map.at(sensor_name.data()); in initializeTrip()
425 std::string tz_policy; in initializeTrip()
426 std::string path = android::base::StringPrintf("%s/%s", (tz_path.data()), in initializeTrip()
441 if (!std::isnan(sensor_info.second.hot_thresholds[i]) && in initializeTrip()
442 !std::isnan(sensor_info.second.hot_hysteresis[i])) { in initializeTrip()
444 std::string threshold = std::to_string(static_cast<int>( in initializeTrip()
454 threshold = std::to_string(static_cast<int>( in initializeTrip()
493 std::vector<Temperature_2_0> ret; in fillCurrentTemperatures()
500 ret.emplace_back(std::move(temp)); in fillCurrentTemperatures()
513 std::vector<TemperatureThreshold> ret; in fillTemperatureThresholds()
520 ret.emplace_back(std::move(temp)); in fillTemperatureThresholds()
533 std::vector<CoolingDevice_2_0> ret; in fillCurrentCoolingDevices()
540 ret.emplace_back(std::move(value)); in fillCurrentCoolingDevices()
558 bool ThermalHelper::thermalWatcherCallbackFunc(const std::set<std::string> &uevent_sensors) { in thermalWatcherCallbackFunc()
559 std::vector<Temperature_2_0> temps; in thermalWatcherCallbackFunc()
579 std::pair<ThrottlingSeverity, ThrottlingSeverity> throtting_status; in thermalWatcherCallbackFunc()
593 std::unique_lock<std::shared_mutex> _lock(sensor_status_map_mutex_); in thermalWatcherCallbackFunc()