summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2021-05-13 12:04:06 -0700
committerYabin Cui <yabinc@google.com>2021-05-13 12:04:06 -0700
commitf9ae7ab0e4b0e58785417945b4966bf2d49bd290 (patch)
treee46db3aaa3f746c70828bf12ef339043b468d9b5
parentce2a3e4b91eceaf5cb023fd45028c84cc1792be8 (diff)
downloadextras-f9ae7ab0e4b0e58785417945b4966bf2d49bd290.tar.gz
simpleperf: add more device info in recording file.
Add android_sdk_version and android_build_type in meta info. Bug: 186469540 Test: run simpleperf_unit_test Change-Id: Ifcab8c93e5565bd3df8cc4f0ef167e537c08b2c5
-rw-r--r--simpleperf/cmd_record.cpp2
-rw-r--r--simpleperf/cmd_record_test.cpp15
2 files changed, 17 insertions, 0 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp
index 2e646bb4..18e4888c 100644
--- a/simpleperf/cmd_record.cpp
+++ b/simpleperf/cmd_record.cpp
@@ -1914,6 +1914,8 @@ bool RecordCommand::DumpMetaInfoFeature(bool kernel_symbols_available) {
android::base::GetProperty("ro.product.model", "").c_str(),
android::base::GetProperty("ro.product.name", "").c_str());
info_map["android_version"] = android::base::GetProperty("ro.build.version.release", "");
+ info_map["android_sdk_version"] = android::base::GetProperty("ro.build.version.sdk", "");
+ info_map["android_build_type"] = android::base::GetProperty("ro.build.type", "");
if (!app_package_name_.empty()) {
info_map["app_package_name"] = app_package_name_;
}
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index 3e0b9e1a..c59641ca 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -1177,3 +1177,18 @@ TEST(record_cmd, add_meta_info_option) {
ASSERT_FALSE(RunRecordCmd({"--add-meta-info", "key1="}, tmpfile.path));
ASSERT_FALSE(RunRecordCmd({"--add-meta-info", "=value1"}, tmpfile.path));
}
+
+TEST(record_cmd, device_meta_info) {
+ TemporaryFile tmpfile;
+ ASSERT_TRUE(RunRecordCmd({}, tmpfile.path));
+ auto reader = RecordFileReader::CreateInstance(tmpfile.path);
+ ASSERT_TRUE(reader);
+
+ const std::unordered_map<std::string, std::string>& meta_info = reader->GetMetaInfoFeature();
+ auto it = meta_info.find("android_sdk_version");
+ ASSERT_NE(it, meta_info.end());
+ ASSERT_FALSE(it->second.empty());
+ it = meta_info.find("android_build_type");
+ ASSERT_NE(it, meta_info.end());
+ ASSERT_FALSE(it->second.empty());
+}