Migrate statsd to thermal hal v2
Part 1 of 2 in migrating statsd to thermal hal v2. Updates the
temperature puller to use thermal hal v2.
Bug: 119228310
Test: adb shell cmd stats pull-source 10021 on blueline. Received 8 cpu
temps, 2 gpu, 1 skin, 1 battery, 1 usb, and 1 npu. Did not receive any
bcl or power amplifier
Change-Id: I8804e282ea928c1815c2a29e72728edf9a053988
diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp
index 0114ff4..def631b 100644
--- a/cmds/statsd/Android.bp
+++ b/cmds/statsd/Android.bp
@@ -136,7 +136,7 @@
"android.hardware.power@1.0",
"android.hardware.power@1.1",
"android.hardware.power.stats@1.0",
- "android.hardware.thermal@1.0",
+ "android.hardware.thermal@2.0",
"libpackagelistparser",
"libsysutils",
"libcutils",
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 0c05be1..dbad6e55 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -2786,13 +2786,14 @@
* frameworks/base/cmds/statsd/src/external/ResourceThermalManagerPuller.cpp
*/
message Temperature {
- // The type of temperature being reported. Eg. CPU, GPU, SKIN, BATTERY.
+ // The type of temperature being reported. Eg. CPU, GPU, SKIN, BATTERY, BCL_.
optional android.os.TemperatureTypeEnum sensor_location = 1;
// The name of the temperature source. Eg. CPU0
optional string sensor_name = 2;
// Temperature in tenths of a degree C.
+ // For BCL, it is decimillivolt, decimilliamps, and percentage * 10.
optional int32 temperature_deci_celsius = 3;
}
diff --git a/cmds/statsd/src/external/ResourceThermalManagerPuller.cpp b/cmds/statsd/src/external/ResourceThermalManagerPuller.cpp
index 33a17de..53709f1 100644
--- a/cmds/statsd/src/external/ResourceThermalManagerPuller.cpp
+++ b/cmds/statsd/src/external/ResourceThermalManagerPuller.cpp
@@ -17,7 +17,7 @@
#define DEBUG false // STOPSHIP if true
#include "Log.h"
-#include <android/hardware/thermal/1.0/IThermal.h>
+#include <android/hardware/thermal/2.0/IThermal.h>
#include "external/ResourceThermalManagerPuller.h"
#include "external/StatsPuller.h"
@@ -31,10 +31,11 @@
using android::hardware::hidl_death_recipient;
using android::hardware::hidl_vec;
using android::hidl::base::V1_0::IBase;
-using android::hardware::thermal::V1_0::IThermal;
-using android::hardware::thermal::V1_0::Temperature;
-using android::hardware::thermal::V1_0::ThermalStatus;
-using android::hardware::thermal::V1_0::ThermalStatusCode;
+using ::android::hardware::thermal::V2_0::IThermal;
+using ::android::hardware::thermal::V2_0::Temperature;
+using ::android::hardware::thermal::V2_0::TemperatureType;
+using ::android::hardware::thermal::V1_0::ThermalStatus;
+using ::android::hardware::thermal::V1_0::ThermalStatusCode;
using android::hardware::Return;
using android::hardware::Void;
@@ -49,7 +50,7 @@
namespace statsd {
bool getThermalHalLocked();
-sp<android::hardware::thermal::V1_0::IThermal> gThermalHal = nullptr;
+sp<android::hardware::thermal::V2_0::IThermal> gThermalHal = nullptr;
std::mutex gThermalHalMutex;
struct ThermalHalDeathRecipient : virtual public hidl_death_recipient {
@@ -107,7 +108,7 @@
data->clear();
bool resultSuccess = true;
- Return<void> ret = gThermalHal->getTemperatures(
+ Return<void> ret = gThermalHal->getCurrentTemperatures(false, TemperatureType::SKIN,
[&](ThermalStatus status, const hidl_vec<Temperature>& temps) {
if (status.code != ThermalStatusCode::SUCCESS) {
ALOGE("Failed to get temperatures from ThermalHAL. Status: %d", status.code);
@@ -121,7 +122,7 @@
ptr->write((static_cast<int>(temps[i].type)));
ptr->write(temps[i].name);
// Convert the temperature to an int.
- int32_t temp = static_cast<int>(temps[i].currentValue * 10);
+ int32_t temp = static_cast<int>(temps[i].value * 10);
ptr->write(temp);
ptr->init();
data->push_back(ptr);
diff --git a/core/proto/android/os/enums.proto b/core/proto/android/os/enums.proto
index db4a4c4..c357065 100644
--- a/core/proto/android/os/enums.proto
+++ b/core/proto/android/os/enums.proto
@@ -57,6 +57,7 @@
}
// These constants are defined in hardware/interfaces/thermal/1.0/types.hal
+// and in hardware/interfaces/thermal/2.0/types.hal
// They are primarily used by android/os/HardwarePropertiesManager.java.
// Any change to the types in the thermal hal should be made here as well.
enum TemperatureTypeEnum {
@@ -65,6 +66,16 @@
TEMPERATURE_TYPE_GPU = 1;
TEMPERATURE_TYPE_BATTERY = 2;
TEMPERATURE_TYPE_SKIN = 3;
+ TEMPERATURE_TYPE_USB_PORT = 4;
+ TEMPERATURE_TYPE_POWER_AMPLIFIER = 5;
+
+ // Battery Charge Limit - virtual thermal sensors.
+ TEMPERATURE_TYPE_BCL_VOLTAGE = 6;
+ TEMPERATURE_TYPE_BCL_CURRENT = 7;
+ TEMPERATURE_TYPE_BCL_PERCENTAGE = 8;
+
+ // Neural Processing Unit.
+ TEMPERATURE_TYPE_NPU = 9;
}
// Wakelock types, primarily used by android/os/PowerManager.java.