heart: Notify SluggishFW on app malfunction detection 57/212457/3
authorjyotsna.a@samsung.com <jyotsna.a@samsung.com>
Tue, 20 Dec 2016 12:49:35 +0000 (18:19 +0530)
committerMichal Bloch <m.bloch@partner.samsung.com>
Thu, 12 Sep 2019 18:19:23 +0000 (18:19 +0000)
[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 <jyotsna.a@samsung.com>
src/heart/heart-abnormal.c

index 2636ec9..2aba308 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <glib.h>
+#include <sys/time.h>
 
 #include "proc-common.h"
 #include "notifier.h"
 #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);