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; |
Tej Singh | c88fbf1 | 2020-02-20 18:14:50 -0800 | [diff] [blame] | 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 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 Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | message 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 | |
| 69 | message BadTypesAtom { |
| 70 | optional IntAtom bad_int_atom = 1; |
| 71 | optional bytes bad_bytes = 2; |
Tej Singh | c88fbf1 | 2020-02-20 18:14:50 -0800 | [diff] [blame] | 72 | repeated int32 repeated_field = 3; |
| 73 | optional double double_field = 4; |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | message BadTypesEvent { |
| 77 | oneof event { |
| 78 | BadTypesAtom bad_types_atom = 1; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | message BadSkippedFieldSingleAtom { |
| 83 | optional int32 field2 = 2; |
| 84 | } |
| 85 | |
| 86 | message BadSkippedFieldSingle { |
| 87 | oneof event { |
| 88 | BadSkippedFieldSingleAtom bad = 1; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | message BadSkippedFieldMultipleAtom { |
| 93 | optional int32 field1 = 1; |
| 94 | optional int32 field3 = 3; |
| 95 | optional int32 field5 = 5; |
| 96 | } |
| 97 | |
| 98 | message BadSkippedFieldMultiple { |
| 99 | oneof event { |
| 100 | BadSkippedFieldMultipleAtom bad = 1; |
| 101 | } |
| 102 | } |
| 103 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 104 | message BadAttributionNodePositionAtom { |
Yangster-mac | 7604aea | 2017-12-11 22:55:49 -0800 | [diff] [blame] | 105 | optional int32 field1 = 1; |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 106 | repeated android.os.statsd.AttributionNode attribution = 2; |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 109 | message BadAttributionNodePosition { |
| 110 | oneof event { BadAttributionNodePositionAtom bad = 1; } |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Yao Chen | bbdd67d | 2018-10-24 12:15:56 -0700 | [diff] [blame] | 113 | message GoodEventWithBinaryFieldAtom { |
| 114 | oneof event { GoodBinaryFieldAtom field1 = 1; } |
| 115 | } |
| 116 | |
| 117 | message ComplexField { |
| 118 | optional string str = 1; |
| 119 | } |
| 120 | |
| 121 | message GoodBinaryFieldAtom { |
| 122 | optional int32 field1 = 1; |
| 123 | optional ComplexField bf = 2 [(android.os.statsd.log_mode) = MODE_BYTES]; |
| 124 | } |
| 125 | |
| 126 | message BadEventWithBinaryFieldAtom { |
| 127 | oneof event { BadBinaryFieldAtom field1 = 1; } |
| 128 | } |
| 129 | |
| 130 | message BadBinaryFieldAtom { |
| 131 | optional int32 field1 = 1; |
| 132 | optional ComplexField bf = 2; |
| 133 | } |
| 134 | |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 135 | message BadStateAtoms { |
| 136 | oneof event { |
| 137 | BadStateAtom1 bad1 = 1; |
| 138 | BadStateAtom2 bad2 = 2; |
| 139 | BadStateAtom3 bad3 = 3; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | message 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. |
| 151 | message BadStateAtom1 { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 152 | optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true]; |
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 |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 158 | [(android.os.statsd.state_field_option).primary_field = true]; |
| 159 | optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 160 | } |
| 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. |
| 164 | message BadStateAtom3 { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 165 | 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 Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | message GoodStateAtom1 { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 171 | 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 Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | // Atoms can have exclusive state field, but no primary field. That means |
| 176 | // the state is globally exclusive (e.g., DisplayState). |
| 177 | message GoodStateAtom2 { |
| 178 | optional int32 uid = 1; |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 179 | optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | // We can have more than one primary fields. That means their combination is a |
| 183 | // primary key. |
| 184 | message GoodStateAtom3 { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 185 | 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 Onea | da01ea5 | 2019-01-30 15:28:36 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Tej Singh | 810eeb3 | 2019-03-07 19:08:52 -0800 | [diff] [blame] | 190 | message ModuleOneAtom { |
Muhammad Qureshi | b13a321 | 2020-03-12 07:37:13 -0700 | [diff] [blame] | 191 | optional int32 field = 1 [(android.os.statsd.is_uid) = true]; |
Tej Singh | 810eeb3 | 2019-03-07 19:08:52 -0800 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | message ModuleTwoAtom { |
| 195 | optional int32 field = 1; |
| 196 | } |
| 197 | |
Muhammad Qureshi | f8460f7 | 2020-03-05 09:48:48 -0800 | [diff] [blame] | 198 | message ModuleOneAndTwoAtom { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 199 | optional int32 field = 1 [(android.os.statsd.state_field_option).exclusive_state = true]; |
Muhammad Qureshi | f8460f7 | 2020-03-05 09:48:48 -0800 | [diff] [blame] | 200 | } |
| 201 | |
Tej Singh | 810eeb3 | 2019-03-07 19:08:52 -0800 | [diff] [blame] | 202 | message NoModuleAtom { |
| 203 | optional string field = 1; |
| 204 | } |
| 205 | |
| 206 | message ModuleAtoms { |
| 207 | oneof event { |
Muhammad Qureshi | bcf6606 | 2019-12-23 17:55:48 -0800 | [diff] [blame] | 208 | ModuleOneAtom module_one_atom = 1 [(android.os.statsd.module) = "module1"]; |
| 209 | ModuleTwoAtom module_two_atom = 2 [(android.os.statsd.module) = "module2"]; |
Muhammad Qureshi | f8460f7 | 2020-03-05 09:48:48 -0800 | [diff] [blame] | 210 | 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 Singh | 810eeb3 | 2019-03-07 19:08:52 -0800 | [diff] [blame] | 214 | } |
Muhammad Qureshi | bcf6606 | 2019-12-23 17:55:48 -0800 | [diff] [blame] | 215 | } |