blob: c3e703826be5c786ad8ae6c95ce807327a598385 [file] [log] [blame]
Yao Chend54f9dd2017-10-17 17:37:48 +00001/*
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";
18
Stefan Lafonae2df012017-11-14 09:17:21 -080019import "frameworks/base/cmds/statsd/src/atoms.proto";
Yao Chen9c1debe2018-02-19 14:39:19 -080020import "frameworks/base/cmds/statsd/src/atom_field_options.proto";
Yao Chend54f9dd2017-10-17 17:37:48 +000021
22package android.stats_log_api_gen;
23
24message IntAtom {
25 optional int32 field1 = 1;
26}
27
28message AnotherIntAtom {
29 optional int32 field1 = 1;
30}
31
32message OutOfOrderAtom {
33 optional int32 field2 = 2;
34 optional int32 field1 = 1;
35}
36
37enum AnEnum {
38 VALUE0 = 0;
39 VALUE1 = 1;
40}
41
42message AllTypesAtom {
Yangster-mac20877162017-12-22 17:19:39 -080043 repeated android.os.statsd.AttributionNode attribution_chain = 1;
Yangster-mac7604aea2017-12-11 22:55:49 -080044 optional double double_field = 2;
45 optional float float_field = 3;
46 optional int64 int64_field = 4;
47 optional uint64 uint64_field = 5;
48 optional int32 int32_field = 6;
49 optional fixed64 fixed64_field = 7;
50 optional fixed32 fixed32_field = 8;
51 optional bool bool_field = 9;
52 optional string string_field = 10;
53 optional uint32 uint32_field = 11;
54 optional AnEnum enum_field = 12;
55 optional sfixed32 sfixed32_field = 13;
56 optional sfixed64 sfixed64_field = 14;
57 optional sint32 sint32_field = 15;
58 optional sint64 sint64_field = 16;
Yao Chend54f9dd2017-10-17 17:37:48 +000059}
60
61message Event {
62 oneof event {
63 OutOfOrderAtom out_of_order_atom = 2;
64 IntAtom int_atom = 1;
65 AnotherIntAtom another_int_atom = 3;
66 AllTypesAtom all_types_atom = 4;
67 }
68}
69
70message BadTypesAtom {
71 optional IntAtom bad_int_atom = 1;
72 optional bytes bad_bytes = 2;
73}
74
75message BadTypesEvent {
76 oneof event {
77 BadTypesAtom bad_types_atom = 1;
78 }
79}
80
81message BadSkippedFieldSingleAtom {
82 optional int32 field2 = 2;
83}
84
85message BadSkippedFieldSingle {
86 oneof event {
87 BadSkippedFieldSingleAtom bad = 1;
88 }
89}
90
91message BadSkippedFieldMultipleAtom {
92 optional int32 field1 = 1;
93 optional int32 field3 = 3;
94 optional int32 field5 = 5;
95}
96
97message BadSkippedFieldMultiple {
98 oneof event {
99 BadSkippedFieldMultipleAtom bad = 1;
100 }
101}
102
Yangster-mac20877162017-12-22 17:19:39 -0800103message BadAttributionNodePositionAtom {
Yangster-mac7604aea2017-12-11 22:55:49 -0800104 optional int32 field1 = 1;
Yangster-mac20877162017-12-22 17:19:39 -0800105 repeated android.os.statsd.AttributionNode attribution = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000106}
107
Yangster-mac20877162017-12-22 17:19:39 -0800108message BadAttributionNodePosition {
109 oneof event { BadAttributionNodePositionAtom bad = 1; }
Yao Chend54f9dd2017-10-17 17:37:48 +0000110}
111
Yao Chenbbdd67d2018-10-24 12:15:56 -0700112message GoodEventWithBinaryFieldAtom {
113 oneof event { GoodBinaryFieldAtom field1 = 1; }
114}
115
116message ComplexField {
117 optional string str = 1;
118}
119
120message GoodBinaryFieldAtom {
121 optional int32 field1 = 1;
122 optional ComplexField bf = 2 [(android.os.statsd.log_mode) = MODE_BYTES];
123}
124
125message BadEventWithBinaryFieldAtom {
126 oneof event { BadBinaryFieldAtom field1 = 1; }
127}
128
129message BadBinaryFieldAtom {
130 optional int32 field1 = 1;
131 optional ComplexField bf = 2;
132}
133
Yao Chen9c1debe2018-02-19 14:39:19 -0800134message BadStateAtoms {
135 oneof event {
136 BadStateAtom1 bad1 = 1;
137 BadStateAtom2 bad2 = 2;
138 BadStateAtom3 bad3 = 3;
139 }
140}
141
142message GoodStateAtoms {
143 oneof event {
144 GoodStateAtom1 good1 = 1;
145 GoodStateAtom2 good2 = 2;
146 }
147}
148
149// The atom has only primary field but no exclusive state field.
150message BadStateAtom1 {
151 optional int32 uid = 1
Yangster-macb6b77c62018-10-12 19:33:24 -0700152 [(android.os.statsd.state_field_option).option = PRIMARY];
Yao Chen9c1debe2018-02-19 14:39:19 -0800153}
154
155// Only primative types can be annotated.
156message BadStateAtom2 {
157 repeated android.os.statsd.AttributionNode attribution = 1
Yangster-macb6b77c62018-10-12 19:33:24 -0700158 [(android.os.statsd.state_field_option).option = PRIMARY];
Yao Chen9c1debe2018-02-19 14:39:19 -0800159 optional int32 state = 2
Yangster-macb6b77c62018-10-12 19:33:24 -0700160 [(android.os.statsd.state_field_option).option = EXCLUSIVE];
Yao Chen9c1debe2018-02-19 14:39:19 -0800161}
162
163// Having 2 exclusive state field in the atom means the atom is badly designed.
164// E.g., putting bluetooth state and wifi state in the same atom.
165message BadStateAtom3 {
166 optional int32 uid = 1
Yangster-macb6b77c62018-10-12 19:33:24 -0700167 [(android.os.statsd.state_field_option).option = PRIMARY];
Yao Chen9c1debe2018-02-19 14:39:19 -0800168 optional int32 state = 2
Yangster-macb6b77c62018-10-12 19:33:24 -0700169 [(android.os.statsd.state_field_option).option = EXCLUSIVE];
Yao Chen9c1debe2018-02-19 14:39:19 -0800170 optional int32 state2 = 3
Yangster-macb6b77c62018-10-12 19:33:24 -0700171 [(android.os.statsd.state_field_option).option = EXCLUSIVE];
Yao Chen9c1debe2018-02-19 14:39:19 -0800172}
173
174message GoodStateAtom1 {
175 optional int32 uid = 1
Yangster-macb6b77c62018-10-12 19:33:24 -0700176 [(android.os.statsd.state_field_option).option = PRIMARY];
Yao Chen9c1debe2018-02-19 14:39:19 -0800177 optional int32 state = 2
Yangster-macb6b77c62018-10-12 19:33:24 -0700178 [(android.os.statsd.state_field_option).option = EXCLUSIVE];
Yao Chen9c1debe2018-02-19 14:39:19 -0800179}
180
181// Atoms can have exclusive state field, but no primary field. That means
182// the state is globally exclusive (e.g., DisplayState).
183message GoodStateAtom2 {
184 optional int32 uid = 1;
185 optional int32 state = 2
Yangster-macb6b77c62018-10-12 19:33:24 -0700186 [(android.os.statsd.state_field_option).option = EXCLUSIVE];
Yao Chen9c1debe2018-02-19 14:39:19 -0800187}
188
189// We can have more than one primary fields. That means their combination is a
190// primary key.
191message GoodStateAtom3 {
192 optional int32 uid = 1
Yangster-macb6b77c62018-10-12 19:33:24 -0700193 [(android.os.statsd.state_field_option).option = PRIMARY];
Yao Chen9c1debe2018-02-19 14:39:19 -0800194 optional int32 tid = 2
Yangster-macb6b77c62018-10-12 19:33:24 -0700195 [(android.os.statsd.state_field_option).option = PRIMARY];
Yao Chen9c1debe2018-02-19 14:39:19 -0800196 optional int32 state = 3
Yangster-macb6b77c62018-10-12 19:33:24 -0700197 [(android.os.statsd.state_field_option).option = EXCLUSIVE];
Andrei Oneada01ea52019-01-30 15:28:36 +0000198}
199
200message WhitelistedAtom {
201 optional int32 field = 1;
202}
203
204message NonWhitelistedAtom {
205 optional int32 field = 1;
206}
207
208message ListedAtoms {
209 oneof event {
210 // Atoms can be whitelisted i.e. they can be triggered by any source
211 WhitelistedAtom whitelisted_atom = 1 [(android.os.statsd.allow_from_any_uid) = true];
212 // Atoms are not whitelisted by default, so they can only be triggered
213 // by whitelisted sources
214 NonWhitelistedAtom non_whitelisted_atom = 2;
215 }
Tej Singh810eeb32019-03-07 19:08:52 -0800216}
217
218message ModuleOneAtom {
219 optional int32 field = 1;
220}
221
222message ModuleTwoAtom {
223 optional int32 field = 1;
224}
225
226message NoModuleAtom {
227 optional string field = 1;
228}
229
230message ModuleAtoms {
231 oneof event {
232 ModuleOneAtom module_one_atom = 1 [(android.os.statsd.log_from_module) = "module1"];
233 ModuleTwoAtom module_two_atom = 2 [(android.os.statsd.log_from_module) = "module2"];
234 NoModuleAtom no_module_atom = 3;
235 }
Yao Chen9c1debe2018-02-19 14:39:19 -0800236}