Correct log time wrt config param 09/231209/1
authorDewal Agarwal <d1.agarwal@samsung.com>
Mon, 20 Apr 2020 06:57:14 +0000 (12:27 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Mon, 20 Apr 2020 06:57:14 +0000 (12:27 +0530)
Change-Id: I8f89374553c2725886bf4442fc0e62a501f9b496
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
include/bm_util.h
src/bm_power_engine.c
src/bm_util.c

index a278643..e9b093d 100644 (file)
@@ -61,7 +61,7 @@ void bm_appid_usage_free(appid_usage_s *data);
 
 void bm_resourceid_usage_free(resourceid_usage_s *data);
 
-long int bm_get_log_time();
+long int bm_get_log_time(int bias);
 
 void bm_set_free_atm_st2_list(GSList *atm_list);
 
index 39364b6..253d9b7 100644 (file)
@@ -339,7 +339,7 @@ static int bm_insert_appid_session_usage_to_db()
 
        int ret_val = BATTERY_MONITOR_ERROR_NONE;
 
-       long int ret_time = bm_get_log_time();
+       long int ret_time = bm_get_log_time(data_collection_period);
 
        g_hash_table_iter_init(&iter, gl_hash);
 
@@ -494,7 +494,7 @@ int bm_ble_calc_power_and_commit(bm_bluetooth_st *handle, bool mode)
        long int P_power_app_bt = 0, P_power_app_data = 0, P_power_app_conn = 0;
        char *appid = NULL;
        long int apprx = 0, apptx = 0;
-       long int ret_time = bm_get_log_time();
+       long int ret_time = bm_get_log_time(data_collection_period);
 
        /* Coefficient to divide the rx and tx time wrt rx and tx bytes */
        double crtx_t = 0;
@@ -710,7 +710,7 @@ int bm_wifi_calc_power_and_commit(bm_wifi_st *handle, bool mode)
        long int apprx = 0, apptx = 0;
        double apptime = 0, crx_t = 0, ctx_t = 0;
        long int rx_t = 0, tx_t = 0;
-       long int ret_time = bm_get_log_time();
+       long int ret_time = bm_get_log_time(data_collection_period);
 
        /* Coefficient to divide the rx and tx time wrt rx and tx bytes */
        if (RX != 0)
@@ -907,7 +907,7 @@ int bm_cpu_calc_power_and_commit(bm_cpu_st *handle, bool mode)
        long int P_power_app_cpu = 0, P_power_app_use = 0;
        double apptime = 0;
        char *appid = NULL;
-       long int ret_time = bm_get_log_time();
+       long int ret_time = bm_get_log_time(data_collection_period);
 
        appid_usage_s *app_usage = (appid_usage_s *)calloc(1, sizeof(appid_usage_s));
        if (app_usage == NULL) {
@@ -1058,7 +1058,7 @@ int bm_display_calc_power_and_commit(bm_display_st *handle, bool mode)
        long int P_power_app_disp = 0, P_power_app_on = 0;
        char *appid = NULL;
        double apptime = 0;
-       long int ret_time = bm_get_log_time();
+       long int ret_time = bm_get_log_time(data_collection_period);
 
        appid_usage_s *app_usage = (appid_usage_s *)calloc(1, sizeof(appid_usage_s));
        if (app_usage == NULL) {
@@ -1228,7 +1228,7 @@ int bm_device_network_calc_power_and_commit(bm_device_network_st *handle, bool m
        char *appid = NULL;
        long int apprx = 0, apptx = 0;
        double apptime = 0;
-       long int ret_time = bm_get_log_time();
+       long int ret_time = bm_get_log_time(data_collection_period);
 
        appid_usage_s *app_usage = (appid_usage_s *)calloc(1, sizeof(appid_usage_s));
        if (app_usage == NULL) {
@@ -1383,7 +1383,7 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle)
        int P_power_app_gps = 0, P_power_app_conn = 0;
        char *appid = NULL;
        int apptime = 0;
-       long int ret_time = bm_get_log_time();
+       long int ret_time = bm_get_log_time(data_collection_period);
 
        appid_usage_s *app_usage = (appid_usage_s *)calloc(1, sizeof(appid_usage_s));
        if (app_usage == NULL) {
index 81b96ce..0a2b90e 100644 (file)
@@ -392,7 +392,7 @@ void bm_resourceid_usage_free(resourceid_usage_s *data)
        return;
 }
 
-long int bm_get_log_time()
+long int bm_get_log_time(int bias)
 {
        ENTER;
 
@@ -400,8 +400,8 @@ long int bm_get_log_time()
        time_t curr_time;
 
        time(&curr_time);
-
-       ret = curr_time;
+       bias /= 1000;
+       ret = (curr_time - bias);
 
        EXIT;
        return ret;