blob: 264a865e3b3993721f0ad1fedefdfcb18b24e2d7 [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 Chen9c1debe2018-02-19 14:39:19 -0800112message BadStateAtoms {
113 oneof event {
114 BadStateAtom1 bad1 = 1;
115 BadStateAtom2 bad2 = 2;
116 BadStateAtom3 bad3 = 3;
117 }
118}
119
120message GoodStateAtoms {
121 oneof event {
122 GoodStateAtom1 good1 = 1;
123 GoodStateAtom2 good2 = 2;
124 }
125}
126
127// The atom has only primary field but no exclusive state field.
128message BadStateAtom1 {
129 optional int32 uid = 1
130 [(android.os.statsd.stateFieldOption).option = PRIMARY];
131}
132
133// Only primative types can be annotated.
134message BadStateAtom2 {
135 repeated android.os.statsd.AttributionNode attribution = 1
136 [(android.os.statsd.stateFieldOption).option = PRIMARY];
137 optional int32 state = 2
138 [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
139}
140
141// Having 2 exclusive state field in the atom means the atom is badly designed.
142// E.g., putting bluetooth state and wifi state in the same atom.
143message BadStateAtom3 {
144 optional int32 uid = 1
145 [(android.os.statsd.stateFieldOption).option = PRIMARY];
146 optional int32 state = 2
147 [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
148 optional int32 state2 = 3
149 [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
150}
151
152message GoodStateAtom1 {
153 optional int32 uid = 1
154 [(android.os.statsd.stateFieldOption).option = PRIMARY];
155 optional int32 state = 2
156 [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
157}
158
159// Atoms can have exclusive state field, but no primary field. That means
160// the state is globally exclusive (e.g., DisplayState).
161message GoodStateAtom2 {
162 optional int32 uid = 1;
163 optional int32 state = 2
164 [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
165}
166
167// We can have more than one primary fields. That means their combination is a
168// primary key.
169message GoodStateAtom3 {
170 optional int32 uid = 1
171 [(android.os.statsd.stateFieldOption).option = PRIMARY];
172 optional int32 tid = 2
173 [(android.os.statsd.stateFieldOption).option = PRIMARY];
174 optional int32 state = 3
175 [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
176}