aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-08 01:12:55 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-08 01:12:55 +0000
commit2c018fbadd30279d8e8975841d17a113506ba807 (patch)
tree76367d069cf2eabafe1b479af12e933162aa30c2
parent973e89122f1394b3e070f555b919f8d9d176f2ff (diff)
parentd85b69a13e9500910d715be5348dedb5f3fbe002 (diff)
downloadperfetto-android13-qpr1-s5-release.tar.gz
Change-Id: I7d080745b4281ebb9d92f50c712cb2740ea7e356
-rw-r--r--Android.bp51
-rw-r--r--BUILD12
-rw-r--r--protos/perfetto/config/android/BUILD.gn1
-rw-r--r--protos/perfetto/config/android/android_polled_state_config.proto3
-rw-r--r--protos/perfetto/config/android/android_system_property_config.proto30
-rw-r--r--protos/perfetto/config/data_source_config.proto6
-rw-r--r--protos/perfetto/config/perfetto_config.proto23
-rw-r--r--protos/perfetto/trace/android/BUILD.gn1
-rw-r--r--protos/perfetto/trace/android/android_system_property.proto27
-rw-r--r--protos/perfetto/trace/perfetto_trace.proto39
-rw-r--r--protos/perfetto/trace/trace_packet.proto4
-rw-r--r--src/traced/probes/BUILD.gn2
-rw-r--r--src/traced/probes/android_system_property/BUILD.gn48
-rw-r--r--src/traced/probes/android_system_property/android_system_property_data_source.cc136
-rw-r--r--src/traced/probes/android_system_property/android_system_property_data_source.h66
-rw-r--r--src/traced/probes/android_system_property/android_system_property_data_source_unittest.cc127
-rw-r--r--src/traced/probes/probes_producer.cc13
17 files changed, 581 insertions, 8 deletions
diff --git a/Android.bp b/Android.bp
index 5373c691f..5aa519fe0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -530,6 +530,7 @@ cc_library_shared {
":perfetto_src_protozero_filtering_message_filter",
":perfetto_src_protozero_protozero",
":perfetto_src_traced_probes_android_log_android_log",
+ ":perfetto_src_traced_probes_android_system_property_android_system_property",
":perfetto_src_traced_probes_common_common",
":perfetto_src_traced_probes_data_source",
":perfetto_src_traced_probes_filesystem_filesystem",
@@ -1099,6 +1100,7 @@ cc_library_static {
":perfetto_src_protozero_filtering_message_filter",
":perfetto_src_protozero_protozero",
":perfetto_src_traced_probes_android_log_android_log",
+ ":perfetto_src_traced_probes_android_system_property_android_system_property",
":perfetto_src_traced_probes_common_common",
":perfetto_src_traced_probes_data_source",
":perfetto_src_traced_probes_filesystem_filesystem",
@@ -1362,6 +1364,7 @@ cc_library_static {
":perfetto_src_protozero_filtering_message_filter",
":perfetto_src_protozero_protozero",
":perfetto_src_traced_probes_android_log_android_log",
+ ":perfetto_src_traced_probes_android_system_property_android_system_property",
":perfetto_src_traced_probes_common_common",
":perfetto_src_traced_probes_data_source",
":perfetto_src_traced_probes_filesystem_filesystem",
@@ -1806,6 +1809,7 @@ cc_test {
":perfetto_src_trace_processor_util_protozero_to_text",
":perfetto_src_trace_processor_util_util",
":perfetto_src_traced_probes_android_log_android_log",
+ ":perfetto_src_traced_probes_android_system_property_android_system_property",
":perfetto_src_traced_probes_common_common",
":perfetto_src_traced_probes_data_source",
":perfetto_src_traced_probes_filesystem_filesystem",
@@ -2239,6 +2243,7 @@ genrule {
srcs: [
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
],
tools: [
@@ -2249,6 +2254,7 @@ genrule {
out: [
"external/perfetto/protos/perfetto/config/android/android_log_config.gen.cc",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.gen.cc",
+ "external/perfetto/protos/perfetto/config/android/android_system_property_config.gen.cc",
"external/perfetto/protos/perfetto/config/android/packages_list_config.gen.cc",
],
}
@@ -2259,6 +2265,7 @@ genrule {
srcs: [
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
],
tools: [
@@ -2269,6 +2276,7 @@ genrule {
out: [
"external/perfetto/protos/perfetto/config/android/android_log_config.gen.h",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.gen.h",
+ "external/perfetto/protos/perfetto/config/android/android_system_property_config.gen.h",
"external/perfetto/protos/perfetto/config/android/packages_list_config.gen.h",
],
export_include_dirs: [
@@ -2283,6 +2291,7 @@ genrule {
srcs: [
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
],
tools: [
@@ -2292,6 +2301,7 @@ genrule {
out: [
"external/perfetto/protos/perfetto/config/android/android_log_config.pb.cc",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pb.cc",
+ "external/perfetto/protos/perfetto/config/android/android_system_property_config.pb.cc",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pb.cc",
],
}
@@ -2302,6 +2312,7 @@ genrule {
srcs: [
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
],
tools: [
@@ -2311,6 +2322,7 @@ genrule {
out: [
"external/perfetto/protos/perfetto/config/android/android_log_config.pb.h",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pb.h",
+ "external/perfetto/protos/perfetto/config/android/android_system_property_config.pb.h",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pb.h",
],
export_include_dirs: [
@@ -2325,6 +2337,7 @@ genrule {
srcs: [
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
],
tools: [
@@ -2335,6 +2348,7 @@ genrule {
out: [
"external/perfetto/protos/perfetto/config/android/android_log_config.pbzero.cc",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pbzero.cc",
+ "external/perfetto/protos/perfetto/config/android/android_system_property_config.pbzero.cc",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pbzero.cc",
],
}
@@ -2345,6 +2359,7 @@ genrule {
srcs: [
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
],
tools: [
@@ -2355,6 +2370,7 @@ genrule {
out: [
"external/perfetto/protos/perfetto/config/android/android_log_config.pbzero.h",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pbzero.h",
+ "external/perfetto/protos/perfetto/config/android/android_system_property_config.pbzero.h",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pbzero.h",
],
export_include_dirs: [
@@ -2441,6 +2457,7 @@ genrule {
"protos/perfetto/common/track_event_descriptor.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
"protos/perfetto/config/chrome/chrome_config.proto",
"protos/perfetto/config/data_source_config.proto",
@@ -3812,6 +3829,7 @@ genrule {
name: "perfetto_protos_perfetto_trace_android_cpp_gen",
srcs: [
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -3826,6 +3844,7 @@ genrule {
cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(in)",
out: [
"external/perfetto/protos/perfetto/trace/android/android_log.gen.cc",
+ "external/perfetto/protos/perfetto/trace/android/android_system_property.gen.cc",
"external/perfetto/protos/perfetto/trace/android/camera_event.gen.cc",
"external/perfetto/protos/perfetto/trace/android/frame_timeline_event.gen.cc",
"external/perfetto/protos/perfetto/trace/android/gpu_mem_event.gen.cc",
@@ -3840,6 +3859,7 @@ genrule {
name: "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
srcs: [
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -3854,6 +3874,7 @@ genrule {
cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(in)",
out: [
"external/perfetto/protos/perfetto/trace/android/android_log.gen.h",
+ "external/perfetto/protos/perfetto/trace/android/android_system_property.gen.h",
"external/perfetto/protos/perfetto/trace/android/camera_event.gen.h",
"external/perfetto/protos/perfetto/trace/android/frame_timeline_event.gen.h",
"external/perfetto/protos/perfetto/trace/android/gpu_mem_event.gen.h",
@@ -3872,6 +3893,7 @@ genrule {
name: "perfetto_protos_perfetto_trace_android_lite_gen",
srcs: [
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -3885,6 +3907,7 @@ genrule {
cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(in)",
out: [
"external/perfetto/protos/perfetto/trace/android/android_log.pb.cc",
+ "external/perfetto/protos/perfetto/trace/android/android_system_property.pb.cc",
"external/perfetto/protos/perfetto/trace/android/camera_event.pb.cc",
"external/perfetto/protos/perfetto/trace/android/frame_timeline_event.pb.cc",
"external/perfetto/protos/perfetto/trace/android/gpu_mem_event.pb.cc",
@@ -3899,6 +3922,7 @@ genrule {
name: "perfetto_protos_perfetto_trace_android_lite_gen_headers",
srcs: [
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -3912,6 +3936,7 @@ genrule {
cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(in)",
out: [
"external/perfetto/protos/perfetto/trace/android/android_log.pb.h",
+ "external/perfetto/protos/perfetto/trace/android/android_system_property.pb.h",
"external/perfetto/protos/perfetto/trace/android/camera_event.pb.h",
"external/perfetto/protos/perfetto/trace/android/frame_timeline_event.pb.h",
"external/perfetto/protos/perfetto/trace/android/gpu_mem_event.pb.h",
@@ -3930,6 +3955,7 @@ genrule {
name: "perfetto_protos_perfetto_trace_android_zero_gen",
srcs: [
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -3944,6 +3970,7 @@ genrule {
cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(in)",
out: [
"external/perfetto/protos/perfetto/trace/android/android_log.pbzero.cc",
+ "external/perfetto/protos/perfetto/trace/android/android_system_property.pbzero.cc",
"external/perfetto/protos/perfetto/trace/android/camera_event.pbzero.cc",
"external/perfetto/protos/perfetto/trace/android/frame_timeline_event.pbzero.cc",
"external/perfetto/protos/perfetto/trace/android/gpu_mem_event.pbzero.cc",
@@ -3958,6 +3985,7 @@ genrule {
name: "perfetto_protos_perfetto_trace_android_zero_gen_headers",
srcs: [
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -3972,6 +4000,7 @@ genrule {
cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(in)",
out: [
"external/perfetto/protos/perfetto/trace/android/android_log.pbzero.h",
+ "external/perfetto/protos/perfetto/trace/android/android_system_property.pbzero.h",
"external/perfetto/protos/perfetto/trace/android/camera_event.pbzero.h",
"external/perfetto/protos/perfetto/trace/android/frame_timeline_event.pbzero.h",
"external/perfetto/protos/perfetto/trace/android/gpu_mem_event.pbzero.h",
@@ -4137,6 +4166,7 @@ genrule {
"protos/perfetto/common/track_event_descriptor.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
"protos/perfetto/config/chrome/chrome_config.proto",
"protos/perfetto/config/data_source_config.proto",
@@ -4157,6 +4187,7 @@ genrule {
"protos/perfetto/config/trace_config.proto",
"protos/perfetto/config/track_event/track_event_config.proto",
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -8788,6 +8819,22 @@ filegroup {
],
}
+// GN: //src/traced/probes/android_system_property:android_system_property
+filegroup {
+ name: "perfetto_src_traced_probes_android_system_property_android_system_property",
+ srcs: [
+ "src/traced/probes/android_system_property/android_system_property_data_source.cc",
+ ],
+}
+
+// GN: //src/traced/probes/android_system_property:unittests
+filegroup {
+ name: "perfetto_src_traced_probes_android_system_property_unittests",
+ srcs: [
+ "src/traced/probes/android_system_property/android_system_property_data_source_unittest.cc",
+ ],
+}
+
// GN: //src/traced/probes/common:common
filegroup {
name: "perfetto_src_traced_probes_common_common",
@@ -9507,6 +9554,7 @@ java_library {
"protos/perfetto/common/track_event_descriptor.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
"protos/perfetto/config/chrome/chrome_config.proto",
"protos/perfetto/config/data_source_config.proto",
@@ -9527,6 +9575,7 @@ java_library {
"protos/perfetto/config/trace_config.proto",
"protos/perfetto/config/track_event/track_event_config.proto",
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
@@ -9974,6 +10023,8 @@ cc_test {
":perfetto_src_trace_processor_util_util",
":perfetto_src_traced_probes_android_log_android_log",
":perfetto_src_traced_probes_android_log_unittests",
+ ":perfetto_src_traced_probes_android_system_property_android_system_property",
+ ":perfetto_src_traced_probes_android_system_property_unittests",
":perfetto_src_traced_probes_common_common",
":perfetto_src_traced_probes_common_test_support",
":perfetto_src_traced_probes_common_unittests",
diff --git a/BUILD b/BUILD
index 8fa787487..784ea1ba5 100644
--- a/BUILD
+++ b/BUILD
@@ -223,6 +223,7 @@ perfetto_cc_library(
":src_protozero_filtering_bytecode_parser",
":src_protozero_filtering_message_filter",
":src_traced_probes_android_log_android_log",
+ ":src_traced_probes_android_system_property_android_system_property",
":src_traced_probes_common_common",
":src_traced_probes_data_source",
":src_traced_probes_filesystem_filesystem",
@@ -1594,6 +1595,15 @@ perfetto_filegroup(
],
)
+# GN target: //src/traced/probes/android_system_property:android_system_property
+perfetto_filegroup(
+ name = "src_traced_probes_android_system_property_android_system_property",
+ srcs = [
+ "src/traced/probes/android_system_property/android_system_property_data_source.cc",
+ "src/traced/probes/android_system_property/android_system_property_data_source.h",
+ ],
+)
+
# GN target: //src/traced/probes/common:common
perfetto_filegroup(
name = "src_traced_probes_common_common",
@@ -2332,6 +2342,7 @@ perfetto_proto_library(
srcs = [
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
],
visibility = [
@@ -2907,6 +2918,7 @@ perfetto_proto_library(
name = "protos_perfetto_trace_android_protos",
srcs = [
"protos/perfetto/trace/android/android_log.proto",
+ "protos/perfetto/trace/android/android_system_property.proto",
"protos/perfetto/trace/android/camera_event.proto",
"protos/perfetto/trace/android/frame_timeline_event.proto",
"protos/perfetto/trace/android/gpu_mem_event.proto",
diff --git a/protos/perfetto/config/android/BUILD.gn b/protos/perfetto/config/android/BUILD.gn
index e7180d55d..f448eb578 100644
--- a/protos/perfetto/config/android/BUILD.gn
+++ b/protos/perfetto/config/android/BUILD.gn
@@ -20,6 +20,7 @@ perfetto_proto_library("@TYPE@") {
sources = [
"android_log_config.proto",
"android_polled_state_config.proto",
+ "android_system_property_config.proto",
"packages_list_config.proto",
]
}
diff --git a/protos/perfetto/config/android/android_polled_state_config.proto b/protos/perfetto/config/android/android_polled_state_config.proto
index bd32c2c03..21e25c2be 100644
--- a/protos/perfetto/config/android/android_polled_state_config.proto
+++ b/protos/perfetto/config/android/android_polled_state_config.proto
@@ -18,7 +18,8 @@ syntax = "proto2";
package perfetto.protos;
-// Data source that polls for display state.
+// Data source that polls for display state. This should only be used for
+// backward-compatibility; AndroidSystemPropertyConfig should be preferred.
message AndroidPolledStateConfig {
// Frequency of polling. If absent the state will be recorded once, at the
// start of the trace.
diff --git a/protos/perfetto/config/android/android_system_property_config.proto b/protos/perfetto/config/android/android_system_property_config.proto
new file mode 100644
index 000000000..fbf106226
--- /dev/null
+++ b/protos/perfetto/config/android/android_system_property_config.proto
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2022 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 perfetto.protos;
+
+// Data source that polls for system properties.
+message AndroidSystemPropertyConfig {
+ // Frequency of polling. If absent the state will be recorded once, at the
+ // start of the trace.
+ // This is required to be > 100ms to avoid excessive CPU usage.
+ optional uint32 poll_ms = 1;
+
+ // Properties to poll. All property names must start with "debug.tracing.".
+ repeated string property_name = 2;
+}
diff --git a/protos/perfetto/config/data_source_config.proto b/protos/perfetto/config/data_source_config.proto
index 22b18e326..f8265a679 100644
--- a/protos/perfetto/config/data_source_config.proto
+++ b/protos/perfetto/config/data_source_config.proto
@@ -20,6 +20,7 @@ package perfetto.protos;
import "protos/perfetto/config/android/android_log_config.proto";
import "protos/perfetto/config/android/android_polled_state_config.proto";
+import "protos/perfetto/config/android/android_system_property_config.proto";
import "protos/perfetto/config/android/packages_list_config.proto";
import "protos/perfetto/config/chrome/chrome_config.proto";
import "protos/perfetto/config/ftrace/ftrace_config.proto";
@@ -37,7 +38,7 @@ import "protos/perfetto/config/test_config.proto";
import "protos/perfetto/config/track_event/track_event_config.proto";
// The configuration that is passed to each data source when starting tracing.
-// Next id: 116
+// Next id: 119
message DataSourceConfig {
enum SessionInitiator {
SESSION_INITIATOR_UNSPECIFIED = 0;
@@ -124,6 +125,9 @@ message DataSourceConfig {
// Data source name: android.polled_state
optional AndroidPolledStateConfig android_polled_state_config = 114
[lazy = true];
+ // Data source name: android.system_property
+ optional AndroidSystemPropertyConfig android_system_property_config = 118
+ [lazy = true];
// Chrome is special as it doesn't use the perfetto IPC layer. We want to
// avoid proto serialization and de-serialization there because that would
diff --git a/protos/perfetto/config/perfetto_config.proto b/protos/perfetto/config/perfetto_config.proto
index 5c354e8e9..00fee9061 100644
--- a/protos/perfetto/config/perfetto_config.proto
+++ b/protos/perfetto/config/perfetto_config.proto
@@ -381,7 +381,8 @@ message AndroidLogConfig {
// Begin of protos/perfetto/config/android/android_polled_state_config.proto
-// Data source that polls for display state.
+// Data source that polls for display state. This should only be used for
+// backward-compatibility; AndroidSystemPropertyConfig should be preferred.
message AndroidPolledStateConfig {
// Frequency of polling. If absent the state will be recorded once, at the
// start of the trace.
@@ -391,6 +392,21 @@ message AndroidPolledStateConfig {
// End of protos/perfetto/config/android/android_polled_state_config.proto
+// Begin of protos/perfetto/config/android/android_system_property_config.proto
+
+// Data source that polls for system properties.
+message AndroidSystemPropertyConfig {
+ // Frequency of polling. If absent the state will be recorded once, at the
+ // start of the trace.
+ // This is required to be > 100ms to avoid excessive CPU usage.
+ optional uint32 poll_ms = 1;
+
+ // Properties to poll. All property names must start with "debug.tracing.".
+ repeated string property_name = 2;
+}
+
+// End of protos/perfetto/config/android/android_system_property_config.proto
+
// Begin of protos/perfetto/config/android/packages_list_config.proto
// Data source that lists details (such as version code) about packages on an
@@ -1588,7 +1604,7 @@ message TrackEventConfig {
// Begin of protos/perfetto/config/data_source_config.proto
// The configuration that is passed to each data source when starting tracing.
-// Next id: 116
+// Next id: 119
message DataSourceConfig {
enum SessionInitiator {
SESSION_INITIATOR_UNSPECIFIED = 0;
@@ -1675,6 +1691,9 @@ message DataSourceConfig {
// Data source name: android.polled_state
optional AndroidPolledStateConfig android_polled_state_config = 114
[lazy = true];
+ // Data source name: android.system_property
+ optional AndroidSystemPropertyConfig android_system_property_config = 118
+ [lazy = true];
// Chrome is special as it doesn't use the perfetto IPC layer. We want to
// avoid proto serialization and de-serialization there because that would
diff --git a/protos/perfetto/trace/android/BUILD.gn b/protos/perfetto/trace/android/BUILD.gn
index 364342755..010ae3285 100644
--- a/protos/perfetto/trace/android/BUILD.gn
+++ b/protos/perfetto/trace/android/BUILD.gn
@@ -19,6 +19,7 @@ perfetto_proto_library("@TYPE@") {
sources = [
"android_log.proto",
+ "android_system_property.proto",
"camera_event.proto",
"frame_timeline_event.proto",
"gpu_mem_event.proto",
diff --git a/protos/perfetto/trace/android/android_system_property.proto b/protos/perfetto/trace/android/android_system_property.proto
new file mode 100644
index 000000000..5f5ada196
--- /dev/null
+++ b/protos/perfetto/trace/android/android_system_property.proto
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2022 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 perfetto.protos;
+
+message AndroidSystemProperty {
+ message PropertyValue {
+ optional string name = 1;
+ optional string value = 2;
+ }
+
+ repeated PropertyValue values = 1;
+}
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 63b058f13..2e560602a 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -381,7 +381,8 @@ message AndroidLogConfig {
// Begin of protos/perfetto/config/android/android_polled_state_config.proto
-// Data source that polls for display state.
+// Data source that polls for display state. This should only be used for
+// backward-compatibility; AndroidSystemPropertyConfig should be preferred.
message AndroidPolledStateConfig {
// Frequency of polling. If absent the state will be recorded once, at the
// start of the trace.
@@ -391,6 +392,21 @@ message AndroidPolledStateConfig {
// End of protos/perfetto/config/android/android_polled_state_config.proto
+// Begin of protos/perfetto/config/android/android_system_property_config.proto
+
+// Data source that polls for system properties.
+message AndroidSystemPropertyConfig {
+ // Frequency of polling. If absent the state will be recorded once, at the
+ // start of the trace.
+ // This is required to be > 100ms to avoid excessive CPU usage.
+ optional uint32 poll_ms = 1;
+
+ // Properties to poll. All property names must start with "debug.tracing.".
+ repeated string property_name = 2;
+}
+
+// End of protos/perfetto/config/android/android_system_property_config.proto
+
// Begin of protos/perfetto/config/android/packages_list_config.proto
// Data source that lists details (such as version code) about packages on an
@@ -1588,7 +1604,7 @@ message TrackEventConfig {
// Begin of protos/perfetto/config/data_source_config.proto
// The configuration that is passed to each data source when starting tracing.
-// Next id: 116
+// Next id: 119
message DataSourceConfig {
enum SessionInitiator {
SESSION_INITIATOR_UNSPECIFIED = 0;
@@ -1675,6 +1691,9 @@ message DataSourceConfig {
// Data source name: android.polled_state
optional AndroidPolledStateConfig android_polled_state_config = 114
[lazy = true];
+ // Data source name: android.system_property
+ optional AndroidSystemPropertyConfig android_system_property_config = 118
+ [lazy = true];
// Chrome is special as it doesn't use the perfetto IPC layer. We want to
// avoid proto serialization and de-serialization there because that would
@@ -2427,6 +2446,19 @@ message AndroidLogPacket {
// End of protos/perfetto/trace/android/android_log.proto
+// Begin of protos/perfetto/trace/android/android_system_property.proto
+
+message AndroidSystemProperty {
+ message PropertyValue {
+ optional string name = 1;
+ optional string value = 2;
+ }
+
+ repeated PropertyValue values = 1;
+}
+
+// End of protos/perfetto/trace/android/android_system_property.proto
+
// Begin of protos/perfetto/trace/android/camera_event.proto
// A profiling event corresponding to a single camera frame. This message
@@ -10073,7 +10105,7 @@ message UiState {
// See the [Buffers and Dataflow](/docs/concepts/buffers.md) doc for details.
//
// Next reserved id: 14 (up to 15).
-// Next id: 83.
+// Next id: 86.
message TracePacket {
// The timestamp of the TracePacket.
// By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -10138,6 +10170,7 @@ message TracePacket {
AndroidCameraFrameEvent android_camera_frame_event = 80;
AndroidCameraSessionStats android_camera_session_stats = 81;
TranslationTable translation_table = 82;
+ AndroidSystemProperty android_system_property = 86;
// Only used in profile packets.
ProfiledFrameSymbols profiled_frame_symbols = 55;
diff --git a/protos/perfetto/trace/trace_packet.proto b/protos/perfetto/trace/trace_packet.proto
index b08ec4e7e..c46e6fd35 100644
--- a/protos/perfetto/trace/trace_packet.proto
+++ b/protos/perfetto/trace/trace_packet.proto
@@ -20,6 +20,7 @@ import "protos/perfetto/common/trace_stats.proto";
import "protos/perfetto/config/trace_config.proto";
import "protos/perfetto/trace/extension_descriptor.proto";
import "protos/perfetto/trace/android/android_log.proto";
+import "protos/perfetto/trace/android/android_system_property.proto";
import "protos/perfetto/trace/android/camera_event.proto";
import "protos/perfetto/trace/android/frame_timeline_event.proto";
import "protos/perfetto/trace/android/gpu_mem_event.proto";
@@ -87,7 +88,7 @@ package perfetto.protos;
// See the [Buffers and Dataflow](/docs/concepts/buffers.md) doc for details.
//
// Next reserved id: 14 (up to 15).
-// Next id: 83.
+// Next id: 86.
message TracePacket {
// The timestamp of the TracePacket.
// By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -152,6 +153,7 @@ message TracePacket {
AndroidCameraFrameEvent android_camera_frame_event = 80;
AndroidCameraSessionStats android_camera_session_stats = 81;
TranslationTable translation_table = 82;
+ AndroidSystemProperty android_system_property = 86;
// Only used in profile packets.
ProfiledFrameSymbols profiled_frame_symbols = 55;
diff --git a/src/traced/probes/BUILD.gn b/src/traced/probes/BUILD.gn
index 4c4b65a15..8a56dca17 100644
--- a/src/traced/probes/BUILD.gn
+++ b/src/traced/probes/BUILD.gn
@@ -58,6 +58,7 @@ source_set("probes_src") {
"../../tracing/core",
"../../tracing/ipc/producer",
"android_log",
+ "android_system_property",
"common",
"filesystem",
"initial_display_state",
@@ -97,6 +98,7 @@ perfetto_unittest_source_set("unittests") {
"../../../gn:gtest_and_gmock",
"../../tracing/test:test_support",
"android_log:unittests",
+ "android_system_property:unittests",
"common:unittests",
"filesystem:unittests",
"initial_display_state:unittests",
diff --git a/src/traced/probes/android_system_property/BUILD.gn b/src/traced/probes/android_system_property/BUILD.gn
new file mode 100644
index 000000000..201961f74
--- /dev/null
+++ b/src/traced/probes/android_system_property/BUILD.gn
@@ -0,0 +1,48 @@
+# Copyright (C) 2022 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.
+
+import("../../../../gn/test.gni")
+
+source_set("android_system_property") {
+ public_deps = [ "../../../tracing/core" ]
+ deps = [
+ "..:data_source",
+ "../../../../gn:default_deps",
+ "../../../../include/perfetto/ext/traced",
+ "../../../../protos/perfetto/config/android:zero",
+ "../../../../protos/perfetto/trace:zero",
+ "../../../../protos/perfetto/trace/android:zero",
+ "../../../base",
+ "../common",
+ ]
+ sources = [
+ "android_system_property_data_source.cc",
+ "android_system_property_data_source.h",
+ ]
+}
+
+perfetto_unittest_source_set("unittests") {
+ testonly = true
+ deps = [
+ ":android_system_property",
+ "../../../../gn:default_deps",
+ "../../../../gn:gtest_and_gmock",
+ "../../../../protos/perfetto/config/android:cpp",
+ "../../../../protos/perfetto/trace/android:cpp",
+ "../../../../src/base:test_support",
+ "../../../../src/tracing/test:test_support",
+ "../common:test_support",
+ ]
+ sources = [ "android_system_property_data_source_unittest.cc" ]
+}
diff --git a/src/traced/probes/android_system_property/android_system_property_data_source.cc b/src/traced/probes/android_system_property/android_system_property_data_source.cc
new file mode 100644
index 000000000..650aa46c0
--- /dev/null
+++ b/src/traced/probes/android_system_property/android_system_property_data_source.cc
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include "src/traced/probes/android_system_property/android_system_property_data_source.h"
+
+#include "perfetto/base/task_runner.h"
+#include "perfetto/base/time.h"
+#include "perfetto/ext/base/android_utils.h"
+#include "perfetto/ext/base/optional.h"
+#include "perfetto/ext/base/string_utils.h"
+#include "perfetto/tracing/core/data_source_config.h"
+
+#include "protos/perfetto/config/android/android_system_property_config.pbzero.h"
+#include "protos/perfetto/trace/android/android_system_property.pbzero.h"
+#include "protos/perfetto/trace/trace_packet.pbzero.h"
+
+namespace perfetto {
+
+// static
+const AndroidSystemPropertyDataSource::Descriptor
+ AndroidSystemPropertyDataSource::descriptor = {
+ /* name */ "android.system_property",
+ /* flags */ Descriptor::kFlagsNone,
+ /*fill_descriptor_func*/ nullptr,
+};
+
+constexpr const char* REQUIRED_NAME_PREFIX = "debug.tracing.";
+
+AndroidSystemPropertyDataSource::AndroidSystemPropertyDataSource(
+ base::TaskRunner* task_runner,
+ const DataSourceConfig& ds_config,
+ TracingSessionID session_id,
+ std::unique_ptr<TraceWriter> writer)
+ : ProbesDataSource(session_id, &descriptor),
+ task_runner_(task_runner),
+ writer_(std::move(writer)),
+ weak_factory_(this) {
+ protos::pbzero::AndroidSystemPropertyConfig::Decoder cfg(
+ ds_config.android_system_property_config_raw());
+ poll_period_ms_ = cfg.poll_ms();
+ if (poll_period_ms_ > 0 && poll_period_ms_ < 100) {
+ PERFETTO_ILOG("poll_ms %" PRIu32
+ " is less than minimum of 100ms. Increasing to 100ms.",
+ poll_period_ms_);
+ poll_period_ms_ = 100;
+ }
+ for (auto name_chars = cfg.property_name(); name_chars; ++name_chars) {
+ auto name = (*name_chars).ToStdString();
+ if (base::StartsWith(name, REQUIRED_NAME_PREFIX)) {
+ property_names_.push_back(name);
+ } else {
+ PERFETTO_ELOG("Property %s lacks required prefix %s", name.c_str(),
+ REQUIRED_NAME_PREFIX);
+ }
+ }
+}
+
+void AndroidSystemPropertyDataSource::Start() {
+ Tick();
+}
+
+base::WeakPtr<AndroidSystemPropertyDataSource>
+AndroidSystemPropertyDataSource::GetWeakPtr() const {
+ return weak_factory_.GetWeakPtr();
+}
+
+void AndroidSystemPropertyDataSource::Tick() {
+ if (poll_period_ms_) {
+ auto weak_this = GetWeakPtr();
+
+ uint32_t delay_ms =
+ poll_period_ms_ -
+ static_cast<uint32_t>(base::GetWallTimeMs().count() % poll_period_ms_);
+ task_runner_->PostDelayedTask(
+ [weak_this]() -> void {
+ if (weak_this) {
+ weak_this->Tick();
+ }
+ },
+ delay_ms);
+ }
+ WriteState();
+}
+
+void AndroidSystemPropertyDataSource::WriteState() {
+ auto packet = writer_->NewTracePacket();
+ packet->set_timestamp(static_cast<uint64_t>(base::GetBootTimeNs().count()));
+ auto* properties = packet->set_android_system_property();
+ for (const auto& name : property_names_) {
+ const base::Optional<std::string> value = ReadProperty(name);
+ if (value) {
+ auto* property = properties->add_values();
+ property->set_name(name);
+ property->set_value(*value);
+ }
+ }
+ packet->Finalize();
+}
+
+#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
+const base::Optional<std::string> AndroidSystemPropertyDataSource::ReadProperty(
+ const std::string& name) {
+ std::string value = base::GetAndroidProp(name.c_str());
+ if (value.empty()) {
+ PERFETTO_LOG("Unable to read %s", name.c_str());
+ return base::nullopt;
+ }
+ return base::make_optional(value);
+}
+#else
+const base::Optional<std::string> AndroidSystemPropertyDataSource::ReadProperty(
+ const std::string&) {
+ PERFETTO_ELOG("Android System Properties only supported on Android.");
+ return base::nullopt;
+}
+#endif
+
+void AndroidSystemPropertyDataSource::Flush(FlushRequestID,
+ std::function<void()> callback) {
+ writer_->Flush(callback);
+}
+
+} // namespace perfetto
diff --git a/src/traced/probes/android_system_property/android_system_property_data_source.h b/src/traced/probes/android_system_property/android_system_property_data_source.h
new file mode 100644
index 000000000..ec7db0eae
--- /dev/null
+++ b/src/traced/probes/android_system_property/android_system_property_data_source.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#ifndef SRC_TRACED_PROBES_ANDROID_SYSTEM_PROPERTY_ANDROID_SYSTEM_PROPERTY_DATA_SOURCE_H_
+#define SRC_TRACED_PROBES_ANDROID_SYSTEM_PROPERTY_ANDROID_SYSTEM_PROPERTY_DATA_SOURCE_H_
+
+#include <memory>
+#include <vector>
+
+#include "perfetto/ext/base/optional.h"
+#include "perfetto/ext/base/weak_ptr.h"
+#include "perfetto/ext/tracing/core/trace_writer.h"
+#include "src/traced/probes/probes_data_source.h"
+
+namespace perfetto {
+
+namespace base {
+class TaskRunner;
+}
+
+class AndroidSystemPropertyDataSource : public ProbesDataSource {
+ public:
+ static const ProbesDataSource::Descriptor descriptor;
+
+ AndroidSystemPropertyDataSource(base::TaskRunner* task_runner,
+ const DataSourceConfig& ds_config,
+ TracingSessionID session_id,
+ std::unique_ptr<TraceWriter> writer);
+
+ // ProbesDataSource implementation.
+ void Start() override;
+ void Flush(FlushRequestID, std::function<void()> callback) override;
+
+ // Virtual for testing.
+ virtual const base::Optional<std::string> ReadProperty(
+ const std::string& name);
+
+ private:
+ void Tick();
+ base::WeakPtr<AndroidSystemPropertyDataSource> GetWeakPtr() const;
+ void WriteState();
+
+ base::TaskRunner* const task_runner_;
+ std::unique_ptr<TraceWriter> writer_;
+ uint32_t poll_period_ms_ = 0;
+ std::vector<std::string> property_names_;
+ base::WeakPtrFactory<AndroidSystemPropertyDataSource>
+ weak_factory_; // Keep last.
+};
+
+} // namespace perfetto
+
+#endif // SRC_TRACED_PROBES_ANDROID_SYSTEM_PROPERTY_ANDROID_SYSTEM_PROPERTY_DATA_SOURCE_H_
diff --git a/src/traced/probes/android_system_property/android_system_property_data_source_unittest.cc b/src/traced/probes/android_system_property/android_system_property_data_source_unittest.cc
new file mode 100644
index 000000000..89d89e608
--- /dev/null
+++ b/src/traced/probes/android_system_property/android_system_property_data_source_unittest.cc
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include "src/traced/probes/android_system_property/android_system_property_data_source.h"
+#include "perfetto/tracing/core/data_source_config.h"
+#include "src/base/test/test_task_runner.h"
+#include "src/tracing/core/trace_writer_for_testing.h"
+#include "test/gtest_and_gmock.h"
+
+#include "protos/perfetto/config/android/android_system_property_config.gen.h"
+#include "protos/perfetto/trace/android/android_system_property.gen.h"
+#include "protos/perfetto/trace/trace_packet.gen.h"
+
+using ::perfetto::protos::gen::AndroidSystemPropertyConfig;
+
+using ::testing::AnyOf;
+using ::testing::ElementsAre;
+using ::testing::Return;
+
+namespace perfetto {
+namespace {
+
+class TestAndroidSystemPropertyDataSource
+ : public AndroidSystemPropertyDataSource {
+ public:
+ TestAndroidSystemPropertyDataSource(base::TaskRunner* task_runner,
+ const DataSourceConfig& config,
+ std::unique_ptr<TraceWriter> writer)
+ : AndroidSystemPropertyDataSource(task_runner,
+ config,
+ /* session_id */ 0,
+ std::move(writer)) {}
+
+ MOCK_METHOD1(ReadProperty,
+ const base::Optional<std::string>(const std::string&));
+};
+
+class AndroidSystemPropertyDataSourceTest : public ::testing::Test {
+ protected:
+ std::unique_ptr<TestAndroidSystemPropertyDataSource>
+ CreateAndroidSystemPropertyDataSource(const DataSourceConfig& config) {
+ auto writer =
+ std::unique_ptr<TraceWriterForTesting>(new TraceWriterForTesting());
+ writer_raw_ = writer.get();
+ auto instance = std::unique_ptr<TestAndroidSystemPropertyDataSource>(
+ new TestAndroidSystemPropertyDataSource(&task_runner_, config,
+ std::move(writer)));
+ return instance;
+ }
+
+ base::TestTaskRunner task_runner_;
+ TraceWriterForTesting* writer_raw_ = nullptr;
+};
+
+DataSourceConfig BuildConfig(const std::vector<std::string>& property_names) {
+ DataSourceConfig ds_config;
+ AndroidSystemPropertyConfig cfg;
+ for (auto name : property_names) {
+ cfg.add_property_name(name);
+ }
+ ds_config.set_android_system_property_config_raw(cfg.SerializeAsString());
+ return ds_config;
+}
+
+TEST_F(AndroidSystemPropertyDataSourceTest, Success) {
+ auto data_source = CreateAndroidSystemPropertyDataSource(BuildConfig(
+ {"debug.tracing.screen_state", "debug.tracing.screen_brightness"}));
+ EXPECT_CALL(*data_source, ReadProperty("debug.tracing.screen_state"))
+ .WillOnce(Return(base::make_optional("2")));
+ EXPECT_CALL(*data_source, ReadProperty("debug.tracing.screen_brightness"))
+ .WillOnce(Return(base::make_optional("0.123456")));
+ data_source->Start();
+
+ protos::gen::TracePacket packet = writer_raw_->GetOnlyTracePacket();
+ EXPECT_TRUE(packet.has_android_system_property());
+ auto properties = packet.android_system_property();
+ EXPECT_EQ(properties.values_size(), 2);
+
+ EXPECT_EQ(properties.values()[0].name(), "debug.tracing.screen_state");
+ EXPECT_EQ(properties.values()[0].value(), "2");
+ EXPECT_EQ(properties.values()[1].name(), "debug.tracing.screen_brightness");
+ EXPECT_EQ(properties.values()[1].value(), "0.123456");
+}
+
+TEST_F(AndroidSystemPropertyDataSourceTest, NotPermitted) {
+ auto data_source = CreateAndroidSystemPropertyDataSource(
+ BuildConfig({"something.with.wrong.prefix"}));
+ EXPECT_CALL(*data_source, ReadProperty("something.with.wrong.prefix"))
+ .Times(0);
+ data_source->Start();
+
+ protos::gen::TracePacket packet = writer_raw_->GetOnlyTracePacket();
+ EXPECT_TRUE(packet.has_android_system_property());
+ auto properties = packet.android_system_property();
+ EXPECT_EQ(properties.values_size(), 0);
+}
+
+TEST_F(AndroidSystemPropertyDataSourceTest, Failure) {
+ auto data_source = CreateAndroidSystemPropertyDataSource(BuildConfig(
+ {"debug.tracing.screen_state", "debug.tracing.screen_brightness"}));
+ EXPECT_CALL(*data_source, ReadProperty("debug.tracing.screen_state"))
+ .WillOnce(Return(base::nullopt));
+ EXPECT_CALL(*data_source, ReadProperty("debug.tracing.screen_brightness"))
+ .WillOnce(Return(base::nullopt));
+ data_source->Start();
+
+ protos::gen::TracePacket packet = writer_raw_->GetOnlyTracePacket();
+ auto properties = packet.android_system_property();
+ EXPECT_EQ(properties.values_size(), 0);
+}
+
+// TODO(simonmacm) test poll_ms
+} // namespace
+} // namespace perfetto
diff --git a/src/traced/probes/probes_producer.cc b/src/traced/probes/probes_producer.cc
index 8b9fc46c5..955f35d8b 100644
--- a/src/traced/probes/probes_producer.cc
+++ b/src/traced/probes/probes_producer.cc
@@ -36,6 +36,7 @@
#include "perfetto/tracing/core/trace_config.h"
#include "src/android_stats/statsd_logging_helper.h"
#include "src/traced/probes/android_log/android_log_data_source.h"
+#include "src/traced/probes/android_system_property/android_system_property_data_source.h"
#include "src/traced/probes/common/cpu_freq_info.h"
#include "src/traced/probes/filesystem/inode_file_data_source.h"
#include "src/traced/probes/ftrace/ftrace_data_source.h"
@@ -262,6 +263,17 @@ ProbesProducer::CreateDSInstance<InitialDisplayStateDataSource>(
endpoint_->CreateTraceWriter(buffer_id)));
}
+template <>
+std::unique_ptr<ProbesDataSource>
+ProbesProducer::CreateDSInstance<AndroidSystemPropertyDataSource>(
+ TracingSessionID session_id,
+ const DataSourceConfig& config) {
+ auto buffer_id = static_cast<BufferID>(config.target_buffer());
+ return std::unique_ptr<ProbesDataSource>(new AndroidSystemPropertyDataSource(
+ task_runner_, config, session_id,
+ endpoint_->CreateTraceWriter(buffer_id)));
+}
+
// Another anonymous namespace. This cannot be moved into the anonymous
// namespace on top (it would fail to compile), because the CreateDSInstance
// methods need to be fully declared before.
@@ -286,6 +298,7 @@ const DataSourceTraits kAllDataSources[] = {
Ds<InodeFileDataSource>(), Ds<LinuxPowerSysfsDataSource>(),
Ds<MetatraceDataSource>(), Ds<PackagesListDataSource>(),
Ds<ProcessStatsDataSource>(), Ds<SysStatsDataSource>(),
+ Ds<AndroidSystemPropertyDataSource>(),
Ds<SystemInfoDataSource>(),
};