blob: aaa488e44fee3e2ba4ecb7d55ec0853830ae862a [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;
Tej Singhc88fbf12020-02-20 18:14:50 -080044 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;
Yao Chend54f9dd2017-10-17 17:37:48 +000058}
59
60message Event {
61 oneof event {
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;
Tej Singhc88fbf12020-02-20 18:14:50 -080072 repeated int32 repeated_field = 3;
73 optional double double_field = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +000074}
75
76message BadTypesEvent {
77 oneof event {
78 BadTypesAtom bad_types_atom = 1;
79 }
80}
81
82message BadSkippedFieldSingleAtom {
83 optional int32 field2 = 2;
84}
85
86message BadSkippedFieldSingle {
87 oneof event {
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 event {
100 BadSkippedFieldMultipleAtom bad = 1;
101 }
102}
103
Yangster-mac20877162017-12-22 17:19:39 -0800104message BadAttributionNodePositionAtom {
Yangster-mac7604aea2017-12-11 22:55:49 -0800105 optional int32 field1 = 1;
Yangster-mac20877162017-12-22 17:19:39 -0800106 repeated android.os.statsd.AttributionNode attribution = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000107}
108
Yangster-mac20877162017-12-22 17:19:39 -0800109message BadAttributionNodePosition {
110 oneof event { BadAttributionNodePositionAtom bad = 1; }
Yao Chend54f9dd2017-10-17 17:37:48 +0000111}
112
Yao Chenbbdd67d2018-10-24 12:15:56 -0700113message GoodEventWithBinaryFieldAtom {
114 oneof event { 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 event { BadBinaryFieldAtom field1 = 1; }
128}
129
130message BadBinaryFieldAtom {
131 optional int32 field1 = 1;
132 optional ComplexField bf = 2;
133}
134
Yao Chen9c1debe2018-02-19 14:39:19 -0800135message BadStateAtoms {
136 oneof event {
137 BadStateAtom1 bad1 = 1;
138 BadStateAtom2 bad2 = 2;
139 BadStateAtom3 bad3 = 3;
140 }
141}
142
143message GoodStateAtoms {
144 oneof event {
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 {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -0700152 optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true];
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
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -0700158 [(android.os.statsd.state_field_option).primary_field = true];
159 optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
Yao Chen9c1debe2018-02-19 14:39:19 -0800160}
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 {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -0700165 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];
Yao Chen9c1debe2018-02-19 14:39:19 -0800168}
169
170message GoodStateAtom1 {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -0700171 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];
Yao Chen9c1debe2018-02-19 14:39:19 -0800173}
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;
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -0700179 optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true];
Yao Chen9c1debe2018-02-19 14:39:19 -0800180}
181
182// We can have more than one primary fields. That means their combination is a
183// primary key.
184message GoodStateAtom3 {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -0700185 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];
Andrei Oneada01ea52019-01-30 15:28:36 +0000188}
189
Tej Singh810eeb32019-03-07 19:08:52 -0800190message ModuleOneAtom {
Muhammad Qureshib13a3212020-03-12 07:37:13 -0700191 optional int32 field = 1 [(android.os.statsd.is_uid) = true];
Tej Singh810eeb32019-03-07 19:08:52 -0800192}
193
194message ModuleTwoAtom {
195 optional int32 field = 1;
196}
197
Muhammad Qureshif8460f72020-03-05 09:48:48 -0800198message ModuleOneAndTwoAtom {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -0700199 optional int32 field = 1 [(android.os.statsd.state_field_option).exclusive_state = true];
Muhammad Qureshif8460f72020-03-05 09:48:48 -0800200}
201
Tej Singh810eeb32019-03-07 19:08:52 -0800202message NoModuleAtom {
203 optional string field = 1;
204}
205
206message ModuleAtoms {
207 oneof event {
Muhammad Qureshibcf66062019-12-23 17:55:48 -0800208 ModuleOneAtom module_one_atom = 1 [(android.os.statsd.module) = "module1"];
209 ModuleTwoAtom module_two_atom = 2 [(android.os.statsd.module) = "module2"];
Muhammad Qureshif8460f72020-03-05 09:48:48 -0800210 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;
Tej Singh810eeb32019-03-07 19:08:52 -0800214 }
Muhammad Qureshibcf66062019-12-23 17:55:48 -0800215}