summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/statsd/src/atoms.proto12
-rw-r--r--cmds/statsd/src/external/ResourceHealthManagerPuller.cpp6
-rw-r--r--cmds/statsd/src/external/StatsPullerManager.cpp3
3 files changed, 21 insertions, 0 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index fa0a01825234..3208d7dc193d 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -204,6 +204,7 @@ message Atom {
DeviceCalculatedPowerBlameUid device_calculated_power_blame_uid = 10040;
DeviceCalculatedPowerBlameOther device_calculated_power_blame_other = 10041;
ProcessMemoryHighWaterMark process_memory_high_water_mark = 10042;
+ BatteryLevel battery_level = 10043;
}
// DO NOT USE field numbers above 100,000 in AOSP.
@@ -2679,6 +2680,17 @@ message BatteryVoltage {
}
/**
+ * Pulls battery level (percent full, from 0 to 100).
+ *
+ * Pulled from:
+ * frameworks/base/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
+ */
+message BatteryLevel {
+ // Battery level. Should be in [0, 100].
+ optional int32 battery_level = 1;
+}
+
+/**
* Pulls the temperature of various parts of the device.
* The units are tenths of a degree Celsius. Eg: 30.3C is reported as 303.
*
diff --git a/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp b/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
index ae2cf74962c3..b878652f5cf1 100644
--- a/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
+++ b/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
@@ -91,6 +91,12 @@ bool ResourceHealthManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* dat
ptr->write(v.legacy.batteryVoltage);
ptr->init();
data->push_back(ptr);
+ } else if (mTagId == android::util::BATTERY_LEVEL) {
+ auto ptr = make_shared<LogEvent>(android::util::BATTERY_LEVEL,
+ wallClockTimestampNs, elapsedTimestampNs);
+ ptr->write(v.legacy.batteryLevel);
+ ptr->init();
+ data->push_back(ptr);
} else {
ALOGE("Unsupported tag in ResourceHealthManagerPuller: %d", mTagId);
}
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index a375dd659f7c..ab635a048bbe 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -168,6 +168,9 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
// battery_voltage
{android::util::BATTERY_VOLTAGE,
{{}, {}, 1 * NS_PER_SEC, new ResourceHealthManagerPuller(android::util::BATTERY_VOLTAGE)}},
+ // battery_voltage
+ {android::util::BATTERY_LEVEL,
+ {{}, {}, 1 * NS_PER_SEC, new ResourceHealthManagerPuller(android::util::BATTERY_LEVEL)}},
// process_memory_state
{android::util::PROCESS_MEMORY_STATE,
{{4, 5, 6, 7, 8, 9},