thermal: add getUndefinedTemperature function.
Bug: 34107726 Test: cts, vts Change-Id: I8a3794158fbc0c9518a26f4616263aa464b43924
This commit is contained in:
parent
4226670424
commit
3c053c66c9
6 changed files with 66 additions and 17 deletions
|
@ -75,4 +75,19 @@ interface IThermal {
|
|||
getCoolingDevices()
|
||||
generates (ThermalStatus status, vec<CoolingDevice> devices);
|
||||
|
||||
/* Retrieves an undefined temperature value.
|
||||
*
|
||||
* @return status Status of the operation. If status code is FAILURE,
|
||||
* the status.debugMessage must be populated with the human-readable
|
||||
* error message.
|
||||
* @return undefinedTemperature returns an undefined temperature value if
|
||||
* status code is SUCCESS. Undefined temperature value is an
|
||||
* unreachable constant device temperature value for HAL.
|
||||
*
|
||||
*/
|
||||
@callflow(next={"*"})
|
||||
@entry
|
||||
@exit
|
||||
getUndefinedTemperature()
|
||||
generates (ThermalStatus status, float undefinedTemperature);
|
||||
};
|
||||
|
|
|
@ -169,6 +169,13 @@ Return<void> Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb) {
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Thermal::getUndefinedTemperature(getUndefinedTemperature_cb _hidl_cb) {
|
||||
ThermalStatus status;
|
||||
status.code = ThermalStatusCode::SUCCESS;
|
||||
_hidl_cb(status, UNKNOWN_TEMPERATURE);
|
||||
return Void();
|
||||
}
|
||||
|
||||
IThermal* HIDL_FETCH_IThermal(const char* /* name */) {
|
||||
thermal_module_t* module;
|
||||
status_t err = hw_get_module(THERMAL_HARDWARE_MODULE_ID,
|
||||
|
|
|
@ -45,6 +45,7 @@ struct Thermal : public IThermal {
|
|||
Return<void> getTemperatures(getTemperatures_cb _hidl_cb) override;
|
||||
Return<void> getCpuUsages(getCpuUsages_cb _hidl_cb) override;
|
||||
Return<void> getCoolingDevices(getCoolingDevices_cb _hidl_cb) override;
|
||||
Return<void> getUndefinedTemperature(getUndefinedTemperature_cb _hidl_cb) override;
|
||||
private:
|
||||
thermal_module_t* mModule;
|
||||
};
|
||||
|
|
|
@ -46,27 +46,27 @@ struct Temperature {
|
|||
|
||||
/**
|
||||
* Current temperature in Celsius. If not available set by HAL to
|
||||
* UNKNOWN_TEMPERATURE.
|
||||
* undefined temperature value.
|
||||
* 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 undefined temperature value.
|
||||
*/
|
||||
float throttlingThreshold;
|
||||
|
||||
/**
|
||||
* Shutdown temperature constant for this temperature.
|
||||
* If not available, set by HAL to UNKNOWN_TEMPERATURE.
|
||||
* If not available, set by HAL to undefined temperature value.
|
||||
*/
|
||||
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 undefined temperature value.
|
||||
*/
|
||||
float vrThrottlingThreshold;
|
||||
|
||||
|
@ -135,7 +135,3 @@ struct ThermalStatus {
|
|||
*/
|
||||
string debugMessage;
|
||||
};
|
||||
|
||||
/**
|
||||
* TODO(pbond): add float constant UNDEFINED_TEMPERATURE.
|
||||
*/
|
||||
|
|
|
@ -79,4 +79,25 @@ interface: {
|
|||
}
|
||||
}
|
||||
|
||||
api: {
|
||||
name: "getUndefinedTemperature"
|
||||
return_type_hidl: {
|
||||
type: TYPE_STRUCT
|
||||
predefined_type: "::android::hardware::thermal::V1_0::ThermalStatus"
|
||||
}
|
||||
return_type_hidl: {
|
||||
type: TYPE_SCALAR
|
||||
scalar_type: "float_t"
|
||||
}
|
||||
callflow: {
|
||||
next: "*"
|
||||
}
|
||||
callflow: {
|
||||
entry: true
|
||||
}
|
||||
callflow: {
|
||||
exit: true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -56,6 +54,17 @@ class ThermalHidlTest : public ::testing::Test {
|
|||
ASSERT_NE(thermal_, nullptr);
|
||||
baseSize_ = 0;
|
||||
names_.clear();
|
||||
|
||||
{
|
||||
float undefined_temperature;
|
||||
thermal_->getUndefinedTemperature(
|
||||
[&undefined_temperature](ThermalStatus status, float temperature) {
|
||||
EXPECT_EQ(ThermalStatusCode::SUCCESS, status.code);
|
||||
EXPECT_LT(MAX_DEVICE_TEMPERATURE, std::abs(undefined_temperature));
|
||||
undefined_temperature = temperature;
|
||||
});
|
||||
undefined_temperature_ = undefined_temperature;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void TearDown() override {}
|
||||
|
@ -127,21 +136,20 @@ 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);
|
||||
temperature.currentValue == undefined_temperature_);
|
||||
|
||||
// .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);
|
||||
temperature.currentValue == undefined_temperature_ ||
|
||||
temperature.shutdownThreshold == undefined_temperature_);
|
||||
|
||||
// .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 ||
|
||||
temperature.throttlingThreshold == undefined_temperature_ ||
|
||||
temperature.shutdownThreshold == undefined_temperature_);
|
||||
}
|
||||
|
||||
// Check validity of CPU usage returned by Thermal HAL.
|
||||
|
@ -164,6 +172,7 @@ class ThermalHidlTest : public ::testing::Test {
|
|||
|
||||
size_t baseSize_;
|
||||
std::vector<hidl_string> names_;
|
||||
float undefined_temperature_;
|
||||
};
|
||||
|
||||
// Sanity test for Thermal::getTemperatures().
|
||||
|
|
Loading…
Reference in a new issue