Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 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 | |
| 17 | syntax = "proto2"; |
| 18 | |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 19 | import "frameworks/base/cmds/statsd/src/atoms.proto"; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 20 | import "frameworks/base/cmds/statsd/src/atom_field_options.proto"; |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 21 | |
| 22 | package android.stats_log_api_gen; |
| 23 | |
| 24 | message IntAtom { |
| 25 | optional int32 field1 = 1; |
| 26 | } |
| 27 | |
| 28 | message AnotherIntAtom { |
| 29 | optional int32 field1 = 1; |
| 30 | } |
| 31 | |
| 32 | message OutOfOrderAtom { |
| 33 | optional int32 field2 = 2; |
| 34 | optional int32 field1 = 1; |
| 35 | } |
| 36 | |
| 37 | enum AnEnum { |
| 38 | VALUE0 = 0; |
| 39 | VALUE1 = 1; |
| 40 | } |
| 41 | |
| 42 | message AllTypesAtom { |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 43 | repeated android.os.statsd.AttributionNode attribution_chain = 1; |
Yangster-mac | 7604aea | 2017-12-11 22:55:49 -0800 | [diff] [blame] | 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; |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | message 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 | |
| 70 | message BadTypesAtom { |
| 71 | optional IntAtom bad_int_atom = 1; |
| 72 | optional bytes bad_bytes = 2; |
| 73 | } |
| 74 | |
| 75 | message BadTypesEvent { |
| 76 | oneof event { |
| 77 | BadTypesAtom bad_types_atom = 1; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | message BadSkippedFieldSingleAtom { |
| 82 | optional int32 field2 = 2; |
| 83 | } |
| 84 | |
| 85 | message BadSkippedFieldSingle { |
| 86 | oneof event { |
| 87 | BadSkippedFieldSingleAtom bad = 1; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | message BadSkippedFieldMultipleAtom { |
| 92 | optional int32 field1 = 1; |
| 93 | optional int32 field3 = 3; |
| 94 | optional int32 field5 = 5; |
| 95 | } |
| 96 | |
| 97 | message BadSkippedFieldMultiple { |
| 98 | oneof event { |
| 99 | BadSkippedFieldMultipleAtom bad = 1; |
| 100 | } |
| 101 | } |
| 102 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 103 | message BadAttributionNodePositionAtom { |
Yangster-mac | 7604aea | 2017-12-11 22:55:49 -0800 | [diff] [blame] | 104 | optional int32 field1 = 1; |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 105 | repeated android.os.statsd.AttributionNode attribution = 2; |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 108 | message BadAttributionNodePosition { |
| 109 | oneof event { BadAttributionNodePositionAtom bad = 1; } |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Yao Chen | bbdd67d | 2018-10-24 12:15:56 -0700 | [diff] [blame] | 112 | message GoodEventWithBinaryFieldAtom { |
| 113 | oneof event { GoodBinaryFieldAtom field1 = 1; } |
| 114 | } |
| 115 | |
| 116 | message ComplexField { |
| 117 | optional string str = 1; |
| 118 | } |
| 119 | |
| 120 | message GoodBinaryFieldAtom { |
| 121 | optional int32 field1 = 1; |
| 122 | optional ComplexField bf = 2 [(android.os.statsd.log_mode) = MODE_BYTES]; |
| 123 | } |
| 124 | |
| 125 | message BadEventWithBinaryFieldAtom { |
| 126 | oneof event { BadBinaryFieldAtom field1 = 1; } |
| 127 | } |
| 128 | |
| 129 | message BadBinaryFieldAtom { |
| 130 | optional int32 field1 = 1; |
| 131 | optional ComplexField bf = 2; |
| 132 | } |
| 133 | |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 134 | message BadStateAtoms { |
| 135 | oneof event { |
| 136 | BadStateAtom1 bad1 = 1; |
| 137 | BadStateAtom2 bad2 = 2; |
| 138 | BadStateAtom3 bad3 = 3; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | message GoodStateAtoms { |
| 143 | oneof event { |
| 144 | GoodStateAtom1 good1 = 1; |
| 145 | GoodStateAtom2 good2 = 2; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | // The atom has only primary field but no exclusive state field. |
| 150 | message BadStateAtom1 { |
| 151 | optional int32 uid = 1 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 152 | [(android.os.statsd.state_field_option).option = PRIMARY]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | // Only primative types can be annotated. |
| 156 | message BadStateAtom2 { |
| 157 | repeated android.os.statsd.AttributionNode attribution = 1 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 158 | [(android.os.statsd.state_field_option).option = PRIMARY]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 159 | optional int32 state = 2 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 160 | [(android.os.statsd.state_field_option).option = EXCLUSIVE]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // Having 2 exclusive state field in the atom means the atom is badly designed. |
| 164 | // E.g., putting bluetooth state and wifi state in the same atom. |
| 165 | message BadStateAtom3 { |
| 166 | optional int32 uid = 1 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 167 | [(android.os.statsd.state_field_option).option = PRIMARY]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 168 | optional int32 state = 2 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 169 | [(android.os.statsd.state_field_option).option = EXCLUSIVE]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 170 | optional int32 state2 = 3 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 171 | [(android.os.statsd.state_field_option).option = EXCLUSIVE]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | message GoodStateAtom1 { |
| 175 | optional int32 uid = 1 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 176 | [(android.os.statsd.state_field_option).option = PRIMARY]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 177 | optional int32 state = 2 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 178 | [(android.os.statsd.state_field_option).option = EXCLUSIVE]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | // Atoms can have exclusive state field, but no primary field. That means |
| 182 | // the state is globally exclusive (e.g., DisplayState). |
| 183 | message GoodStateAtom2 { |
| 184 | optional int32 uid = 1; |
| 185 | optional int32 state = 2 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 186 | [(android.os.statsd.state_field_option).option = EXCLUSIVE]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | // We can have more than one primary fields. That means their combination is a |
| 190 | // primary key. |
| 191 | message GoodStateAtom3 { |
| 192 | optional int32 uid = 1 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 193 | [(android.os.statsd.state_field_option).option = PRIMARY]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 194 | optional int32 tid = 2 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 195 | [(android.os.statsd.state_field_option).option = PRIMARY]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 196 | optional int32 state = 3 |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 197 | [(android.os.statsd.state_field_option).option = EXCLUSIVE]; |
Andrei Onea | da01ea5 | 2019-01-30 15:28:36 +0000 | [diff] [blame^] | 198 | } |
| 199 | |
| 200 | message WhitelistedAtom { |
| 201 | optional int32 field = 1; |
| 202 | } |
| 203 | |
| 204 | message NonWhitelistedAtom { |
| 205 | optional int32 field = 1; |
| 206 | } |
| 207 | |
| 208 | message ListedAtoms { |
| 209 | oneof event { |
| 210 | // Atoms can be whitelisted i.e. they can be triggered by any source |
| 211 | WhitelistedAtom whitelisted_atom = 1 [(android.os.statsd.allow_from_any_uid) = true]; |
| 212 | // Atoms are not whitelisted by default, so they can only be triggered |
| 213 | // by whitelisted sources |
| 214 | NonWhitelistedAtom non_whitelisted_atom = 2; |
| 215 | } |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 216 | } |