• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17syntax = "proto2";
18
19package android.os.statsd;
20option java_package = "com.android.os";
21option java_multiple_files = true;
22option java_outer_classname = "AtomFieldOptions";
23
24import "google/protobuf/descriptor.proto";
25
26enum 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 [(state_field_option).option = PRIMARY];
40//    optional android.app.ProcessStateEnum state = 2 [(state_field_option).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  [(state_field_option).option = PRIMARY];
50//    optional int32 tid = 2  [(state_field_option).option = PRIMARY];
51//    optional int32 state = 3 [(state_field_option).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 [(state_field_option).option = EXCLUSIVE];
59// }
60//
61// Only fields of primary types can be annotated. AttributionNode cannot be primary keys (and they
62// usually are not).
63message StateAtomFieldOption {
64    optional StateField option = 1 [default = STATE_FIELD_UNSET];
65}
66
67// Used to generate StatsLog.write APIs.
68enum LogMode {
69    MODE_UNSET = 0;
70    // Log fields as their actual types e.g., all primary data types.
71    // Or fields that are hardcoded in stats_log_api_gen tool e.g., AttributionNode
72    MODE_AUTOMATIC = 1;
73    // Log fields in their proto binary format. These fields will not be parsed in statsd
74    MODE_BYTES = 2;
75}
76
77extend google.protobuf.FieldOptions {
78    // Flags to decorate an atom that presents a state change.
79    optional StateAtomFieldOption state_field_option = 50000;
80
81    // Flags to decorate the uid fields in an atom.
82    optional bool is_uid = 50001 [default = false];
83
84    optional LogMode log_mode = 50002 [default = MODE_AUTOMATIC];
85
86    optional bool allow_from_any_uid = 50003 [default = false];
87
88    optional string log_from_module = 50004;
89}