blob: cd00ba8e88980c69e49b3303095db6033d0901ea [file] [log] [blame]
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -07001/*
2 * Copyright (C) 2017 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";
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070018
Yao Chend54f9dd2017-10-17 17:37:48 +000019// TODO: Not the right package and class name
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070020package android.os.statsd;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070021option java_package = "com.android.os";
22option java_outer_classname = "StatsEventProto";
23
Yao Chend54f9dd2017-10-17 17:37:48 +000024/**
25 * The master event class. This message defines all of the available
26 * raw stats log events from the Android system, also known as "atoms."
27 *
28 * This field contains a single oneof with all of the available messages.
29 * The stats-log-api-gen tool runs as part of the Android build and
30 * generates the android.util.StatsLog class, which contains the constants
31 * and methods that Android uses to log.
32 *
33 * This StatsEvent class is not actually built into the Android system.
34 * Instead, statsd on Android constructs these messages synthetically,
35 * in the format defined here and in stats_log.proto.
36 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070037message StatsEvent {
Yao Chend54f9dd2017-10-17 17:37:48 +000038 oneof event {
39 ScreenStateChanged screen_state_changed = 1;
40 ProcessStateChanged process_state_changed = 2;
41 WakeLockChanged wakelock_changed = 3;
42 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070043}
44
Yao Chend54f9dd2017-10-17 17:37:48 +000045/**
46 * A WorkSource represents the chained attribution of applications that
47 * resulted in a particular bit of work being done.
48 */
49message WorkSource {
50 // TODO
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070051}
52
Yao Chend54f9dd2017-10-17 17:37:48 +000053/*
54 * *****************************************************************************
55 * Below are all of the individual atoms that are logged by Android via statsd
56 * and Westworld.
57 *
58 * RULES:
59 * - The field ids for each atom must start at 1, and count upwards by 1.
60 * Skipping field ids is not allowed.
61 * - These form an API, so renaming, renumbering or removing fields is
62 * not allowed between android releases. (This is not currently enforced,
63 * but there will be a tool to enforce this restriction).
64 * - The types must be built-in protocol buffer types, namely, no sub-messages
65 * are allowed (yet). The bytes type is also not allowed.
66 * - The CamelCase name of the message type should match the
67 * underscore_separated name as defined in StatsEvent.
68 * - If an atom represents work that can be attributed to an app, there can
69 * be exactly one WorkSource field. It must be field number 1.
70 * - A field that is a uid should be a string field, tagged with the [xxx]
71 * annotation. The generated code on android will be represented by UIDs,
72 * and those UIDs will be translated in xxx to those strings.
73 *
74 * CONVENTIONS:
75 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange
76 * - If there is a UID, it goes first. Think in an object-oriented fashion.
77 * *****************************************************************************
78 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070079
Yao Chend54f9dd2017-10-17 17:37:48 +000080/**
81 * Logs when the screen state changes.
82 *
83 * Logged from:
84 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
85 */
86message ScreenStateChanged {
87 // TODO: Use the real screen state.
88 enum State {
89 STATE_UNKNOWN = 0;
90 STATE_OFF = 1;
91 STATE_ON = 2;
92 STATE_DOZE = 3;
93 STATE_DOZE_SUSPEND = 4;
94 STATE_VR = 5;
95 }
96 // New screen state.
97 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070098}
Yao Chend54f9dd2017-10-17 17:37:48 +000099
100/**
101 * Logs that the state of a process state, as per the activity manager has changed.
102 *
103 * Logged from:
104 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
105 */
106message ProcessStateChanged {
107 // TODO: Use the real (mapped) process states.
108 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
109
110 // The state.
111 optional int32 state = 2;
112}
113
114/**
115 * Logs that the state of a wakelock has changed.
116 *
117 * Logged from:
118 * TODO
119 */
120message WakeLockChanged {
121 // TODO: Add attribution instead of uid.
122 optional int32 uid = 1;
123
124 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
125 optional string tag = 2;
126
127 // TODO: Use a constant instead of boolean?
128 optional bool state = 3;
129}
130