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/proto_logging/stats/atoms.proto"; 20import "frameworks/proto_logging/stats/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 float float_field = 2; 45 optional int64 int64_field = 3; 46 optional uint64 uint64_field = 4; 47 optional int32 int32_field = 5; 48 optional bool bool_field = 6; 49 optional string string_field = 7; 50 optional uint32 uint32_field = 8; 51 optional AnEnum enum_field = 9; 52 repeated float repeated_float_field = 10; 53 repeated int64 repeated_int64_field = 11; 54 repeated int32 repeated_int32_field = 12; 55 repeated bool repeated_bool_field = 13; 56 repeated string repeated_string_field = 14; 57} 58 59// Separated from AllTypesAtom because tests can't properly check atoms with multiple enum type 60// fields 61message RepeatedEnumAtom { 62 repeated AnEnum repeated_enum_field = 1; 63} 64 65message Event { 66 oneof pushed { 67 OutOfOrderAtom out_of_order_atom = 2; 68 IntAtom int_atom = 1; 69 AnotherIntAtom another_int_atom = 3; 70 AllTypesAtom all_types_atom = 4; 71 RepeatedEnumAtom repeated_enum_atom = 5; 72 } 73} 74 75message BadTypesAtom { 76 optional IntAtom bad_int_atom = 1; 77 optional bytes bad_bytes = 2; 78 optional double double_field = 3; 79 optional fixed64 fixed64_field = 4; 80 optional fixed32 fixed32_field = 5; 81 optional sfixed64 sfixed64_field = 6; 82 optional sfixed32 sfixed32_field = 7; 83 optional sint64 sint64_field = 8; 84 optional sint32 sint32_field = 9; 85 repeated double double_repeated_field = 10; 86 repeated fixed64 fixed64_repeated_field = 11; 87 repeated fixed32 fixed32_repeated_field = 12; 88 repeated sfixed64 sfixed64_repeated_field = 13; 89 repeated sfixed32 sfixed32_repeated_field = 14; 90 repeated sint64 sint64_repeated_field = 15; 91 repeated sint32 sint32_repeated_field = 16; 92 repeated uint64 uint64_repeated_field = 17; 93 repeated uint32 uint32_repeated_field = 18; 94 repeated IntAtom bad_int_atom_repeated_field = 19; 95 repeated bytes bad_bytes_repeated_field = 20; 96} 97 98message BadTypesEvent { 99 oneof pushed { 100 BadTypesAtom bad_types_atom = 1; 101 } 102} 103 104message BadSkippedFieldSingleAtom { 105 optional int32 field2 = 2; 106} 107 108message BadSkippedFieldSingle { 109 oneof pushed { 110 BadSkippedFieldSingleAtom bad = 1; 111 } 112} 113 114message BadSkippedFieldMultipleAtom { 115 optional int32 field1 = 1; 116 optional int32 field3 = 3; 117 optional int32 field5 = 5; 118} 119 120message BadSkippedFieldMultiple { 121 oneof pushed { 122 BadSkippedFieldMultipleAtom bad = 1; 123 } 124} 125 126message BadAttributionNodePositionAtom { 127 optional int32 field1 = 1; 128 repeated android.os.statsd.AttributionNode attribution = 2; 129} 130 131message BadAttributionNodePosition { 132 oneof pushed { BadAttributionNodePositionAtom bad = 1; } 133} 134 135message GoodEventWithBinaryFieldAtom { 136 oneof pushed { GoodBinaryFieldAtom field1 = 1; } 137} 138 139message ComplexField { 140 optional string str = 1; 141} 142 143message GoodBinaryFieldAtom { 144 optional int32 field1 = 1; 145 optional ComplexField bf = 2 [(android.os.statsd.log_mode) = MODE_BYTES]; 146} 147 148message BadEventWithBinaryFieldAtom { 149 oneof pushed { BadBinaryFieldAtom field1 = 1; } 150} 151 152message BadBinaryFieldAtom { 153 optional int32 field1 = 1; 154 optional ComplexField bf = 2; 155} 156 157message BadStateAtoms { 158 oneof pushed { 159 BadStateAtom1 bad1 = 1; 160 BadStateAtom2 bad2 = 2; 161 BadStateAtom3 bad3 = 3; 162 BadStateAtom4 bad4 = 4; 163 } 164} 165 166message GoodStateAtoms { 167 oneof pushed { 168 GoodStateAtom1 good1 = 1; 169 GoodStateAtom2 good2 = 2; 170 } 171} 172 173// The atom has only primary field but no exclusive state field. 174message BadStateAtom1 { 175 optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true]; 176} 177 178// Only primative types can be annotated. 179message BadStateAtom2 { 180 repeated android.os.statsd.AttributionNode attribution = 1 181 [(android.os.statsd.state_field_option).primary_field = true]; 182 optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true]; 183} 184 185// Having 2 exclusive state field in the atom means the atom is badly designed. 186// E.g., putting bluetooth state and wifi state in the same atom. 187message BadStateAtom3 { 188 optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true]; 189 optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true]; 190 optional int32 state2 = 3 [(android.os.statsd.state_field_option).exclusive_state = true]; 191} 192 193// Repeated fields can't have state annotations. 194message BadStateAtom4 { 195 repeated int32 state = 1 [(android.os.statsd.state_field_option).exclusive_state = true]; 196} 197 198message GoodStateAtom1 { 199 optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true]; 200 optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true]; 201} 202 203// Atoms can have exclusive state field, but no primary field. That means 204// the state is globally exclusive (e.g., DisplayState). 205message GoodStateAtom2 { 206 optional int32 uid = 1; 207 optional int32 state = 2 [(android.os.statsd.state_field_option).exclusive_state = true]; 208} 209 210// We can have more than one primary fields. That means their combination is a 211// primary key. 212message GoodStateAtom3 { 213 optional int32 uid = 1 [(android.os.statsd.state_field_option).primary_field = true]; 214 optional int32 tid = 2 [(android.os.statsd.state_field_option).primary_field = true]; 215 optional int32 state = 3 [(android.os.statsd.state_field_option).exclusive_state = true]; 216} 217 218message BadUidAtoms { 219 oneof pushed { 220 BadUidAtom1 bad1 = 1; 221 BadUidAtom2 bad2 = 2; 222 } 223} 224 225message GoodUidAtoms { 226 oneof pushed { 227 GoodUidAtom1 good1 = 1; 228 GoodUidAtom2 good2 = 2; 229 } 230} 231 232// The only repeated field type that can have is_uid annotation is int32. 233message BadUidAtom1 { 234 repeated int64 uid = 1 [(android.os.statsd.is_uid) = true]; 235} 236 237message BadUidAtom2 { 238 optional string uid = 1 [(android.os.statsd.is_uid) = true]; 239} 240 241message GoodUidAtom1 { 242 optional int32 uid = 1 [(android.os.statsd.is_uid) = true]; 243} 244 245message GoodUidAtom2 { 246 repeated int32 uid = 1 [(android.os.statsd.is_uid) = true]; 247} 248 249message ModuleOneAtom { 250 optional int32 field = 1 [(android.os.statsd.is_uid) = true]; 251} 252 253message ModuleTwoAtom { 254 optional int32 field = 1; 255} 256 257message ModuleOneAndTwoAtom { 258 optional int32 field = 1 [(android.os.statsd.state_field_option).exclusive_state = true]; 259} 260 261message NoModuleAtom { 262 optional string field = 1; 263} 264 265message ModuleAtoms { 266 oneof pushed { 267 ModuleOneAtom module_one_atom = 1 [(android.os.statsd.module) = "module1"]; 268 ModuleTwoAtom module_two_atom = 2 [(android.os.statsd.module) = "module2"]; 269 ModuleOneAndTwoAtom module_one_and_two_atom = 3 [ 270 (android.os.statsd.module) = "module1", (android.os.statsd.module) = "module2" 271 ]; 272 NoModuleAtom no_module_atom = 4; 273 } 274} 275 276message PushedAndPulledAtoms { 277 oneof pushed { 278 IntAtom int_atom_1 = 1; 279 } 280 281 oneof pulled { 282 OutOfOrderAtom out_of_order_atom = 99999; 283 AnotherIntAtom another_int_atom = 10000; 284 } 285} 286 287message VendorAtoms { 288 optional IntAtom pushed_atom_100000 = 100000; 289 optional AnotherIntAtom pulled_atom_199999 = 199999; 290} 291 292message ExtensionAtoms { 293 oneof pushed { 294 IntAtom int_atom_1 = 1; 295 } 296 oneof pulled { 297 OutOfOrderAtom out_of_order_atom = 10000; 298 } 299 300 extensions 9999; // Pushed atom extension, ExtensionAtomPushed 301 302 extensions 99999; // Pulled atom extension, ExtensionAtomPulled 303} 304