am dc45e39b: am f14e5c6b: am 2218720d: Merge "crash_reporter: Use os-release.d to store the crash server url"

* commit 'dc45e39b4e007d41b23736cd44c212c8c7fb618d':
  crash_reporter: Use os-release.d to store the crash server url
This commit is contained in:
Steve Fung 2015-10-16 17:45:44 +00:00 committed by Android Git Automerger
commit 7744e1a782
2 changed files with 27 additions and 2 deletions

View File

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

View File

@ -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")"