diff options
author | Minghao Zhang <quic_minghao@quicinc.com> | 2022-03-29 22:00:09 +0800 |
---|---|---|
committer | chrisl7 <wandersonrodriguesf1@gmail.com> | 2023-02-25 16:41:00 -0800 |
commit | a2363b10b5c6f85cd0c96cda9f1e55264e53d8cb (patch) | |
tree | 0aea25dc4f3181d50ced1a9f1bca3be458457cb0 | |
parent | ffd812bff5dab55dad2cc4833f4c069fa67e005c (diff) |
thermal-hal: Add a fake temperature data for v2 APIs
In GKI builds, some thermal sensors may not be populated. With this
case thermal hal2.0 will return error for v2 APIs. For compliance,
return success with a dummy temperature data, in case sensors are
not available.
Change-Id: I5ab60aabc12b91ae30500eb9935c48f4f99dd75d
-rw-r--r-- | thermal.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/thermal.cpp b/thermal.cpp index cb379c8..91b976d 100644 --- a/thermal.cpp +++ b/thermal.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -59,6 +60,13 @@ static const Temperature_1_0 dummy_temp_1_0 = { .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; @@ -169,9 +177,15 @@ Return<void> Thermal::getCurrentTemperatures( 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); |