summaryrefslogtreecommitdiff
path: root/core/proto
diff options
context:
space:
mode:
authorAdam Bookatz <bookatz@google.com>2021-05-05 12:39:16 -0700
committerAdam Bookatz <bookatz@google.com>2021-05-13 11:40:26 -0700
commit2f3abb44411db58e98b64644adee9633fc504e7d (patch)
tree646bb881545b7e039de05704b3e4f015fed2c500 /core/proto
parentc73c098665515f33041d90f0a49b3cdc392e2b13 (diff)
BatteryUsageStats atom - frameworks/base
Writes the BatteryUsageStats atoms.proto atoms based on the current BatteryUsageStats data in BatteryStats. Does NOT write the past pre-reset snapshot atoms; that is an adventure for a future cl. Bug: 184095105 Test: atest BatteryUsageStatsProtoTests Test: statsd_testdrive <atomId> Change-Id: I2fc5a983deb58d7d393c0696db2165b124c94dc2
Diffstat (limited to 'core/proto')
-rw-r--r--core/proto/android/os/batteryusagestats.proto81
1 files changed, 81 insertions, 0 deletions
diff --git a/core/proto/android/os/batteryusagestats.proto b/core/proto/android/os/batteryusagestats.proto
new file mode 100644
index 000000000000..bcce784ae0be
--- /dev/null
+++ b/core/proto/android/os/batteryusagestats.proto
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+package android.os;
+
+option java_multiple_files = true;
+
+import "frameworks/proto_logging/stats/enums/os/enums.proto";
+
+// This message is used for statsd logging and should be kept in sync with
+// frameworks/proto_logging/stats/atoms.proto
+/**
+ * Represents a device's BatteryUsageStats, with power usage information about the device
+ * and each app.
+ */
+message BatteryUsageStatsAtomsProto {
+
+ // The session start timestamp in UTC milliseconds since January 1, 1970, per Date#getTime().
+ // All data is no older than this time.
+ optional int64 session_start_millis = 1;
+
+ // The session end timestamp in UTC milliseconds since January 1, 1970, per Date#getTime().
+ // All data is no more recent than this time.
+ optional int64 session_end_millis = 2;
+
+ // Length that the reported data covered. This usually will be equal to the entire session,
+ // session_end_millis - session_start_millis, but may not be if some data during this time frame
+ // is missing.
+ optional int64 session_duration_millis = 3;
+
+ // Represents usage of a consumer, storing all of its power component usage.
+ message BatteryConsumerData {
+ // Total power consumed by this BatteryConsumer (including all of its PowerComponents).
+ // May not equal the sum of the PowerComponentUsage due to under- or over-estimations.
+ // Multiply by 1/36 to obtain mAh.
+ optional int64 total_consumed_power_deci_coulombs = 1;
+
+ // Represents power and time usage of a particular power component.
+ message PowerComponentUsage {
+ // Holds android.os.PowerComponentEnum, or custom component value between 1000 and 9999.
+ // Evidently, if one attempts to write an int to an enum field that is out of range, it
+ // is treated as 0, so we must make this an int32.
+ optional int32 component = 1;
+
+ // Power consumed by this component. Multiply by 1/36 to obtain mAh.
+ optional int64 power_deci_coulombs = 2;
+
+ optional int64 duration_millis = 3;
+ }
+ repeated PowerComponentUsage power_components = 2;
+ }
+
+ // Total power usage for the device during this session.
+ optional BatteryConsumerData device_battery_consumer = 4;
+
+ // Power usage by a uid during this session.
+ message UidBatteryConsumer {
+ optional int32 uid = 1;
+ optional BatteryConsumerData battery_consumer_data = 2;
+ optional int64 time_in_foreground_millis = 3;
+ optional int64 time_in_background_millis = 4;
+ }
+ repeated UidBatteryConsumer uid_battery_consumers = 5;
+
+ // Sum of all discharge percentage point drops during the reported session.
+ optional int32 session_discharge_percentage = 6;
+} \ No newline at end of file