Delete atoms.proto from statsd

Use the atoms.proto in proto_logging as the source of truth. Also
migrates statsd log api gen to use the new atoms.proto

Bug: 167962588
Test: m -j && m CtsStatsdAtomHostTestCases

Change-Id: I36ec354d273dceace5245d7634c68ac63dc5a8cd
This commit is contained in:
Jeffrey Huang
2020-11-23 23:47:38 -08:00
parent e8e9fe5846
commit 4e671568fe
12 changed files with 34 additions and 12772 deletions

View File

@@ -912,13 +912,17 @@ java_library_host {
name: "platformprotos",
srcs: [
":ipconnectivity-proto-src",
":libstats_internal_protos",
"cmds/am/proto/instrumentation_data.proto",
"cmds/statsd/src/**/*.proto",
"core/proto/**/*.proto",
"libs/incident/proto/**/*.proto",
],
proto: {
include_dirs: ["external/protobuf/src"],
include_dirs: [
"external/protobuf/src",
"frameworks/proto_logging/stats",
],
type: "full",
},
// Protos have lots of MissingOverride and similar.

View File

@@ -14,34 +14,6 @@
// limitations under the License.
//
// ==========================================================
// Build the library for use on the host
// ==========================================================
cc_library_host_shared {
name: "libstats_proto_host",
srcs: [
"src/atoms.proto",
"src/atom_field_options.proto",
],
shared_libs: [
"libplatformprotos",
],
proto: {
type: "full",
export_proto_headers: true,
include_dirs: [
"external/protobuf/src",
],
},
export_shared_lib_headers: [
"libplatformprotos",
]
}
cc_defaults {
name: "statsd_defaults",
@@ -277,9 +249,8 @@ cc_test {
// atom_field_options.proto needs field_options.proto, but that is
// not included in libprotobuf-cpp-lite, so compile it here.
":libprotobuf-internal-protos",
":libstats_internal_protos",
"src/atom_field_options.proto",
"src/atoms.proto",
"src/shell/shell_data.proto",
"src/stats_log.proto",
"tests/AlarmMonitor_test.cpp",
@@ -346,7 +317,10 @@ cc_test {
proto: {
type: "lite",
include_dirs: ["external/protobuf/src"],
include_dirs: [
"external/protobuf/src",
"frameworks/proto_logging/stats",
],
},
}
@@ -363,6 +337,7 @@ cc_benchmark {
// atom_field_options.proto needs field_options.proto, but that is
// not included in libprotobuf-cpp-lite, so compile it here.
":libprotobuf-internal-protos",
":libstats_internal_protos",
"benchmark/duration_metric_benchmark.cpp",
"benchmark/filter_value_benchmark.cpp",
@@ -372,14 +347,15 @@ cc_benchmark {
"benchmark/main.cpp",
"benchmark/metric_util.cpp",
"benchmark/stats_write_benchmark.cpp",
"src/atom_field_options.proto",
"src/atoms.proto",
"src/stats_log.proto",
],
proto: {
type: "lite",
include_dirs: ["external/protobuf/src"],
include_dirs: [
"external/protobuf/src",
"frameworks/proto_logging/stats",
],
},
cflags: [
@@ -411,11 +387,14 @@ java_library {
sdk_version: "core_current",
proto: {
type: "lite",
include_dirs: ["external/protobuf/src"],
include_dirs: [
"external/protobuf/src",
"frameworks/proto_logging/stats",
],
},
srcs: [
"src/atoms.proto",
":libstats_atoms_proto",
"src/shell/shell_config.proto",
"src/shell/shell_data.proto",
"src/stats_log.proto",
@@ -437,10 +416,13 @@ java_library {
proto: {
type: "nano",
output_params: ["store_unknown_fields=true"],
include_dirs: ["external/protobuf/src"],
include_dirs: [
"external/protobuf/src",
"frameworks/proto_logging/stats",
],
},
srcs: [
"src/atoms.proto",
":libstats_atoms_proto",
"src/shell/shell_config.proto",
"src/shell/shell_data.proto",
"src/stats_log.proto",

View File

@@ -1,116 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto2";
package android.os.statsd;
option java_package = "com.android.os";
option java_multiple_files = true;
option java_outer_classname = "AtomFieldOptions";
import "google/protobuf/descriptor.proto";
// Used to annotate an atom that represents a state change. A state change atom must have exactly
// ONE exclusive state field, and any number of primary key fields. For example, message
// UidProcessStateChanged {
// optional int32 uid = 1 [(state_field_option).primary_field = true];
// optional android.app.ProcessStateEnum state =
// 2 [(state_field_option).exclusive_state = true];
// }
// Each UidProcessStateChanged atom event represents a state change for a specific uid.
// A new state automatically overrides the previous state.
//
// If the atom has 2 or more primary fields, it means the combination of the
// primary fields are the primary key.
// For example:
// message ThreadStateChanged {
// optional int32 pid = 1 [(state_field_option).primary_field = true];
// optional int32 tid = 2 [(state_field_option).primary_field = true];
// optional int32 state = 3 [(state_field_option).exclusive_state = true];
// }
//
// Sometimes, there is no primary key field, when the state is GLOBAL.
// For example,
// message ScreenStateChanged {
// optional android.view.DisplayStateEnum state =
// 1 [(state_field_option).exclusive_state = true];
// }
//
// For state atoms with attribution chain, sometimes the primary key is the first uid in the chain.
// For example:
// message AudioStateChanged {
// repeated AttributionNode attribution_node = 1
// [(stateFieldOption).primary_field_first_uid = true];
//
// enum State {
// OFF = 0;
// ON = 1;
// // RESET indicates all audio stopped. Used when it (re)starts (e.g. after it crashes).
// RESET = 2;
// }
// optional State state = 2 [(stateFieldOption).exclusive_state = true];
// }
message StateAtomFieldOption {
// Fields that represent the key that the state belongs to.
// Used on simple proto fields. Do not use on attribution chains.
optional bool primary_field = 1 [default = false];
// The field that represents the state. It's an exclusive state.
optional bool exclusive_state = 2 [default = false];
// Used on an attribution chain field to indicate that the first uid is the
// primary field.
optional bool primary_field_first_uid = 3 [default = false];
// Note: We cannot annotate directly on the enums because many enums are imported from other
// proto files in the platform. proto-lite cc library does not support annotations unfortunately
// Knowing the default state value allows state trackers to remove entries that become the
// default state. If there is no default value specified, the default value is unknown, and all
// states will be tracked in memory.
optional int32 default_state_value = 4;
// A reset state signals all states go to default value. For example, BLE reset means all active
// BLE scans are to be turned off.
optional int32 trigger_state_reset_value = 5;
// If the state change needs to count nesting.
optional bool nested = 6 [default = true];
}
// Used to generate StatsLog.write APIs.
enum LogMode {
MODE_UNSET = 0;
// Log fields as their actual types e.g., all primary data types.
// Or fields that are hardcoded in stats_log_api_gen tool e.g., AttributionNode
MODE_AUTOMATIC = 1;
// Log fields in their proto binary format. These fields will not be parsed in statsd
MODE_BYTES = 2;
}
extend google.protobuf.FieldOptions {
// Flags to decorate an atom that presents a state change.
optional StateAtomFieldOption state_field_option = 50000;
// Flags to decorate the uid fields in an atom.
optional bool is_uid = 50001 [default = false];
optional LogMode log_mode = 50002 [default = MODE_AUTOMATIC];
repeated string module = 50004;
optional bool truncate_timestamp = 50005 [default = false];
}

File diff suppressed because it is too large Load Diff

View File

@@ -21,7 +21,7 @@ package android.os.statsd;
option java_package = "com.android.os.statsd";
option java_outer_classname = "ShellDataProto";
import "frameworks/base/cmds/statsd/src/atoms.proto";
import "frameworks/proto_logging/stats/atoms.proto";
// The output of shell subscription, including both pulled and pushed subscriptions.
message ShellData {

View File

@@ -21,7 +21,7 @@ package android.os.statsd;
option java_package = "com.android.os";
option java_outer_classname = "StatsLog";
import "frameworks/base/cmds/statsd/src/atoms.proto";
import "frameworks/proto_logging/stats/atoms.proto";
message DimensionsValue {
optional int32 field = 1;

View File

@@ -16,8 +16,8 @@
#include <gtest/gtest.h>
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
#include "frameworks/base/core/proto/android/stats/launcher/launcher.pb.h"
#include "frameworks/proto_logging/stats/atoms.pb.h"
#include "log/log_event_list.h"
#include "stats_event.h"

View File

@@ -20,9 +20,9 @@
#include <vector>
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
#include "frameworks/base/cmds/statsd/src/shell/shell_config.pb.h"
#include "frameworks/base/cmds/statsd/src/shell/shell_data.pb.h"
#include "frameworks/proto_logging/stats/atoms.pb.h"
#include "stats_event.h"
#include "tests/metrics/metrics_test_helper.h"
#include "tests/statsd_test_util.h"

View File

@@ -20,7 +20,7 @@
#include <map>
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
#include "frameworks/proto_logging/stats/atoms.pb.h"
namespace android {
namespace stats_log_api_gen {

View File

@@ -24,7 +24,7 @@
#include <set>
#include <vector>
#include "frameworks/base/cmds/statsd/src/atom_field_options.pb.h"
#include "frameworks/proto_logging/stats/atom_field_options.pb.h"
namespace android {
namespace stats_log_api_gen {

View File

@@ -9,7 +9,7 @@
#include <vector>
#include "Collation.h"
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
#include "frameworks/proto_logging/stats/atoms.pb.h"
#include "java_writer.h"
#include "java_writer_q.h"
#include "native_writer.h"

View File

@@ -16,8 +16,8 @@
syntax = "proto2";
import "frameworks/base/cmds/statsd/src/atoms.proto";
import "frameworks/base/cmds/statsd/src/atom_field_options.proto";
import "frameworks/proto_logging/stats/atoms.proto";
import "frameworks/proto_logging/stats/atom_field_options.proto";
package android.stats_log_api_gen;