Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8cd9994 authored by Steve Fung's avatar Steve Fung Committed by Android Git Automerger
Browse files

am fcc93587: Merge "crash_reporter: Update to use the os-release.d configs"

* commit 'fcc93587':
  crash_reporter: Update to use the os-release.d configs
parents a6be63e9 fcc93587
Loading
Loading
Loading
Loading
+3 −21
Original line number Diff line number Diff line
@@ -298,8 +298,8 @@ send_crash() {
  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 @@ send_crash() {
    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 @@ send_crash() {
  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
+20 −15
Original line number Diff line number Diff line
@@ -59,13 +59,10 @@ static const gid_t kUnknownGid = -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";

// 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 @@ 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);

  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);