summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeYuan Wang <kamewang@google.com>2022-12-23 17:27:24 +0800
committerKame(TeYuan) Wang <kamewang@google.com>2022-12-23 11:07:48 +0000
commit755820efc09f8711065ff9afa9d97b4741fe80e1 (patch)
treec24e0736ab60662d75fcb3cf3a771a1db50b91c4
parentdacdb1fb86d7c99abe125184646f04a05b4a7ff4 (diff)
thermal: add sensor_status_check when reading the temperature
sensor_status_map will not be initilized when the vendor.disable.thermal.control debug property is enabled, so add a check to prevent crashing if someone access sensor_status_map. Bug: 254163925 Test: swithc vendor.disable.thermal.control and check no thermalHAL crash Change-Id: I6014ccdb974c1620a41df8ae32c612ff861514ca
-rw-r--r--thermal/thermal-helper.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp
index 8436127..27fa3b5 100644
--- a/thermal/thermal-helper.cpp
+++ b/thermal/thermal-helper.cpp
@@ -809,6 +809,10 @@ bool ThermalHelper::readThermalSensor(std::string_view sensor_name, float *temp,
boot_clock::time_point now = boot_clock::now();
ATRACE_NAME(StringPrintf("ThermalHelper::readThermalSensor - %s", sensor_name.data()).c_str());
+ if (!(sensor_info_map_.count(sensor_name.data()) &&
+ sensor_status_map_.count(sensor_name.data()))) {
+ return false;
+ }
const auto &sensor_info = sensor_info_map_.at(sensor_name.data());
auto &sensor_status = sensor_status_map_.at(sensor_name.data());