• 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/base/cmds/statsd/src/atoms.proto";
20import "frameworks/base/cmds/statsd/src/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 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;
59}
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
103message BadAttributionNodePositionAtom {
104  optional int32 field1 = 1;
105  repeated android.os.statsd.AttributionNode attribution = 2;
106}
107
108message BadAttributionNodePosition {
109  oneof event { BadAttributionNodePositionAtom bad = 1; }
110}
111
112message 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}