blob: 8527185d38910adab4a8f42f120fd32cd67cac0a [file] [log] [blame]
Yao Chen9c1debe2018-02-19 14:39:19 -08001/*
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
tsaichristine5adc7e02020-01-14 17:07:39 -080026// Used to annotate an atom that represents a state change. A state change atom must have exactly
27// ONE exclusive state field, and any number of primary key fields. For example, message
28// UidProcessStateChanged {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070029// optional int32 uid = 1 [(state_field_option).primary_field = true];
30// optional android.app.ProcessStateEnum state =
31// 2 [(state_field_option).exclusive_state = true];
Yao Chen9c1debe2018-02-19 14:39:19 -080032// }
tsaichristine5adc7e02020-01-14 17:07:39 -080033// Each UidProcessStateChanged atom event represents a state change for a specific uid.
Yao Chen9c1debe2018-02-19 14:39:19 -080034// A new state automatically overrides the previous state.
35//
tsaichristine5adc7e02020-01-14 17:07:39 -080036// If the atom has 2 or more primary fields, it means the combination of the
37// primary fields are the primary key.
Yao Chen9c1debe2018-02-19 14:39:19 -080038// For example:
39// message ThreadStateChanged {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070040// optional int32 pid = 1 [(state_field_option).primary_field = true];
41// optional int32 tid = 2 [(state_field_option).primary_field = true];
42// optional int32 state = 3 [(state_field_option).exclusive_state = true];
Yao Chen9c1debe2018-02-19 14:39:19 -080043// }
44//
45// Sometimes, there is no primary key field, when the state is GLOBAL.
46// For example,
Yao Chen9c1debe2018-02-19 14:39:19 -080047// message ScreenStateChanged {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070048// optional android.view.DisplayStateEnum state =
49// 1 [(state_field_option).exclusive_state = true];
Yao Chen9c1debe2018-02-19 14:39:19 -080050// }
51//
tsaichristine5adc7e02020-01-14 17:07:39 -080052// For state atoms with attribution chain, sometimes the primary key is the first uid in the chain.
53// For example:
54// message AudioStateChanged {
55// repeated AttributionNode attribution_node = 1
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070056// [(stateFieldOption).primary_field_first_uid = true];
tsaichristine5adc7e02020-01-14 17:07:39 -080057//
58// enum State {
59// OFF = 0;
60// ON = 1;
61// // RESET indicates all audio stopped. Used when it (re)starts (e.g. after it crashes).
62// RESET = 2;
63// }
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070064// optional State state = 2 [(stateFieldOption).exclusive_state = true];
tsaichristine5adc7e02020-01-14 17:07:39 -080065// }
Yao Chen9c1debe2018-02-19 14:39:19 -080066message StateAtomFieldOption {
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070067 // Fields that represent the key that the state belongs to.
68 // Used on simple proto fields. Do not use on attribution chains.
69 optional bool primary_field = 1 [default = false];
70
71 // The field that represents the state. It's an exclusive state.
72 optional bool exclusive_state = 2 [default = false];
73
74 // Used on an attribution chain field to indicate that the first uid is the
75 // primary field.
76 optional bool primary_field_first_uid = 3 [default = false];
tsaichristine5adc7e02020-01-14 17:07:39 -080077
78 // Note: We cannot annotate directly on the enums because many enums are imported from other
79 // proto files in the platform. proto-lite cc library does not support annotations unfortunately
80
81 // Knowing the default state value allows state trackers to remove entries that become the
82 // default state. If there is no default value specified, the default value is unknown, and all
83 // states will be tracked in memory.
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070084 optional int32 default_state_value = 4;
tsaichristine5adc7e02020-01-14 17:07:39 -080085
86 // A reset state signals all states go to default value. For example, BLE reset means all active
87 // BLE scans are to be turned off.
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070088 optional int32 trigger_state_reset_value = 5;
tsaichristine5adc7e02020-01-14 17:07:39 -080089
90 // If the state change needs to count nesting.
Muhammad Qureshi3f9c3302020-04-01 16:11:53 -070091 optional bool nested = 6 [default = true];
Yao Chen9c1debe2018-02-19 14:39:19 -080092}
93
Yao Chenbbdd67d2018-10-24 12:15:56 -070094// Used to generate StatsLog.write APIs.
95enum LogMode {
96 MODE_UNSET = 0;
97 // Log fields as their actual types e.g., all primary data types.
98 // Or fields that are hardcoded in stats_log_api_gen tool e.g., AttributionNode
99 MODE_AUTOMATIC = 1;
100 // Log fields in their proto binary format. These fields will not be parsed in statsd
101 MODE_BYTES = 2;
102}
103
Yao Chen9c1debe2018-02-19 14:39:19 -0800104extend google.protobuf.FieldOptions {
105 // Flags to decorate an atom that presents a state change.
Yangster-macb6b77c62018-10-12 19:33:24 -0700106 optional StateAtomFieldOption state_field_option = 50000;
Yao Chenc40a19d2018-03-15 16:48:25 -0700107
108 // Flags to decorate the uid fields in an atom.
109 optional bool is_uid = 50001 [default = false];
Yao Chenbbdd67d2018-10-24 12:15:56 -0700110
111 optional LogMode log_mode = 50002 [default = MODE_AUTOMATIC];
Andrei Oneada01ea52019-01-30 15:28:36 +0000112
113 optional bool allow_from_any_uid = 50003 [default = false];
Tej Singh810eeb32019-03-07 19:08:52 -0800114
Muhammad Qureshif8460f72020-03-05 09:48:48 -0800115 repeated string module = 50004;
Muhammad Qureshi9b995802020-03-20 13:55:51 -0700116
117 optional bool truncate_timestamp = 50005 [default = false];
Muhammad Qureshibcf66062019-12-23 17:55:48 -0800118}