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 GoodEventWithBinaryFieldAtom { 113 oneof event { GoodBinaryFieldAtom field1 = 1; } 114} 115 116message ComplexField { 117 optional string str = 1; 118} 119 120message GoodBinaryFieldAtom { 121 optional int32 field1 = 1; 122 optional ComplexField bf = 2 [(android.os.statsd.log_mode) = MODE_BYTES]; 123} 124 125message BadEventWithBinaryFieldAtom { 126 oneof event { BadBinaryFieldAtom field1 = 1; } 127} 128 129message BadBinaryFieldAtom { 130 optional int32 field1 = 1; 131 optional ComplexField bf = 2; 132} 133 134message BadStateAtoms { 135 oneof event { 136 BadStateAtom1 bad1 = 1; 137 BadStateAtom2 bad2 = 2; 138 BadStateAtom3 bad3 = 3; 139 } 140} 141 142message 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. 150message BadStateAtom1 { 151 optional int32 uid = 1 152 [(android.os.statsd.state_field_option).option = PRIMARY]; 153} 154 155// Only primative types can be annotated. 156message BadStateAtom2 { 157 repeated android.os.statsd.AttributionNode attribution = 1 158 [(android.os.statsd.state_field_option).option = PRIMARY]; 159 optional int32 state = 2 160 [(android.os.statsd.state_field_option).option = EXCLUSIVE]; 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. 165message BadStateAtom3 { 166 optional int32 uid = 1 167 [(android.os.statsd.state_field_option).option = PRIMARY]; 168 optional int32 state = 2 169 [(android.os.statsd.state_field_option).option = EXCLUSIVE]; 170 optional int32 state2 = 3 171 [(android.os.statsd.state_field_option).option = EXCLUSIVE]; 172} 173 174message GoodStateAtom1 { 175 optional int32 uid = 1 176 [(android.os.statsd.state_field_option).option = PRIMARY]; 177 optional int32 state = 2 178 [(android.os.statsd.state_field_option).option = EXCLUSIVE]; 179} 180 181// Atoms can have exclusive state field, but no primary field. That means 182// the state is globally exclusive (e.g., DisplayState). 183message GoodStateAtom2 { 184 optional int32 uid = 1; 185 optional int32 state = 2 186 [(android.os.statsd.state_field_option).option = EXCLUSIVE]; 187} 188 189// We can have more than one primary fields. That means their combination is a 190// primary key. 191message GoodStateAtom3 { 192 optional int32 uid = 1 193 [(android.os.statsd.state_field_option).option = PRIMARY]; 194 optional int32 tid = 2 195 [(android.os.statsd.state_field_option).option = PRIMARY]; 196 optional int32 state = 3 197 [(android.os.statsd.state_field_option).option = EXCLUSIVE]; 198} 199 200message WhitelistedAtom { 201 optional int32 field = 1; 202} 203 204message NonWhitelistedAtom { 205 optional int32 field = 1; 206} 207 208message 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 } 216} 217 218message ModuleOneAtom { 219 optional int32 field = 1; 220} 221 222message ModuleTwoAtom { 223 optional int32 field = 1; 224} 225 226message NoModuleAtom { 227 optional string field = 1; 228} 229 230message ModuleAtoms { 231 oneof event { 232 ModuleOneAtom module_one_atom = 1 [(android.os.statsd.log_from_module) = "module1"]; 233 ModuleTwoAtom module_two_atom = 2 [(android.os.statsd.log_from_module) = "module2"]; 234 NoModuleAtom no_module_atom = 3; 235 } 236}