Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
| 19 | package android.os.statsd; |
| 20 | option java_package = "com.android.os"; |
| 21 | option java_multiple_files = true; |
| 22 | option java_outer_classname = "AtomFieldOptions"; |
| 23 | |
| 24 | import "google/protobuf/descriptor.proto"; |
| 25 | |
| 26 | enum StateField { |
| 27 | // Default value for fields that are not primary or exclusive state. |
| 28 | STATE_FIELD_UNSET = 0; |
| 29 | // Fields that represent the key that the state belongs to. |
| 30 | PRIMARY = 1; |
| 31 | // The field that represents the state. It's an exclusive state. |
| 32 | EXCLUSIVE = 2; |
| 33 | } |
| 34 | |
| 35 | // Used to annotate an atom that reprsents a state change. A state change atom must have exactly ONE |
| 36 | // exclusive state field, and any number of primary key fields. |
| 37 | // For example, |
| 38 | // message UidProcessStateChanged { |
| 39 | // optional int32 uid = 1 [(stateFieldOption).option = PRIMARY]; |
| 40 | // optional android.app.ProcessStateEnum state = 2 [(stateFieldOption).option = EXCLUSIVE]; |
| 41 | // } |
| 42 | // Each of this UidProcessStateChanged atom represents a state change for a specific uid. |
| 43 | // A new state automatically overrides the previous state. |
| 44 | // |
| 45 | // If the atom has 2 or more primary fields, it means the combination of the primary fields are |
| 46 | // the primary key. |
| 47 | // For example: |
| 48 | // message ThreadStateChanged { |
| 49 | // optional int32 pid = 1 [(stateFieldOption).option = PRIMARY]; |
| 50 | // optional int32 tid = 2 [(stateFieldOption).option = PRIMARY]; |
| 51 | // optional int32 state = 3 [(stateFieldOption).option = EXCLUSIVE]; |
| 52 | // } |
| 53 | // |
| 54 | // Sometimes, there is no primary key field, when the state is GLOBAL. |
| 55 | // For example, |
| 56 | // |
| 57 | // message ScreenStateChanged { |
| 58 | // optional android.view.DisplayStateEnum state = 1 [(stateFieldOption).option = EXCLUSIVE]; |
| 59 | // } |
| 60 | // |
| 61 | // Only fields of primary types can be annotated. AttributionNode cannot be primary keys (and they |
| 62 | // usually are not). |
| 63 | message StateAtomFieldOption { |
| 64 | optional StateField option = 1 [default = STATE_FIELD_UNSET]; |
| 65 | } |
| 66 | |
| 67 | extend google.protobuf.FieldOptions { |
| 68 | // Flags to decorate an atom that presents a state change. |
| 69 | optional StateAtomFieldOption stateFieldOption = 50000; |
| 70 | } |