Merge 0bed6311d348a1daf1645bcc3e52ea62f8596ffa on remote branch
Change-Id: I63037526ad0bddc2efca6d85d41f4bbdb537ab09
diff --git a/Android.bp b/Android.bp
index 8508f61..327f400 100644
--- a/Android.bp
+++ b/Android.bp
@@ -31,5 +31,6 @@
cflags: [
"-Wno-unused-parameter",
"-Wno-unused-variable",
+ "-fexceptions",
],
}
diff --git a/thermal.cpp b/thermal.cpp
index ea4272a..c00320e 100644
--- a/thermal.cpp
+++ b/thermal.cpp
@@ -26,6 +26,39 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <ctype.h>
@@ -60,6 +93,13 @@
.vrThrottlingThreshold = 40,
};
+static const Temperature dummy_temp_2_0 = {
+ .type = TemperatureType::SKIN,
+ .name = "test sensor",
+ .value = 25.0,
+ .throttlingStatus = ThrottlingSeverity::NONE,
+};
+
template <typename A, typename B>
Return<void> exit_hal(A _cb, hidl_vec<B> _data, std::string_view _msg) {
ThermalStatus _status;
@@ -170,9 +210,15 @@
return exit_hal(_hidl_cb, temperatures,
"ThermalHAL not initialized properly.");
- if (utils.readTemperatures(filterType, type, temperatures) <= 0)
- return exit_hal(_hidl_cb, temperatures,
- "Sensor Temperature read failure.");
+ if (utils.readTemperatures(filterType, type, temperatures) <= 0) {
+ if (filterType && type != dummy_temp_2_0.type) {
+ status.code = ThermalStatusCode::FAILURE;
+ status.debugMessage = "Failed to read dummy temperature value";
+ } else {
+ temperatures = {dummy_temp_2_0};
+ LOG(INFO) << "Returning Dummy Temperature Value" << std::endl;
+ }
+ }
_hidl_cb(status, temperatures);
diff --git a/thermalCommon.cpp b/thermalCommon.cpp
index 2870a7a..9ca5148 100644
--- a/thermalCommon.cpp
+++ b/thermalCommon.cpp
@@ -372,18 +372,30 @@
{
char file_name[MAX_PATH];
std::string buf;
- int ret = 0;
+ int ret = 0, ct = 0;
+ bool read_ok = false;
- LOG(DEBUG) << "Entering " <<__func__;
snprintf(file_name, sizeof(file_name), CDEV_CUR_STATE_PATH,
cdev.cdevn);
- ret = readLineFromFile(std::string(file_name), buf);
- if (ret <= 0) {
- LOG(ERROR) << "Cdev state read error:"<< ret <<
- " for cdev: " << cdev.c.name;
- return -1;
- }
- cdev.c.value = std::stoi(buf, nullptr, 0);
+ do {
+ ret = readLineFromFile(std::string(file_name), buf);
+ if (ret <= 0) {
+ LOG(ERROR) << "Cdev state read error:"<< ret <<
+ " for cdev: " << cdev.c.name;
+ return -1;
+ }
+ try {
+ cdev.c.value = std::stoi(buf, nullptr, 0);
+ read_ok = true;
+ }
+ catch (std::exception &err) {
+ LOG(ERROR) << "Cdev read stoi error:" << err.what()
+ << " cdev:" << cdev.c.name << " ID:"
+ << cdev.cdevn << " buf:" << buf <<
+ std::endl;
+ }
+ ct++;
+ } while (!read_ok && ct < RETRY_CT);
LOG(DEBUG) << "cdev Name:" << cdev.c.name << ". state:" <<
cdev.c.value << std::endl;
@@ -425,7 +437,8 @@
}
if (idx >= 0)
severity = (ThrottlingSeverity)(idx);
- LOG(DEBUG) << "Sensor Name:" << sensor.t.name << ". prev severity:" <<
+ LOG(INFO) << "Sensor Name:" << sensor.t.name << "temp: " <<
+ temp << ". prev severity:" <<
(int)sensor.lastThrottleStatus << ". cur severity:" <<
(int)sensor.t.throttlingStatus << " New severity:" <<
(int)severity << std::endl;
@@ -442,18 +455,32 @@
char file_name[MAX_PATH];
float temp;
std::string buf;
- int ret = 0;
+ int ret = 0, ct = 0;
+ bool read_ok = false;
- LOG(DEBUG) << "Entering " <<__func__;
- snprintf(file_name, sizeof(file_name), TEMPERATURE_FILE_FORMAT,
+ do {
+ snprintf(file_name, sizeof(file_name), TEMPERATURE_FILE_FORMAT,
sensor.tzn);
- ret = readLineFromFile(std::string(file_name), buf);
- if (ret <= 0) {
- LOG(ERROR) << "Temperature read error:"<< ret <<
- " for sensor " << sensor.t.name;
- return -1;
- }
- sensor.t.value = (float)std::stoi(buf, nullptr, 0) / (float)sensor.mulFactor;
+ ret = readLineFromFile(std::string(file_name), buf);
+ if (ret <= 0) {
+ LOG(ERROR) << "Temperature read error:"<< ret <<
+ " for sensor " << sensor.t.name;
+ return -1;
+ }
+ try {
+ sensor.t.value = (float)std::stoi(buf, nullptr, 0) /
+ (float)sensor.mulFactor;
+ read_ok = true;
+ }
+ catch (std::exception &err) {
+ LOG(ERROR) << "Temperature buf stoi error: "
+ << err.what()
+ << " buf:" << buf << " sensor:"
+ << sensor.t.name << " TZ:" <<
+ sensor.tzn << std::endl;
+ }
+ ct++;
+ } while (!read_ok && ct < RETRY_CT);
LOG(DEBUG) << "Sensor Name:" << sensor.t.name << ". Temperature:" <<
(float)sensor.t.value << std::endl;
diff --git a/thermalCommon.h b/thermalCommon.h
index 6a1b348..e61bb2a 100644
--- a/thermalCommon.h
+++ b/thermalCommon.h
@@ -39,6 +39,8 @@
namespace V2_0 {
namespace implementation {
+#define RETRY_CT 3
+
class ThermalCommon {
public:
ThermalCommon();
diff --git a/thermalConfig.cpp b/thermalConfig.cpp
index 03fd984..291a74d 100644
--- a/thermalConfig.cpp
+++ b/thermalConfig.cpp
@@ -1020,12 +1020,24 @@
std::vector<struct target_therm_cfg>::iterator it_vec;
bool bcl_defined = false;
std::string soc_val;
+ int ct = 0;
+ bool read_ok = false;
- if (cmnInst.readFromFile(socIDPath, soc_val) <= 0) {
- LOG(ERROR) <<"soc ID fetch error";
- return;
- }
- soc_id = std::stoi(soc_val, nullptr, 0);
+ do {
+ if (cmnInst.readFromFile(socIDPath, soc_val) <= 0) {
+ LOG(ERROR) <<"soc ID fetch error";
+ return;
+ }
+ try {
+ soc_id = std::stoi(soc_val, nullptr, 0);
+ read_ok = true;
+ }
+ catch (std::exception &err) {
+ LOG(ERROR) <<"soc id stoi err:" << err.what()
+ << " buf:" << soc_val;
+ }
+ ct++;
+ } while (!read_ok && ct < RETRY_CT);
if (soc_id <= 0) {
LOG(ERROR) << "Invalid soc ID: " << soc_id;
return;