• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
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
19import "frameworks/proto_logging/stats/atoms.proto";
20import "frameworks/proto_logging/stats/atom_field_options.proto";
21
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 {
43  repeated android.os.statsd.AttributionNode attribution_chain = 1;
44  optional float float_field = 2;
45  optional int64 int64_field = 3;
46  optional uint64 uint64_field = 4;
47  optional int32 int32_field = 5;
48  optional fixed64 fixed64_field = 6;
49  optional fixed32 fixed32_field = 7;
50  optional bool bool_field = 8;
51  optional string string_field = 9;
52  optional uint32 uint32_field = 10;
53  optional AnEnum enum_field = 11;
54  optional sfixed32 sfixed32_field = 12;
55  optional sfixed64 sfixed64_field = 13;
56  optional sint32 sint32_field = 14;
57  optional sint64 sint64_field = 15;
58}
59
60message Event {
61    oneof pushed {
62        OutOfOrderAtom out_of_order_atom = 2;
63        IntAtom int_atom = 1;
64        AnotherIntAtom another_int_atom = 3;
65        AllTypesAtom all_types_atom = 4;
66    }
67}
68
69message BadTypesAtom {
70    optional IntAtom bad_int_atom = 1;
71    optional bytes bad_bytes = 2;
72    repeated int32 repeated_field = 3;
73    optional double double_field = 4;
74}
75
76message BadTypesEvent {
77    oneof pushed {
78        BadTypesAtom bad_types_atom = 1;
79    }
80}
81
82message BadSkippedFieldSingleAtom {
83    optional int32 field2 = 2;
84}
85
86message BadSkippedFieldSingle {
87    oneof pushed {
88        BadSkippedFieldSingleAtom bad = 1;
89    }
90}
91
92message BadSkippedFieldMultipleAtom {
93    optional int32 field1 = 1;
94    optional int32 field3 = 3;
95    optional int32 field5 = 5;
96}
97
98message BadSkippedFieldMultiple {
99    oneof pushed {
100        BadSkippedFieldMultipleAtom bad = 1;
101    }
102}
103
104message BadAttributionNodePositionAtom {
105  optional int32 field1 = 1;
106  repeated android.os.statsd.AttributionNode attribution = 2;
107}
108
109message BadAttributionNodePosition {
110  oneof pushed { BadAttributionNodePositionAtom bad = 1; }
111}
112
113message GoodEventWithBinaryFieldAtom {
114    oneof pushed { GoodBinaryFieldAtom field1 = 1; }
115}
116
117message ComplexField {
118    optional string str = 1;
119}
120
121message GoodBinaryFieldAtom {
122    optional int32 field1 = 1;
123    optional ComplexField bf = 2 [(android.os.statsd.log_mode) = MODE_BYTES];
124}
125
126message BadEventWithBinaryFieldAtom {
127    oneof pushed { BadBinaryFieldAtom field1 = 1; }
128}
129
130message BadBinaryFieldAtom {
131    optional int32 field1 = 1;
132    optional ComplexField bf = 2;
133}
134
135message BadStateAtoms {
136    oneof pushed {
137        BadStateAtom1 bad1 = 1;
138        BadStateAtom2 bad2 = 2;
139        BadStateAtom3 bad3 = 3;
140    }
141}
142
143message GoodStateAtoms {
144    oneof pushed {
145        GoodStateAtom1 good1 = 1;
146        GoodStateAtom2 good2 = 2;
147    }
148}
149
150// The atom has only primary field but no exclusive state field.
151message BadStateAtom1 {
152    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
153}
154
155// Only primative types can be annotated.
156message BadStateAtom2 {
157    repeated android.os.statsd.AttributionNode attribution = 1
158            [(android.os.statsd.state_field_option).primary_field = true];
159    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
160}
161
162// Having 2 exclusive state field in the atom means the atom is badly designed.
163// E.g., putting bluetooth state and wifi state in the same atom.
164message BadStateAtom3 {
165    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
166    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
167    optional int32 state2 = 3 [(android.os.statsd.state_field_option).exclusive_state = true];
168}
169
170message GoodStateAtom1 {
171    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
172    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
173}
174
175// Atoms can have exclusive state field, but no primary field. That means
176// the state is globally exclusive (e.g., DisplayState).
177message GoodStateAtom2 {
178    optional int32 uid = 1;
179    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
180}
181
182// We can have more than one primary fields. That means their combination is a
183// primary key.
184message GoodStateAtom3 {
185    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
186    optional int32 tid = 2 [(android.os.statsd.state_field_option).primary_field = true];
187    optional int32 state = 3 [(android.os.statsd.state_field_option).exclusive_state = true];
188}
189
190message ModuleOneAtom {
191    optional int32 field = 1 [(android.os.statsd.is_uid) = true];
192}
193
194message ModuleTwoAtom {
195    optional int32 field = 1;
196}
197
198message ModuleOneAndTwoAtom {
199    optional int32 field = 1 [(android.os.statsd.state_field_option).exclusive_state = true];
200}
201
202message NoModuleAtom {
203    optional string field = 1;
204}
205
206message ModuleAtoms {
207    oneof pushed {
208        ModuleOneAtom module_one_atom = 1 [(android.os.statsd.module) = "module1"];
209        ModuleTwoAtom module_two_atom = 2 [(android.os.statsd.module) = "module2"];
210        ModuleOneAndTwoAtom module_one_and_two_atom = 3 [
211                (android.os.statsd.module) = "module1", (android.os.statsd.module) = "module2"
212        ];
213        NoModuleAtom no_module_atom = 4;
214    }
215}
216
217message NotAPushNorPullAtom {
218    oneof event {
219        IntAtom int_atom = 1;
220    }
221}
222
223message AtomNotInAOneof {
224    optional IntAtom int_atom = 1;
225}
226
227message PushedAndPulledAtoms {
228    oneof pushed {
229        IntAtom int_atom_1 = 1;
230    }
231
232    oneof pulled {
233        OutOfOrderAtom out_of_order_atom = 11;
234        AnotherIntAtom another_int_atom = 10;
235    }
236}
237