Store time as millisecond which Historian wants 73/223273/5
authorKichan Kwon <k_c.kwon@samsung.com>
Tue, 28 Jan 2020 04:26:07 +0000 (13:26 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Wed, 19 Feb 2020 05:17:23 +0000 (14:17 +0900)
Change-Id: Ia397f689d54d80cd7ee5026c3e6bb7ca481caaf8
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
include/bd_history_item.h
src/battery_dump/bd_history_item.c
src/battery_dump/bm_listeners.c

index 011cd95..af4ca0c 100644 (file)
@@ -34,8 +34,8 @@ typedef struct _history_tag_s {
 } history_tag_s;
 
 typedef struct _history_item_s {
-       long int time_s;
-       long int time_current;
+       long long time_s;
+       long long time_current;
        int cmd_s;
        int state_1;
        int state_2;
@@ -55,8 +55,8 @@ typedef struct _history_item_s {
 
 // Private
 typedef struct _dump_data_s {
-       long int time_s;
-       long int time_current;
+       long long time_s;
+       long long time_current;
        int dump_1;
        int dump_2;
        int state_1;
index d543863..1b975c3 100644 (file)
@@ -18,7 +18,7 @@
 #include <dumpsys-system.h>
 #include <string.h>
 #include <stdlib.h>
-#include <time.h>
+#include <sys/time.h>
 #include <glib/gprintf.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -634,10 +634,10 @@ static int bd_get_history_detail_from_dump(int index, history_item_s* dump_node)
                _DBG("Wakereason_Tag_NULL");
 
        dump_node->time_s = history_data[index].time_s;
-       _DBG("TIME_S is %ld", dump_node->time_s);
+       _DBG("TIME_S is %lld", dump_node->time_s);
 
        dump_node->time_current = history_data[index].time_current;
-       _DBG("C TIME is %ld", dump_node->time_current);
+       _DBG("C TIME is %lld", dump_node->time_current);
 
        EXIT;
        return BATTERY_MONITOR_ERROR_NONE;
@@ -711,16 +711,16 @@ int bd_print_history_item_main(int fd, int num_h_items, long base_time, bool chk
                        dump_p = g_string_append_c(dump_p, ',');
                        _DBG("value %s", dump_p->str);
                        if (old_state.time_s < 0) {
-                               g_string_append_printf(dump_p, "%ld",
+                               g_string_append_printf(dump_p, "%lld",
                                                (new_state.time_s - base_time));
                                _DBG("value %s", dump_p->str);
                        } else {
-                               g_string_append_printf(dump_p, "%ld",
+                               g_string_append_printf(dump_p, "%lld",
                                                (new_state.time_s - old_state.time_s));
                                _DBG("value %s", dump_p->str);
                        }
                        old_state.time_s = new_state.time_s;
-                       _DBG("Value old_state.time_s %ld", old_state.time_s);
+                       _DBG("Value old_state.time_s %lld", old_state.time_s);
                } else { //: Let's skip the NC mode in initial version
                }
                if (new_state.cmd_s == CM_ST) {
@@ -746,7 +746,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long base_time, bool chk
                        dump_p = g_string_append(dump_p, "TIME:");
                        _DBG("value %s", dump_p->str);
                        if (chkin) {
-                               g_string_append_printf(dump_p, "%ld", new_state.time_current);
+                               g_string_append_printf(dump_p, "%lld", new_state.time_current);
                                _DBG("value %s", dump_p->str);
                                dump_p = g_string_append(dump_p, "\n");
                                _DBG("value %s", dump_p->str);
@@ -1068,8 +1068,10 @@ static int bd_set_history_from_listener(history_item_s* nrec)
        BM_CHECK_INPUT_PARAM(nrec);
 
        int dvar1 = 0, dvar2 = 0;
-       time_t current_time;
-       time(&current_time); //This time needs to be changed to MT
+       struct timeval tv;
+       gettimeofday(&tv, NULL);
+
+       time_t current_time = tv.tv_sec;
 
 //     history_data[h_count].time_s = current_time;// comment for testing with test fn
        history_data[h_count].time_s = nrec->time_s;
@@ -1104,7 +1106,7 @@ static int bd_set_history_from_listener(history_item_s* nrec)
                history_data[h_count].event_tag = nrec->event_tag;
        }
        if (nrec->cmd_s == CM_CRR_TIME || nrec->cmd_s == CM_RST)
-               history_data[h_count].time_current = current_time;
+               history_data[h_count].time_current = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
 
        history_data[h_count].state_1 = nrec->state_1;
        history_data[h_count].state_2 = nrec->state_2;
index 7a853a3..3959647 100644 (file)
@@ -23,8 +23,7 @@
 #include <bd_history_item.h>
 #include <vconf.h>
 #include <pthread.h>
-
-
+#include <sys/time.h>
 
 wifi_manager_h wifi = NULL;
 static bool display_on;
@@ -755,9 +754,11 @@ static void bm_create_event_data(int type,int val)
 
 
        data_obj->cmd_s = CM_UPD;
-       data_obj->time_s = 0;
        data_obj->time_current = 0;
 
+       struct timeval tv;
+       gettimeofday(&tv, NULL);
+       data_obj->time_s = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
 
        data_obj->battery_level = bm_battery_level_listener();
        if(data_obj->battery_level < 0)