Merge "metricsd: Read build time values from etc/os-release.d."
diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender
index e38d410..1f58792 100755
--- a/crash_reporter/crash_sender
+++ b/crash_reporter/crash_sender
@@ -298,8 +298,8 @@
local log="$(get_key_value "${meta_path}" "log")"
local sig="$(get_key_value "${meta_path}" "sig")"
local send_payload_size="$(stat -c "%s" "${report_payload}" 2>/dev/null)"
- local product="$(get_key_value "${meta_path}" "upload_var_prod")"
- local version="$(get_key_value "${meta_path}" "upload_var_ver")"
+ local product="$(get_key_value "${meta_path}" "product_id")"
+ local version="$(get_key_value "${meta_path}" "product_version")"
local upload_prefix="$(get_key_value "${meta_path}" "upload_prefix")"
local guid
local model_manifest_id="$(get_key_value "${WEAVE_CONF_FILE}" "model_id")"
@@ -350,25 +350,6 @@
esac
done
- # When uploading Chrome reports we need to report the right product and
- # version. If the meta file does not specify it, use GOOGLE_CRASH_ID
- # as the product and GOOGLE_CRASH_VERSION_ID as the version.
- if [ "${product}" = "undefined" ]; then
- product="$(get_key_value /etc/os-release 'GOOGLE_CRASH_ID')"
- fi
- if [ "${version}" = "undefined" ]; then
- version="$(get_key_value /etc/os-release 'GOOGLE_CRASH_VERSION_ID')"
- fi
-
- # If GOOGLE_CRASH_* is undefined, we look for ID and VERSION_ID in
- # /etc/os-release.
- if [ "${product}" = "undefined" ]; then
- product="$(get_key_value /etc/os-release 'ID')"
- fi
- if [ "${version}" = "undefined" ]; then
- version="$(get_key_value /etc/os-release 'VERSION_ID')"
- fi
-
# If ID or VERSION_ID is undefined, we use the default product name
# and bdk_version from /etc/os-release.d.
if [ "${product}" = "undefined" ]; then
@@ -408,6 +389,7 @@
lecho " Metadata: ${meta_path} (${kind})"
lecho " Payload: ${report_payload}"
lecho " Version: ${version}"
+ lecho " Bdk Version: ${bdk_version}"
[ -n "${image_type}" ] && lecho " Image type: ${image_type}"
[ -n "${boot_mode}" ] && lecho " Boot mode: ${boot_mode}"
if is_mock; then
diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc
index 53fbb14..56e7bb9 100644
--- a/crash_reporter/user_collector.cc
+++ b/crash_reporter/user_collector.cc
@@ -59,13 +59,10 @@
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";
-
+// Product information keys in the /etc/os-release.d folder.
static const char kBdkVersionKey[] = "bdk_version";
+static const char kProductIDKey[] = "product_id";
+static const char kProductVersionKey[] = "product_version";
using base::FilePath;
@@ -508,20 +505,28 @@
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);
-
brillo::OsReleaseReader reader;
reader.Load();
- std::string bdk_version = "undefined";
- if (!reader.GetString(kBdkVersionKey, &bdk_version)) {
+ std::string value = "undefined";
+ if (!reader.GetString(kBdkVersionKey, &value)) {
LOG(ERROR) << "Could not read " << kBdkVersionKey
<< " from /etc/os-release.d/";
}
- AddCrashMetaData(kBdkVersionKey, bdk_version);
+ AddCrashMetaData(kBdkVersionKey, value);
+
+ value = "undefined";
+ if (!reader.GetString(kProductIDKey, &value)) {
+ LOG(ERROR) << "Could not read " << kProductIDKey
+ << " from /etc/os-release.d/";
+ }
+ AddCrashMetaData(kProductIDKey, value);
+
+ value = "undefined";
+ if (!reader.GetString(kProductVersionKey, &value)) {
+ LOG(ERROR) << "Could not read " << kProductVersionKey
+ << " from /etc/os-release.d/";
+ }
+ AddCrashMetaData(kProductVersionKey, value);
ErrorType error_type =
ConvertCoreToMinidump(pid, container_dir, core_path, minidump_path);
diff --git a/libcutils/tests/MemsetTest.cpp b/libcutils/tests/MemsetTest.cpp
index 45efc51..a98485f 100644
--- a/libcutils/tests/MemsetTest.cpp
+++ b/libcutils/tests/MemsetTest.cpp
@@ -20,6 +20,8 @@
#include <sys/mman.h>
#include <sys/types.h>
+#include <memory>
+
#include <cutils/memory.h>
#include <gtest/gtest.h>
@@ -127,14 +129,14 @@
min_incr = 2;
value |= value << 16;
}
- uint32_t* expected_buf = new uint32_t[MAX_TEST_SIZE/sizeof(uint32_t)];
+ std::unique_ptr<uint32_t[]> expected_buf(new uint32_t[MAX_TEST_SIZE/sizeof(uint32_t)]);
for (size_t i = 0; i < MAX_TEST_SIZE/sizeof(uint32_t); i++) {
expected_buf[i] = value;
}
// Allocate one large buffer with lots of extra space so that we can
// guarantee that all possible alignments will fit.
- uint8_t *buf = new uint8_t[3*MAX_TEST_SIZE];
+ std::unique_ptr<uint8_t[]> buf(new uint8_t[3*MAX_TEST_SIZE]);
uint8_t *buf_align;
for (size_t i = 0; i < num_aligns; i++) {
size_t incr = min_incr;
@@ -142,7 +144,7 @@
incr = GetIncrement(len, min_incr);
buf_align = reinterpret_cast<uint8_t*>(GetAlignedPtr(
- buf+FENCEPOST_LENGTH, align[i][0], align[i][1]));
+ buf.get()+FENCEPOST_LENGTH, align[i][0], align[i][1]));
SetFencepost(&buf_align[-FENCEPOST_LENGTH]);
SetFencepost(&buf_align[len]);
@@ -153,15 +155,13 @@
} else {
android_memset32(reinterpret_cast<uint32_t*>(buf_align), value, len);
}
- ASSERT_EQ(0, memcmp(expected_buf, buf_align, len))
+ ASSERT_EQ(0, memcmp(expected_buf.get(), buf_align, len))
<< "Failed size " << len << " align " << align[i][0] << " " << align[i][1] << "\n";
VerifyFencepost(&buf_align[-FENCEPOST_LENGTH]);
VerifyFencepost(&buf_align[len]);
}
}
- delete expected_buf;
- delete buf;
}
TEST(libcutils, android_memset16_non_zero) {