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 | |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 26 | // 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 Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 29 | // 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 Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 32 | // } |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 33 | // Each UidProcessStateChanged atom event represents a state change for a specific uid. |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 34 | // A new state automatically overrides the previous state. |
| 35 | // |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 36 | // If the atom has 2 or more primary fields, it means the combination of the |
| 37 | // primary fields are the primary key. |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 38 | // For example: |
| 39 | // message ThreadStateChanged { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 40 | // 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 Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 43 | // } |
| 44 | // |
| 45 | // Sometimes, there is no primary key field, when the state is GLOBAL. |
| 46 | // For example, |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 47 | // message ScreenStateChanged { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 48 | // optional android.view.DisplayStateEnum state = |
| 49 | // 1 [(state_field_option).exclusive_state = true]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 50 | // } |
| 51 | // |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 52 | // 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 Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 56 | // [(stateFieldOption).primary_field_first_uid = true]; |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 57 | // |
| 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 Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 64 | // optional State state = 2 [(stateFieldOption).exclusive_state = true]; |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 65 | // } |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 66 | message StateAtomFieldOption { |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 67 | // 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]; |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 77 | |
| 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 Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 84 | optional int32 default_state_value = 4; |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 85 | |
| 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 Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 88 | optional int32 trigger_state_reset_value = 5; |
tsaichristine | 5adc7e0 | 2020-01-14 17:07:39 -0800 | [diff] [blame] | 89 | |
| 90 | // If the state change needs to count nesting. |
Muhammad Qureshi | 3f9c330 | 2020-04-01 16:11:53 -0700 | [diff] [blame] | 91 | optional bool nested = 6 [default = true]; |
Yao Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Yao Chen | bbdd67d | 2018-10-24 12:15:56 -0700 | [diff] [blame] | 94 | // Used to generate StatsLog.write APIs. |
| 95 | enum 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 Chen | 9c1debe | 2018-02-19 14:39:19 -0800 | [diff] [blame] | 104 | extend google.protobuf.FieldOptions { |
| 105 | // Flags to decorate an atom that presents a state change. |
Yangster-mac | b6b77c6 | 2018-10-12 19:33:24 -0700 | [diff] [blame] | 106 | optional StateAtomFieldOption state_field_option = 50000; |
Yao Chen | c40a19d | 2018-03-15 16:48:25 -0700 | [diff] [blame] | 107 | |
| 108 | // Flags to decorate the uid fields in an atom. |
| 109 | optional bool is_uid = 50001 [default = false]; |
Yao Chen | bbdd67d | 2018-10-24 12:15:56 -0700 | [diff] [blame] | 110 | |
| 111 | optional LogMode log_mode = 50002 [default = MODE_AUTOMATIC]; |
Andrei Onea | da01ea5 | 2019-01-30 15:28:36 +0000 | [diff] [blame] | 112 | |
| 113 | optional bool allow_from_any_uid = 50003 [default = false]; |
Tej Singh | 810eeb3 | 2019-03-07 19:08:52 -0800 | [diff] [blame] | 114 | |
Muhammad Qureshi | f8460f7 | 2020-03-05 09:48:48 -0800 | [diff] [blame] | 115 | repeated string module = 50004; |
Muhammad Qureshi | 9b99580 | 2020-03-20 13:55:51 -0700 | [diff] [blame] | 116 | |
| 117 | optional bool truncate_timestamp = 50005 [default = false]; |
Muhammad Qureshi | bcf6606 | 2019-12-23 17:55:48 -0800 | [diff] [blame] | 118 | } |