• 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/atom_field_options.proto";
20import "frameworks/proto_logging/stats/attribution_node.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 bool bool_field = 6;
49  optional string string_field = 7;
50  optional uint32 uint32_field = 8;
51  optional AnEnum enum_field = 9;
52  repeated float repeated_float_field = 10;
53  repeated int64 repeated_int64_field = 11;
54  repeated int32 repeated_int32_field = 12;
55  repeated bool repeated_bool_field = 13;
56  repeated string repeated_string_field = 14;
57}
58
59// Separated from AllTypesAtom because tests can't properly check atoms with multiple enum type
60// fields
61message RepeatedEnumAtom {
62    repeated AnEnum repeated_enum_field = 1;
63}
64
65message Event {
66    oneof pushed {
67        OutOfOrderAtom out_of_order_atom = 2;
68        IntAtom int_atom = 1;
69        AnotherIntAtom another_int_atom = 3;
70        AllTypesAtom all_types_atom = 4;
71        RepeatedEnumAtom repeated_enum_atom = 5;
72    }
73}
74
75message BadTypesAtom {
76    optional IntAtom bad_int_atom = 1;
77    optional bytes bad_bytes = 2;
78    optional double double_field = 3;
79    optional fixed64 fixed64_field = 4;
80    optional fixed32 fixed32_field = 5;
81    optional sfixed64 sfixed64_field = 6;
82    optional sfixed32 sfixed32_field = 7;
83    optional sint64 sint64_field = 8;
84    optional sint32 sint32_field = 9;
85    repeated double double_repeated_field = 10;
86    repeated fixed64 fixed64_repeated_field = 11;
87    repeated fixed32 fixed32_repeated_field = 12;
88    repeated sfixed64 sfixed64_repeated_field = 13;
89    repeated sfixed32 sfixed32_repeated_field = 14;
90    repeated sint64 sint64_repeated_field = 15;
91    repeated sint32 sint32_repeated_field = 16;
92    repeated uint64 uint64_repeated_field = 17;
93    repeated uint32 uint32_repeated_field = 18;
94    repeated IntAtom bad_int_atom_repeated_field = 19;
95    repeated bytes bad_bytes_repeated_field = 20;
96}
97
98message BadTypesEvent {
99    oneof pushed {
100        BadTypesAtom bad_types_atom = 1;
101    }
102}
103
104message BadSkippedFieldSingleAtom {
105    optional int32 field2 = 2;
106}
107
108message BadSkippedFieldSingle {
109    oneof pushed {
110        BadSkippedFieldSingleAtom bad = 1;
111    }
112}
113
114message BadSkippedFieldMultipleAtom {
115    optional int32 field1 = 1;
116    optional int32 field3 = 3;
117    optional int32 field5 = 5;
118}
119
120message BadSkippedFieldMultiple {
121    oneof pushed {
122        BadSkippedFieldMultipleAtom bad = 1;
123    }
124}
125
126message BadAttributionNodePositionAtom {
127  optional int32 field1 = 1;
128  repeated android.os.statsd.AttributionNode attribution = 2;
129}
130
131message BadAttributionNodePosition {
132  oneof pushed { BadAttributionNodePositionAtom bad = 1; }
133}
134
135message GoodEventWithBinaryFieldAtom {
136    oneof pushed { GoodBinaryFieldAtom field1 = 1; }
137}
138
139message ComplexField {
140    optional string str = 1;
141}
142
143message GoodBinaryFieldAtom {
144    optional int32 field1 = 1;
145    optional ComplexField bf = 2 [(android.os.statsd.log_mode) = MODE_BYTES];
146}
147
148message BadEventWithBinaryFieldAtom {
149    oneof pushed { BadBinaryFieldAtom field1 = 1; }
150}
151
152message BadBinaryFieldAtom {
153    optional int32 field1 = 1;
154    optional ComplexField bf = 2;
155}
156
157message BadStateAtoms {
158    oneof pushed {
159        BadStateAtom1 bad1 = 1;
160        BadStateAtom2 bad2 = 2;
161        BadStateAtom3 bad3 = 3;
162        BadStateAtom4 bad4 = 4;
163    }
164}
165
166message GoodStateAtoms {
167    oneof pushed {
168        GoodStateAtom1 good1 = 1;
169        GoodStateAtom2 good2 = 2;
170    }
171}
172
173message GoodRestrictedAtom {
174    optional int64 int64_field = 1 [(android.os.statsd.field_restriction_option).app_usage = true];
175    optional uint64 uint64_field = 2
176        [(android.os.statsd.field_restriction_option).app_activity = true];
177    optional int32 int32_field_1 = 3
178        [(android.os.statsd.field_restriction_option).health_connect = true];
179    optional bool bool_field = 4
180        [(android.os.statsd.field_restriction_option).accessibility = true];
181    optional string string_field = 5
182        [(android.os.statsd.field_restriction_option).system_search = true];
183    optional AnEnum enum_field = 6
184        [(android.os.statsd.field_restriction_option).ambient_sensing = true];
185    optional uint32 uint32_field = 7
186        [(android.os.statsd.field_restriction_option).user_engagement = true];
187    optional float float_field = 8
188        [(android.os.statsd.field_restriction_option).peripheral_device_info = true];
189    optional int32 int32_field_2 = 9
190        [(android.os.statsd.field_restriction_option).demographic_classification = true];
191}
192
193// Nonprimitive fields
194message BadRestrictedAtom1 {
195    repeated android.os.statsd.AttributionNode attribution_chain = 1
196        [(android.os.statsd.field_restriction_option).demographic_classification = true];
197    repeated float repeated_float_field = 2
198        [(android.os.statsd.field_restriction_option).app_usage = true];
199    repeated int64 repeated_int64_field = 3
200        [(android.os.statsd.field_restriction_option).app_activity = true];
201    repeated int32 repeated_int32_field = 4
202        [(android.os.statsd.field_restriction_option).health_connect = true];
203    repeated bool repeated_bool_field = 5
204        [(android.os.statsd.field_restriction_option).accessibility = true];
205    repeated string repeated_string_field = 6
206        [(android.os.statsd.field_restriction_option).system_search = true];
207}
208
209// Restriction category on atom field
210message BadRestrictedAtom2 {
211    optional int32 int32_field = 1
212        [(android.os.statsd.restriction_category) = RESTRICTION_DIAGNOSTIC];
213}
214
215// The atom has only primary field but no exclusive state field.
216message BadStateAtom1 {
217    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
218}
219
220// Only primative types can be annotated.
221message BadStateAtom2 {
222    repeated android.os.statsd.AttributionNode attribution = 1
223            [(android.os.statsd.state_field_option).primary_field = true];
224    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
225}
226
227// Having 2 exclusive state field in the atom means the atom is badly designed.
228// E.g., putting bluetooth state and wifi state in the same atom.
229message BadStateAtom3 {
230    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
231    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
232    optional int32 state2 = 3 [(android.os.statsd.state_field_option).exclusive_state = true];
233}
234
235// Repeated fields can't have state annotations.
236message BadStateAtom4 {
237    repeated int32 state = 1 [(android.os.statsd.state_field_option).exclusive_state = true];
238}
239
240message GoodStateAtom1 {
241    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
242    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
243}
244
245// Atoms can have exclusive state field, but no primary field. That means
246// the state is globally exclusive (e.g., DisplayState).
247message GoodStateAtom2 {
248    optional int32 uid = 1;
249    optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
250}
251
252// We can have more than one primary fields. That means their combination is a
253// primary key.
254message GoodStateAtom3 {
255    optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
256    optional int32 tid = 2 [(android.os.statsd.state_field_option).primary_field = true];
257    optional int32 state = 3 [(android.os.statsd.state_field_option).exclusive_state = true];
258}
259
260message BadUidAtoms {
261    oneof pushed {
262        BadUidAtom1 bad1 = 1;
263        BadUidAtom2 bad2 = 2;
264    }
265}
266
267message GoodUidAtoms {
268    oneof pushed {
269        GoodUidAtom1 good1 = 1;
270        GoodUidAtom2 good2 = 2;
271    }
272}
273
274// The only repeated field type that can have is_uid annotation is int32.
275message BadUidAtom1 {
276    repeated int64 uid = 1 [(android.os.statsd.is_uid) = true];
277}
278
279message BadUidAtom2 {
280    optional string uid = 1 [(android.os.statsd.is_uid) = true];
281}
282
283message GoodUidAtom1 {
284    optional int32 uid = 1 [(android.os.statsd.is_uid) = true];
285}
286
287message GoodUidAtom2 {
288    repeated int32 uid = 1 [(android.os.statsd.is_uid) = true];
289}
290
291message ModuleOneAtom {
292    optional int32 field = 1 [(android.os.statsd.is_uid) = true];
293}
294
295message ModuleTwoAtom {
296    optional int32 field = 1;
297}
298
299message ModuleOneAndTwoAtom {
300    optional int32 field = 1 [(android.os.statsd.state_field_option).exclusive_state = true];
301}
302
303message NoModuleAtom {
304    optional string field = 1;
305}
306
307message ModuleAtoms {
308    oneof pushed {
309        ModuleOneAtom module_one_atom = 1 [(android.os.statsd.module) = "module1"];
310        ModuleTwoAtom module_two_atom = 2 [(android.os.statsd.module) = "module2"];
311        ModuleOneAndTwoAtom module_one_and_two_atom = 3 [
312                (android.os.statsd.module) = "module1", (android.os.statsd.module) = "module2"
313        ];
314        NoModuleAtom no_module_atom = 4;
315    }
316}
317
318message PushedAndPulledAtoms {
319    oneof pushed {
320        IntAtom int_atom_1 = 1;
321    }
322
323    oneof pulled {
324        OutOfOrderAtom out_of_order_atom = 99999;
325        AnotherIntAtom another_int_atom = 10000;
326    }
327}
328
329message VendorAtoms {
330    optional IntAtom pushed_atom_100000 = 100000;
331    optional AnotherIntAtom pulled_atom_199999 = 199999;
332}
333
334message GoodRestrictedAtoms {
335    optional GoodRestrictedAtom pushed_atom_1 = 1
336        [(android.os.statsd.restriction_category) = RESTRICTION_DIAGNOSTIC];
337    optional GoodRestrictedAtom pushed_atom_2 = 2
338        [(android.os.statsd.restriction_category) = RESTRICTION_SYSTEM_INTELLIGENCE];
339}
340
341// Nonprimitive fields
342message BadRestrictedAtoms1 {
343    optional BadRestrictedAtom1 pushed_atom_1 = 1
344        [(android.os.statsd.restriction_category) = RESTRICTION_AUTHENTICATION];
345}
346
347// Restriction category on atom field
348message BadRestrictedAtoms2 {
349    optional BadRestrictedAtom2 pushed_atom_1 = 1;
350}
351
352// Field restriction without restriction category
353message BadRestrictedAtoms3 {
354    optional GoodRestrictedAtom pushed_atom_1 = 1;
355}
356
357// Field restriction option on top level atom field
358message BadRestrictedAtoms4 {
359    optional IntAtom pushed_atom_1 = 1
360        [(android.os.statsd.field_restriction_option).peripheral_device_info = true];
361}
362
363// Restricted pulled atoms
364message BadRestrictedAtoms5 {
365    optional GoodRestrictedAtom pulled_atom_10001 = 10001
366        [(android.os.statsd.restriction_category) = RESTRICTION_AUTHENTICATION];
367    optional GoodRestrictedAtom pulled_atom_10002 = 10002
368        [(android.os.statsd.restriction_category) = RESTRICTION_FRAUD_AND_ABUSE];
369}
370
371message ExtensionAtoms {
372    oneof pushed {
373        IntAtom int_atom_1 = 1;
374    }
375    oneof pulled {
376        OutOfOrderAtom out_of_order_atom = 10000;
377    }
378
379    extensions 9999; // Pushed atom extension, ExtensionAtomPushed
380
381    extensions 99999; // Pulled atom extension, ExtensionAtomPulled
382}
383