summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2015-12-10 22:25:33 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-12-10 22:25:33 +0000
commitf2b8cb9023c3f41f3655e8b34a5bee40ee70b948 (patch)
treef9c13329dc6b0c4b20d746b3305d68277fababbe
parent5fc82ef714a462fdceda791035fc1a9847e83458 (diff)
parent8361935de89a5092cfb54245e55e454981f99f11 (diff)
downloadcore-f2b8cb9023c3f41f3655e8b34a5bee40ee70b948.tar.gz
core-f2b8cb9023c3f41f3655e8b34a5bee40ee70b948.tar.bz2
core-f2b8cb9023c3f41f3655e8b34a5bee40ee70b948.zip
Merge "crash_reporter: use libmetricscollectorservice for user crash event reports"
-rw-r--r--crash_reporter/Android.mk15
-rw-r--r--crash_reporter/crash_reporter.cc42
2 files changed, 21 insertions, 36 deletions
diff --git a/crash_reporter/Android.mk b/crash_reporter/Android.mk
index 81cb458f5..565963cbc 100644
--- a/crash_reporter/Android.mk
+++ b/crash_reporter/Android.mk
@@ -43,11 +43,12 @@ LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension)
LOCAL_C_INCLUDES := $(crash_reporter_includes)
LOCAL_RTTI_FLAG := -frtti
LOCAL_SHARED_LIBRARIES := libchrome \
+ libbinder \
libbrillo \
libcutils \
- libdbus \
libmetrics \
libpcrecpp
+LOCAL_STATIC_LIBRARIES := libmetricscollectorservice
LOCAL_SRC_FILES := $(crash_reporter_src)
include $(BUILD_STATIC_LIBRARY)
@@ -60,18 +61,19 @@ LOCAL_C_INCLUDES := $(crash_reporter_includes)
LOCAL_REQUIRED_MODULES := core2md \
crash_reporter_logs.conf \
crash_sender \
- crash_server \
- dbus-send
+ crash_server
LOCAL_INIT_RC := crash_reporter.rc
LOCAL_RTTI_FLAG := -frtti
LOCAL_SHARED_LIBRARIES := libchrome \
+ libbinder \
libbrillo \
libcutils \
- libdbus \
libmetrics \
- libpcrecpp
+ libpcrecpp \
+ libutils
LOCAL_SRC_FILES := crash_reporter.cc
-LOCAL_STATIC_LIBRARIES := libcrash
+LOCAL_STATIC_LIBRARIES := libcrash \
+ libmetricscollectorservice
include $(BUILD_EXECUTABLE)
# Crash sender script.
@@ -140,7 +142,6 @@ LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension)
LOCAL_SHARED_LIBRARIES := libchrome \
libbrillo \
libcutils \
- libdbus \
libpcrecpp
LOCAL_SRC_FILES := $(crash_reporter_test_src)
LOCAL_STATIC_LIBRARIES := libcrash libgmock
diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc
index 3955fe54b..26ffa3803 100644
--- a/crash_reporter/crash_reporter.cc
+++ b/crash_reporter/crash_reporter.cc
@@ -25,10 +25,13 @@
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
+#include <binder/IServiceManager.h>
#include <brillo/flag_helper.h>
-#include <brillo/process.h>
#include <brillo/syslog_logging.h>
+#include <metrics/metrics_collector_service_client.h>
#include <metrics/metrics_library.h>
+#include <utils/String16.h>
+
#include "kernel_collector.h"
#include "kernel_warning_collector.h"
@@ -37,8 +40,6 @@
#include "user_collector.h"
static const char kCrashCounterHistogram[] = "Logging.CrashCounter";
-static const char kUserCrashSignal[] =
- "org.chromium.CrashReporter.UserCrash";
static const char kKernelCrashDetected[] = "/var/run/kernel-crash-detected";
static const char kUncleanShutdownDetected[] =
"/var/run/unclean-shutdown-detected";
@@ -56,6 +57,7 @@ enum CrashKinds {
static MetricsLibrary s_metrics_lib;
+using android::brillo::metrics::IMetricsCollectorService;
using base::FilePath;
using base::StringPrintf;
@@ -88,32 +90,14 @@ static void CountUncleanShutdown() {
static void CountUserCrash() {
SendCrashMetrics(kCrashKindUser, "user");
- // Announce through D-Bus whenever a user crash happens. This is
- // used by the metrics daemon to log active use time between
- // crashes.
- //
- // We run in the background in case dbus-daemon itself is crashed
- // and not responding. This allows us to not block and potentially
- // deadlock on a dbus-daemon crash. If dbus-daemon crashes without
- // restarting, each crash will fork off a lot of dbus-send
- // processes. Such a system is in a unusable state and will need
- // to be restarted anyway.
- //
- // Note: This will mean that the dbus-send process will become a zombie and
- // reparent to init for reaping, but that's OK -- see above.
-
- brillo::ProcessImpl dbus_send;
- dbus_send.AddArg("/system/bin/dbus-send");
- dbus_send.AddArg("--type=signal");
- dbus_send.AddArg("--system");
- dbus_send.AddArg("/");
- dbus_send.AddArg(kUserCrashSignal);
- bool status = dbus_send.Start();
- if (status) {
- dbus_send.Release();
- } else {
- PLOG(WARNING) << "Sending UserCrash DBus signal failed";
- }
+ // Tell the metrics collector about the user crash, in order to log active
+ // use time between crashes.
+ MetricsCollectorServiceClient metrics_collector_service;
+
+ if (metrics_collector_service.Init())
+ metrics_collector_service.notifyUserCrash();
+ else
+ LOG(ERROR) << "Failed to send user crash notification to metrics_collector";
}