Merge "thermal-hal: Add thermal HAL 2.0 support for sm7150, sm6125 and variants"
diff --git a/thermal.cpp b/thermal.cpp
index 1d8cdcb..ea4272a 100644
--- a/thermal.cpp
+++ b/thermal.cpp
@@ -51,6 +51,15 @@
using ::android::hardware::interfacesEqual;
+static const Temperature_1_0 dummy_temp_1_0 = {
+ .type = TemperatureType_1_0::SKIN,
+ .name = "test sensor",
+ .currentValue = 30,
+ .throttlingThreshold = 40,
+ .shutdownThreshold = 60,
+ .vrThrottlingThreshold = 40,
+};
+
template <typename A, typename B>
Return<void> exit_hal(A _cb, hidl_vec<B> _data, std::string_view _msg) {
ThermalStatus _status;
@@ -86,9 +95,12 @@
hidl_vec<Temperature_1_0> temperatures;
status.code = ThermalStatusCode::SUCCESS;
- if (!utils.isSensorInitialized())
- return exit_hal(_hidl_cb, temperatures,
- "ThermalHAL not initialized properly.");
+ if (!utils.isSensorInitialized()) {
+ std::vector<Temperature_1_0> _temp = {dummy_temp_1_0};
+ LOG(INFO) << "Returning Dummy Value" << std::endl;
+ _hidl_cb(status, _temp);
+ return Void();
+ }
if (utils.readTemperatures(temperatures) <= 0)
return exit_hal(_hidl_cb, temperatures,
@@ -106,9 +118,6 @@
hidl_vec<CpuUsage> cpu_usages;
status.code = ThermalStatusCode::SUCCESS;
- if (!utils.isSensorInitialized())
- return exit_hal(_hidl_cb, cpu_usages,
- "ThermalHAL not initialized properly.");
if (utils.fetchCpuUsages(cpu_usages) <= 0)
return exit_hal(_hidl_cb, cpu_usages,
"CPU usage read failure.");
@@ -123,9 +132,6 @@
hidl_vec<CoolingDevice_1_0> cdev;
status.code = ThermalStatusCode::SUCCESS;
- if (!utils.isCdevInitialized())
- return exit_hal(_hidl_cb, cdev,
- "ThermalHAL not initialized properly.");
/* V1 Cdev requires only Fan Support. */
_hidl_cb(status, cdev);
return Void();
diff --git a/thermalCommon.cpp b/thermalCommon.cpp
index 6fb0d03..2a3ec38 100644
--- a/thermalCommon.cpp
+++ b/thermalCommon.cpp
@@ -383,7 +383,7 @@
" for cdev: " << cdev->c.name;
return -1;
}
- cdev->c.value = std::stoi(buf, nullptr, 0);
+ cdev->c.value = std::stoi(buf);
LOG(DEBUG) << "cdev Name:" << cdev->c.name << ". state:" <<
cdev->c.value << std::endl;
@@ -436,7 +436,7 @@
" for sensor " << sensor->t.name;
return -1;
}
- sensor->t.value = (float)std::stoi(buf, nullptr, 0) / (float)sensor->mulFactor;
+ sensor->t.value = (float)std::stoi(buf) / (float)sensor->mulFactor;
LOG(DEBUG) << "Sensor Name:" << sensor->t.name << ". Temperature:" <<
(float)sensor->t.value << std::endl;