diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2019-09-20 14:03:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.ap-northeast-2.compute.internal> | 2019-09-20 14:03:52 +0000 |
commit | 9383342900f8f43a8fe43346735eea5e27a0260e (patch) | |
tree | afc92ccd5e403feef39808deba34fa59c2aff90a | |
parent | 497525d2ea6a203d42701156c555c8d2cf33f60a (diff) | |
parent | ba5046c2f791dd076b969fdf13a11dea81c07422 (diff) | |
download | resourced-9383342900f8f43a8fe43346735eea5e27a0260e.tar.gz resourced-9383342900f8f43a8fe43346735eea5e27a0260e.tar.bz2 resourced-9383342900f8f43a8fe43346735eea5e27a0260e.zip |
Merge "heart: Notify SluggishFW on app malfunction detection" into tizen
-rw-r--r-- | src/heart/heart-abnormal.c | 47 |
1 files changed, 47 insertions, 0 deletions
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 <stdio.h> #include <stdlib.h> #include <glib.h> +#include <sys/time.h> #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); |