1/* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17syntax = "proto2"; 18package android.os; 19 20option java_multiple_files = true; 21 22import "frameworks/proto_logging/stats/enums/os/enums.proto"; 23 24// This message is used for statsd logging and should be kept in sync with 25// frameworks/proto_logging/stats/atoms.proto 26/** 27 * Represents a device's BatteryUsageStats, with power usage information about the device 28 * and each app. 29 */ 30message BatteryUsageStatsAtomsProto { 31 32 // The session start timestamp in UTC milliseconds since January 1, 1970, per Date#getTime(). 33 // All data is no older than this time. 34 optional int64 session_start_millis = 1; 35 36 // The session end timestamp in UTC milliseconds since January 1, 1970, per Date#getTime(). 37 // All data is no more recent than this time. 38 optional int64 session_end_millis = 2; 39 40 // Length that the reported data covered. This usually will be equal to the entire session, 41 // session_end_millis - session_start_millis, but may not be if some data during this time frame 42 // is missing. 43 optional int64 session_duration_millis = 3; 44 45 // Represents usage of a consumer, storing all of its power component usage. 46 message BatteryConsumerData { 47 // Total power consumed by this BatteryConsumer (including all of its PowerComponents). 48 // May not equal the sum of the PowerComponentUsage due to under- or over-estimations. 49 // Multiply by 1/36 to obtain mAh. 50 optional int64 total_consumed_power_deci_coulombs = 1; 51 52 // Represents power and time usage of a particular power component. 53 message PowerComponentUsage { 54 // Holds android.os.PowerComponentEnum, or custom component value between 1000 and 9999. 55 // Evidently, if one attempts to write an int to an enum field that is out of range, it 56 // is treated as 0, so we must make this an int32. 57 optional int32 component = 1; 58 59 // Power consumed by this component. Multiply by 1/36 to obtain mAh. 60 optional int64 power_deci_coulombs = 2; 61 62 optional int64 duration_millis = 3; 63 } 64 repeated PowerComponentUsage power_components = 2; 65 } 66 67 // Total power usage for the device during this session. 68 optional BatteryConsumerData device_battery_consumer = 4; 69 70 // Power usage by a uid during this session. 71 message UidBatteryConsumer { 72 optional int32 uid = 1; 73 optional BatteryConsumerData battery_consumer_data = 2; 74 optional int64 time_in_foreground_millis = 3; 75 optional int64 time_in_background_millis = 4; 76 } 77 repeated UidBatteryConsumer uid_battery_consumers = 5; 78 79 // Sum of all discharge percentage point drops during the reported session. 80 optional int32 session_discharge_percentage = 6; 81}