From 568336613fc8e37ca4fcb3d40053064cf05a837a Mon Sep 17 00:00:00 2001 From: Steve Fung Date: Fri, 16 Oct 2015 02:17:53 -0700 Subject: [PATCH] crash_reporter: Use os-release.d to store the crash server url Since all of the other configs use os-release.d rather than system properties, switch the crash server url as well. This also makes the product configuration more straightforward. Bug: 24989289 Change-Id: Ia4b423e59937a917c882e74b110b5ea520ca6016 --- crash_reporter/Android.mk | 17 +++++++++++++++++ crash_reporter/crash_sender | 12 ++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/crash_reporter/Android.mk b/crash_reporter/Android.mk index 875695630..11dfcbc82 100644 --- a/crash_reporter/Android.mk +++ b/crash_reporter/Android.mk @@ -60,6 +60,7 @@ LOCAL_C_INCLUDES := $(crash_reporter_includes) LOCAL_REQUIRED_MODULES := core2md \ crash_reporter_logs.conf \ crash_sender \ + crash_server \ dbus-send LOCAL_INIT_RC := crash_reporter.rc LOCAL_RTTI_FLAG := -frtti @@ -92,6 +93,22 @@ LOCAL_SHARED_LIBRARIES := libmetrics LOCAL_SRC_FILES := $(warn_collector_src) include $(BUILD_EXECUTABLE) +# /etc/os-release.d/crash_server configuration file. +# ======================================================== +ifdef OSRELEASED_DIRECTORY +include $(CLEAR_VARS) +LOCAL_MODULE := crash_server +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY) +include $(BUILD_SYSTEM)/base_rules.mk + +# If the crash server isn't set, use a blank value. crash_sender +# will log it as a configuration error. +$(LOCAL_BUILT_MODULE): BRILLO_CRASH_SERVER ?= "" +$(LOCAL_BUILT_MODULE): + echo $(BRILLO_CRASH_SERVER) > $@ +endif + # Crash reporter logs conf file. # ======================================================== include $(CLEAR_VARS) diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender index 1f5879284..5b859a877 100755 --- a/crash_reporter/crash_sender +++ b/crash_reporter/crash_sender @@ -78,6 +78,9 @@ DEVCOREDUMP_UPLOAD_FLAG_FILE="${CRASH_STATE_DIR}/device_coredump_upload_allowed" # The weave configuration file. WEAVE_CONF_FILE="/etc/weaved/weaved.conf" +# The os-release.d folder. +OSRELEASED_FOLDER="/etc/os-release.d" + # The syslog tag for all logging we emit. TAG="$(basename $0)[$$]" @@ -256,7 +259,12 @@ get_kind() { get_key_value() { local file="$1" key="$2" value - if [ -f "${file}" ]; then + if [ -f "${file}/${key}" ]; then + # Get the value from a folder where each key is its own file. The key + # file's entire contents is the value. + value=$(cat "${file}/${key}") + elif [ -f "${file}" ]; then + # Get the value from a file that has multiple key=value combinations. # Return the first entry. There shouldn't be more than one anyways. # Substr at length($1) + 2 skips past the key and following = sign (awk # uses 1-based indexes), but preserves embedded = characters. @@ -291,7 +299,7 @@ send_crash() { local report_payload="$(get_key_value "${meta_path}" "payload")" local kind="$(get_kind "${meta_path}")" local exec_name="$(get_key_value "${meta_path}" "exec_name")" - local url="$(getprop crash_reporter.server)" + local url="$(get_key_value "${OSRELEASED_FOLDER}" "crash_server")" local bdk_version="$(get_key_value "${meta_path}" "bdk_version")" local hwclass="$(get_hardware_class)" local write_payload_size="$(get_key_value "${meta_path}" "payload_size")"