Loading thermal/1.0/default/Thermal.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #define LOG_TAG "android.hardware.thermal@1.0-impl" #include <errno.h> #include <math.h> #include <vector> Loading @@ -33,6 +34,14 @@ namespace thermal { namespace V1_0 { namespace implementation { namespace { float finalizeTemperature(float temperature) { return temperature == UNKNOWN_TEMPERATURE ? NAN : temperature; } } Thermal::Thermal(thermal_module_t* module) : mModule(module) {} // Methods from ::android::hardware::thermal::V1_0::IThermal follow. Loading Loading @@ -76,10 +85,11 @@ Return<void> Thermal::getTemperatures(getTemperatures_cb _hidl_cb) { ; } temperatures[i].name = list[i].name; temperatures[i].currentValue = list[i].current_value; temperatures[i].throttlingThreshold = list[i].throttling_threshold; temperatures[i].shutdownThreshold = list[i].shutdown_threshold; temperatures[i].vrThrottlingThreshold = list[i].vr_throttling_threshold; temperatures[i].currentValue = finalizeTemperature(list[i].current_value); temperatures[i].throttlingThreshold = finalizeTemperature(list[i].throttling_threshold); temperatures[i].shutdownThreshold = finalizeTemperature(list[i].shutdown_threshold); temperatures[i].vrThrottlingThreshold = finalizeTemperature(list[i].vr_throttling_threshold); } } } Loading thermal/1.0/types.hal +4 −9 Original line number Diff line number Diff line Loading @@ -45,28 +45,27 @@ struct Temperature { string name; /** * Current temperature in Celsius. If not available set by HAL to * UNKNOWN_TEMPERATURE. * Current temperature in Celsius. If not available set by HAL to NAN. * Current temperature can be in any units if type=UNKNOWN. */ float currentValue; /** * Throttling temperature constant for this temperature. * If not available, set by HAL to UNKNOWN_TEMPERATURE. * If not available, set by HAL to NAN. */ float throttlingThreshold; /** * Shutdown temperature constant for this temperature. * If not available, set by HAL to UNKNOWN_TEMPERATURE. * If not available, set by HAL to NAN. */ float shutdownThreshold; /** * Threshold temperature above which the VR mode clockrate minimums cannot * be maintained for this device. * If not available, set by HAL to UNKNOWN_TEMPERATURE. * If not available, set by HAL to NAN. */ float vrThrottlingThreshold; Loading Loading @@ -135,7 +134,3 @@ struct ThermalStatus { */ string debugMessage; }; /** * TODO(pbond): add float constant UNDEFINED_TEMPERATURE. */ thermal/1.0/vts/functional/thermal_hidl_hal_test.cpp +4 −9 Original line number Diff line number Diff line Loading @@ -43,8 +43,6 @@ using ::android::sp; #define THERMAL_SERVICE_NAME "thermal" #define MONITORING_OPERATION_NUMBER 10 #define UNDEFINED_TEMPERATURE (-FLT_MAX) #define MAX_DEVICE_TEMPERATURE 200 #define MAX_FAN_SPEED 20000 Loading Loading @@ -127,21 +125,18 @@ class ThermalHidlTest : public ::testing::Test { // .currentValue of known type is in Celsius and must be reasonable. EXPECT_TRUE(temperature.type == TemperatureType::UNKNOWN || std::abs(temperature.currentValue) < MAX_DEVICE_TEMPERATURE || temperature.currentValue == UNDEFINED_TEMPERATURE); isnan(temperature.currentValue)); // .name must not be empty. EXPECT_LT(0u, temperature.name.size()); // .currentValue must not exceed .shutdwonThreshold if defined. EXPECT_TRUE(temperature.currentValue < temperature.shutdownThreshold || temperature.currentValue == UNDEFINED_TEMPERATURE || temperature.shutdownThreshold == UNDEFINED_TEMPERATURE); isnan(temperature.currentValue) || isnan(temperature.shutdownThreshold)); // .throttlingThreshold must not exceed .shutdownThreshold if defined. EXPECT_TRUE(temperature.throttlingThreshold < temperature.shutdownThreshold || temperature.throttlingThreshold == UNDEFINED_TEMPERATURE || temperature.shutdownThreshold == UNDEFINED_TEMPERATURE); EXPECT_TRUE(temperature.throttlingThreshold < temperature.shutdownThreshold || isnan(temperature.throttlingThreshold) || isnan(temperature.shutdownThreshold)); } // Check validity of CPU usage returned by Thermal HAL. Loading Loading
thermal/1.0/default/Thermal.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #define LOG_TAG "android.hardware.thermal@1.0-impl" #include <errno.h> #include <math.h> #include <vector> Loading @@ -33,6 +34,14 @@ namespace thermal { namespace V1_0 { namespace implementation { namespace { float finalizeTemperature(float temperature) { return temperature == UNKNOWN_TEMPERATURE ? NAN : temperature; } } Thermal::Thermal(thermal_module_t* module) : mModule(module) {} // Methods from ::android::hardware::thermal::V1_0::IThermal follow. Loading Loading @@ -76,10 +85,11 @@ Return<void> Thermal::getTemperatures(getTemperatures_cb _hidl_cb) { ; } temperatures[i].name = list[i].name; temperatures[i].currentValue = list[i].current_value; temperatures[i].throttlingThreshold = list[i].throttling_threshold; temperatures[i].shutdownThreshold = list[i].shutdown_threshold; temperatures[i].vrThrottlingThreshold = list[i].vr_throttling_threshold; temperatures[i].currentValue = finalizeTemperature(list[i].current_value); temperatures[i].throttlingThreshold = finalizeTemperature(list[i].throttling_threshold); temperatures[i].shutdownThreshold = finalizeTemperature(list[i].shutdown_threshold); temperatures[i].vrThrottlingThreshold = finalizeTemperature(list[i].vr_throttling_threshold); } } } Loading
thermal/1.0/types.hal +4 −9 Original line number Diff line number Diff line Loading @@ -45,28 +45,27 @@ struct Temperature { string name; /** * Current temperature in Celsius. If not available set by HAL to * UNKNOWN_TEMPERATURE. * Current temperature in Celsius. If not available set by HAL to NAN. * Current temperature can be in any units if type=UNKNOWN. */ float currentValue; /** * Throttling temperature constant for this temperature. * If not available, set by HAL to UNKNOWN_TEMPERATURE. * If not available, set by HAL to NAN. */ float throttlingThreshold; /** * Shutdown temperature constant for this temperature. * If not available, set by HAL to UNKNOWN_TEMPERATURE. * If not available, set by HAL to NAN. */ float shutdownThreshold; /** * Threshold temperature above which the VR mode clockrate minimums cannot * be maintained for this device. * If not available, set by HAL to UNKNOWN_TEMPERATURE. * If not available, set by HAL to NAN. */ float vrThrottlingThreshold; Loading Loading @@ -135,7 +134,3 @@ struct ThermalStatus { */ string debugMessage; }; /** * TODO(pbond): add float constant UNDEFINED_TEMPERATURE. */
thermal/1.0/vts/functional/thermal_hidl_hal_test.cpp +4 −9 Original line number Diff line number Diff line Loading @@ -43,8 +43,6 @@ using ::android::sp; #define THERMAL_SERVICE_NAME "thermal" #define MONITORING_OPERATION_NUMBER 10 #define UNDEFINED_TEMPERATURE (-FLT_MAX) #define MAX_DEVICE_TEMPERATURE 200 #define MAX_FAN_SPEED 20000 Loading Loading @@ -127,21 +125,18 @@ class ThermalHidlTest : public ::testing::Test { // .currentValue of known type is in Celsius and must be reasonable. EXPECT_TRUE(temperature.type == TemperatureType::UNKNOWN || std::abs(temperature.currentValue) < MAX_DEVICE_TEMPERATURE || temperature.currentValue == UNDEFINED_TEMPERATURE); isnan(temperature.currentValue)); // .name must not be empty. EXPECT_LT(0u, temperature.name.size()); // .currentValue must not exceed .shutdwonThreshold if defined. EXPECT_TRUE(temperature.currentValue < temperature.shutdownThreshold || temperature.currentValue == UNDEFINED_TEMPERATURE || temperature.shutdownThreshold == UNDEFINED_TEMPERATURE); isnan(temperature.currentValue) || isnan(temperature.shutdownThreshold)); // .throttlingThreshold must not exceed .shutdownThreshold if defined. EXPECT_TRUE(temperature.throttlingThreshold < temperature.shutdownThreshold || temperature.throttlingThreshold == UNDEFINED_TEMPERATURE || temperature.shutdownThreshold == UNDEFINED_TEMPERATURE); EXPECT_TRUE(temperature.throttlingThreshold < temperature.shutdownThreshold || isnan(temperature.throttlingThreshold) || isnan(temperature.shutdownThreshold)); } // Check validity of CPU usage returned by Thermal HAL. Loading