From 4818011085da225e6fb80512163ac8a8a22aed7f Mon Sep 17 00:00:00 2001 From: Steve Fung Date: Wed, 30 Sep 2015 16:27:56 -0700 Subject: [PATCH] crash_reporter: Set Version and Product ID Read in the ro.build.id property for version, and ro.product.product_id for the Product ID. Bug: 22874192 Change-Id: I9a3fbf375d49d04fc7bf6700c5987cb9e435c318 --- crash_reporter/Android.mk | 1 + crash_reporter/crash_collector.cc | 16 ---------------- crash_reporter/user_collector.cc | 13 +++++++++++++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/crash_reporter/Android.mk b/crash_reporter/Android.mk index e797022c3..875695630 100644 --- a/crash_reporter/Android.mk +++ b/crash_reporter/Android.mk @@ -117,6 +117,7 @@ LOCAL_MODULE := crash_reporter_tests LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension) LOCAL_SHARED_LIBRARIES := libchrome \ libchromeos \ + libcutils \ libdbus \ libpcrecpp LOCAL_SRC_FILES := $(crash_reporter_test_src) diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc index b81a936cf..ae56b4ca5 100644 --- a/crash_reporter/crash_collector.cc +++ b/crash_reporter/crash_collector.cc @@ -53,9 +53,6 @@ const char kSystemCrashPath[] = "/data/misc/crash_reporter/crash"; const char kUploadVarPrefix[] = "upload_var_"; const char kUploadFilePrefix[] = "upload_file_"; -// Key of the lsb-release entry containing the OS version. -const char kLsbVersionKey[] = "CHROMEOS_RELEASE_VERSION"; - // Normally this path is not used. Unfortunately, there are a few edge cases // where we need this. Any process that runs as kDefaultUserName that crashes // is consider a "user crash". That includes the initial Chrome browser that @@ -387,27 +384,14 @@ void CrashCollector::AddCrashMetaUploadData(const std::string &key, void CrashCollector::WriteCrashMetaData(const FilePath &meta_path, const std::string &exec_name, const std::string &payload_path) { - chromeos::KeyValueStore store; - if (!store.Load(FilePath(lsb_release_))) { - LOG(ERROR) << "Problem parsing " << lsb_release_; - // Even though there was some failure, take as much as we could read. - } - - std::string version("unknown"); - if (!store.GetString(kLsbVersionKey, &version)) { - LOG(ERROR) << "Unable to read " << kLsbVersionKey << " from " - << lsb_release_; - } int64_t payload_size = -1; base::GetFileSize(FilePath(payload_path), &payload_size); std::string meta_data = StringPrintf("%sexec_name=%s\n" - "ver=%s\n" "payload=%s\n" "payload_size=%" PRId64 "\n" "done=1\n", extra_metadata_.c_str(), exec_name.c_str(), - version.c_str(), payload_path.c_str(), payload_size); // We must use WriteNewFile instead of base::WriteFile as we diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc index 61ccc37bd..a9522ccbe 100644 --- a/crash_reporter/user_collector.cc +++ b/crash_reporter/user_collector.cc @@ -55,6 +55,13 @@ static const uid_t kUnknownUid = -1; const char *UserCollector::kUserId = "Uid:\t"; const char *UserCollector::kGroupId = "Gid:\t"; +// The property containing the OS version. +const char kVersionProperty[] = "ro.build.id"; + +// The property containing the product id. +const char kProductIDProperty[] = "ro.product.product_id"; + + using base::FilePath; using base::StringPrintf; @@ -455,6 +462,12 @@ UserCollector::ErrorType UserCollector::ConvertAndEnqueueCrash( if (GetLogContents(FilePath(log_config_path_), exec, log_path)) AddCrashMetaData("log", log_path.value()); + char value[PROPERTY_VALUE_MAX]; + property_get(kVersionProperty, value, "undefined"); + AddCrashMetaUploadData("ver", value); + property_get(kProductIDProperty, value, "undefined"); + AddCrashMetaUploadData("prod", value); + ErrorType error_type = ConvertCoreToMinidump(pid, container_dir, core_path, minidump_path); if (error_type != kErrorNone) {