thermal-hal: Update the common data object with the status
thermal-hal has a hash map storing all the sensor instances. Use the same
instance to read and update the temperature, update the severity and
determine the next threshold based on severity. Not using the same
instance can lead to a situation where the information is updated in the
local copy rather than in the global copy in the hash map.
Also change the return signature of the estimateseverity function to
return the new severity value if it is changed. Otherwise it will return
-1. This provided a mechanism for the caller's to know if there is any
change in severity for that sensor.
Change-Id: I34c2a271b505fea969db6f4a04321e63c0181ea7
diff --git a/thermalCommon.h b/thermalCommon.h
index 4375e1e..6a1b348 100644
--- a/thermalCommon.h
+++ b/thermalCommon.h
@@ -44,14 +44,14 @@
ThermalCommon();
~ThermalCommon() = default;
- int readFromFile(std::string_view path, std::string *out);
- int initThermalZones(std::vector<struct target_therm_cfg> cfg);
- void initThreshold(struct therm_sensor sens);
+ int readFromFile(std::string_view path, std::string& out);
+ int initThermalZones(std::vector<struct target_therm_cfg>& cfg);
+ void initThreshold(struct therm_sensor& sens);
int initCdev();
- int read_cdev_state(struct therm_cdev *cdev);
- int read_temperature(struct therm_sensor *sensor);
- int estimateSeverity(struct therm_sensor *sensor);
+ int read_cdev_state(struct therm_cdev& cdev);
+ int read_temperature(struct therm_sensor& sensor);
+ int estimateSeverity(struct therm_sensor& sensor);
int get_cpu_usages(hidl_vec<CpuUsage>& list);
std::vector<struct therm_sensor> fetch_sensor_list()
@@ -69,8 +69,8 @@
std::vector<struct therm_sensor> sens;
std::vector<struct therm_cdev> cdev;
- int initializeCpuSensor(struct target_therm_cfg cpu_cfg);
- int initialize_sensor(struct target_therm_cfg cfg,
+ int initializeCpuSensor(struct target_therm_cfg& cpu_cfg);
+ int initialize_sensor(struct target_therm_cfg& cfg,
int sens_idx);
};