From ba5046c2f791dd076b969fdf13a11dea81c07422 Mon Sep 17 00:00:00 2001 From: "jyotsna.a@samsung.com" Date: Tue, 20 Dec 2016 18:19:35 +0530 Subject: heart: Notify SluggishFW on app malfunction detection [Problem] New request from Tizen community [Cause & Measure] Updating sluggish FW to support app malfunction reporting Change-Id: If2a183a2504f29b30b03dcb969338e5dc89850a9 Signed-off-by: jyotsna.a@samsung.com --- src/heart/heart-abnormal.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/heart/heart-abnormal.c b/src/heart/heart-abnormal.c index 2636ec95..2aba308d 100644 --- a/src/heart/heart-abnormal.c +++ b/src/heart/heart-abnormal.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "proc-common.h" #include "notifier.h" @@ -44,6 +45,12 @@ #define ABNORMAL_DATA_MAX 1024 #define ABNORMAL_CHECK_NUM 10 +#define TIMESTAMP_LEN 16 +#define MILLISEC 1000 +#define TIME_MAX_LEN 64 +#define SLUG_TYPE_MALFUN "6" +#define NOPID "-" + enum abnormal_type { FC = 0, ANR = 1, @@ -154,6 +161,45 @@ static void heart_abnormal_launch_popup(char *appid, int count) #endif } +static int heart_abnormal_report_malfunction(char *name) +{ + int ret = -1; + char *param[5] = {0,}; + char timestr[TIMESTAMP_LEN] = {0,}; + char msgid[TIME_MAX_LEN] = {0,}; + char ts[TIME_MAX_LEN] = {0,}; + char pa1[TIMESTAMP_LEN] = {0,}; + char pa2[TIMESTAMP_LEN] = {0,}; + struct timeval time_of_day; + int milli; + time_t unix_time = time(NULL); + + if (gettimeofday(&time_of_day, NULL)) { + _E("gettimeofday failed"); + return ret; + } + + snprintf(timestr, sizeof(timestr), "%.10ld", unix_time); + milli = time_of_day.tv_usec / MILLISEC; + strftime(ts, TIME_MAX_LEN, "%Y.%m.%d-%H:%M:%S", localtime(&time_of_day.tv_sec)); + snprintf(msgid, sizeof(msgid), "%s+%d", ts, milli); + snprintf(pa1, TIMESTAMP_LEN, SLUG_TYPE_MALFUN); + snprintf(pa2, TIMESTAMP_LEN, NOPID); + + param[0] = pa1; + param[1] = pa2; + param[2] = name; + param[3] = timestr; + param[4] = msgid; + + ret = d_bus_call_method_async("org.tizen.system.crash", "/Org/Tizen/System/Crash/Crash", "org.tizen.system.crash.Crash", + "sluggish_dump", "iisss", param); + + if (ret < 0) + _E("Malfunction reporting to sluggish tool failed"); + return ret; +} + static void heart_abnormal_process_crashed(GVariant *params) { int ret, notify, count; @@ -195,6 +241,7 @@ static void heart_abnormal_process_crashed(GVariant *params) if (count > ABNORMAL_CHECK_NUM) { heart_abnormal_launch_popup(appid, count); notify = 1; + heart_abnormal_report_malfunction(appid); } g_hash_table_remove_all(heart_abnormal_list); -- cgit v1.2.3