diff options
author | Dewal Agarwal <d1.agarwal@samsung.com> | 2020-09-29 17:59:50 +0530 |
---|---|---|
committer | Dewal Agarwal <d1.agarwal@samsung.com> | 2020-10-29 12:51:10 +0530 |
commit | fcdf6a9c8545c25838820a3b3694ec19375a8043 (patch) | |
tree | a5487b39825fcc34c081962822ad9facbac6a981 /src | |
parent | e784c0e27004e6d04a289db46d4583857c75bcd1 (diff) | |
download | batterymonitor-fcdf6a9c8545c25838820a3b3694ec19375a8043.tar.gz batterymonitor-fcdf6a9c8545c25838820a3b3694ec19375a8043.tar.bz2 batterymonitor-fcdf6a9c8545c25838820a3b3694ec19375a8043.zip |
Change Dump formats
Change-Id: I882746fbe71d69cbdd93be0839de3a372003860d
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/battery_dump/bd_history_item.c | 168 | ||||
-rw-r--r-- | src/bm_server_db.c | 2 |
2 files changed, 66 insertions, 104 deletions
diff --git a/src/battery_dump/bd_history_item.c b/src/battery_dump/bd_history_item.c index 569b7eb..37dd684 100644 --- a/src/battery_dump/bd_history_item.c +++ b/src/battery_dump/bd_history_item.c @@ -213,13 +213,14 @@ static int bd_get_pool_entry_from_dump(int fd) return BATTERY_MONITOR_ERROR_NONE; } -static int bd_get_and_print_system_base_battery_usage_from_dump(int fd, long int duration) +static int bd_get_and_print_system_base_battery_usage_from_dump(int fd, long int dstart_time) { ENTER; int ret = BATTERY_MONITOR_ERROR_NONE; float usage_mah = 0; time_t crr_time = 0; time(&crr_time); + long int dend_time = crr_time; int uid_n = 1000; //For Tizen // Base Resource usage; const char *rid_str = NULL; @@ -230,7 +231,7 @@ static int bd_get_and_print_system_base_battery_usage_from_dump(int fd, long int return BATTERY_MONITOR_ERROR_INTERNAL; } resourceid_usage_s *res_use = - bm_server_query_resource_base_usage_resourceid_ci(rid_str, duration, crr_time, &ret); + bm_server_query_resource_base_usage_resourceid_ci(rid_str, dstart_time, dend_time, &ret); if (res_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("For resourceid %s", rid_str); continue; @@ -254,7 +255,7 @@ static int bd_get_and_print_system_base_battery_usage_from_dump(int fd, long int return ret; } -static int bd_get_and_print_battery_usage_from_dump(int fd, long int duration) +static int bd_get_and_print_battery_usage_from_dump(int fd, long int dstart_time) { ENTER; int ret = BATTERY_MONITOR_ERROR_NONE; @@ -263,7 +264,7 @@ static int bd_get_and_print_battery_usage_from_dump(int fd, long int duration) gpointer key, value; GString *dump_p = NULL; char *appid = NULL; int *uid_n = NULL; time_t crr_time = 0; time(&crr_time); - long int end_t = crr_time; + long int dend_time = crr_time; float usageMAh = 0; int battery_capacity = 500;//default ret = bm_get_battery_power_params(&battery_capacity); @@ -290,7 +291,7 @@ static int bd_get_and_print_battery_usage_from_dump(int fd, long int duration) while (g_hash_table_iter_next(&iter, &key, &value)) { uid_n = (int *)key; appid = (char *)value; _DBG("%d %s", *uid_n, appid); usageMAh = 0; - appid_usage_s *app_use = bm_server_query_app_usage_by_appid_ci(appid, duration, end_t, &ret); + appid_usage_s *app_use = bm_server_query_app_usage_by_appid_ci(appid, dstart_time, dend_time, &ret); if (app_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("For appid %s", appid); continue; @@ -323,7 +324,7 @@ static int bd_get_and_print_battery_usage_from_dump(int fd, long int duration) return BATTERY_MONITOR_ERROR_INTERNAL; } resourceid_usage_s *res_use = - bm_server_query_resource_usage_resourceid_ci(rid_str, duration, end_t, &ret); + bm_server_query_resource_usage_resourceid_ci(rid_str, dstart_time, dend_time, &ret); if (res_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("For resourceid %s", rid_str); continue; @@ -363,7 +364,7 @@ static int bd_get_and_print_battery_usage_from_dump(int fd, long int duration) g_string_free(dump_p, TRUE); } - ret = bd_get_and_print_system_base_battery_usage_from_dump(fd, duration); + ret = bd_get_and_print_system_base_battery_usage_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("Base usage dump failed"); @@ -371,7 +372,7 @@ static int bd_get_and_print_battery_usage_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_gbr_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_gbr_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; // Dump brightness Data @@ -379,7 +380,7 @@ static int bd_get_and_print_gbr_stat_entry_from_dump(int fd, long int duration) BM_CHECK_MEM_ALLOC(gbr_stat, {}); int ret = BATTERY_MONITOR_ERROR_NONE; - ret = bm_server_battery_dump_query_from_db(gbr_stat, 3, duration); + ret = bm_server_battery_dump_query_from_db(gbr_stat, 3, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gbr_stat); @@ -403,7 +404,7 @@ static int bd_get_and_print_gbr_stat_entry_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_misc_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_misc_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; //Dump screen on and off time @@ -412,7 +413,7 @@ static int bd_get_and_print_misc_stat_entry_from_dump(int fd, long int duration) BM_CHECK_MEM_ALLOC(gbr_stat, {}); int ret = BATTERY_MONITOR_ERROR_NONE; - ret = bm_server_battery_dump_query_from_db(gbr_stat, 3, duration); + ret = bm_server_battery_dump_query_from_db(gbr_stat, 3, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gbr_stat); @@ -436,7 +437,7 @@ static int bd_get_and_print_misc_stat_entry_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_gn_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_gn_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; @@ -444,7 +445,7 @@ static int bd_get_and_print_gn_stat_entry_from_dump(int fd, long int duration) bd_gl_ntw_stat_s *gn_stat = (bd_gl_ntw_stat_s *)calloc(1, sizeof(bd_gl_ntw_stat_s)); BM_CHECK_MEM_ALLOC(gn_stat, {}); int ret = BATTERY_MONITOR_ERROR_NONE; - ret = bm_server_battery_dump_query_from_db(gn_stat, 2, duration); + ret = bm_server_battery_dump_query_from_db(gn_stat, 2, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gn_stat); @@ -470,7 +471,7 @@ static int bd_get_and_print_gn_stat_entry_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_gwf_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_gwf_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; // Dump Wifi Stats @@ -478,7 +479,7 @@ static int bd_get_and_print_gwf_stat_entry_from_dump(int fd, long int duration) BM_CHECK_MEM_ALLOC(gwfl_stat, {}); int ret = BATTERY_MONITOR_ERROR_NONE; - ret = bm_server_battery_dump_query_from_db(gwfl_stat, 1, duration); + ret = bm_server_battery_dump_query_from_db(gwfl_stat, 1, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gwfl_stat); @@ -515,7 +516,7 @@ static int bd_get_and_print_gwf_stat_entry_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_gble_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_gble_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; // Dump bt Data @@ -523,7 +524,7 @@ static int bd_get_and_print_gble_stat_entry_from_dump(int fd, long int duration) BM_CHECK_MEM_ALLOC(gble_stat, {}); int ret = BATTERY_MONITOR_ERROR_NONE; - ret = bm_server_battery_dump_query_from_db(gble_stat, 0, duration); + ret = bm_server_battery_dump_query_from_db(gble_stat, 0, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gble_stat); @@ -549,7 +550,7 @@ static int bd_get_and_print_gble_stat_entry_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_gst_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_gst_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; @@ -558,7 +559,7 @@ static int bd_get_and_print_gst_stat_entry_from_dump(int fd, long int duration) bd_gl_sgt_stat_s *gst_stat = (bd_gl_sgt_stat_s *)calloc(1, sizeof(bd_gl_sgt_stat_s)); BM_CHECK_MEM_ALLOC(gst_stat, {}); - ret = bm_server_battery_dump_query_from_db(gst_stat, 4, duration); + ret = bm_server_battery_dump_query_from_db(gst_stat, 4, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gst_stat); @@ -594,14 +595,14 @@ static int bd_get_and_print_gst_stat_entry_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_gwst_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_gwst_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; bd_gl_wst_stat_s *gwst_stat = (bd_gl_wst_stat_s *)calloc(1, sizeof(bd_gl_wst_stat_s)); BM_CHECK_MEM_ALLOC(gwst_stat, {}); int ret = BATTERY_MONITOR_ERROR_NONE; - ret = bm_server_battery_dump_query_from_db(gwst_stat, 5, duration); + ret = bm_server_battery_dump_query_from_db(gwst_stat, 5, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gwst_stat); @@ -626,17 +627,17 @@ static int bd_get_and_print_gwst_stat_entry_from_dump(int fd, long int duration) return ret; } -static int bd_get_and_print_gcpu_stat_entry_from_dump(int fd, long int duration) +static int bd_get_and_print_gcpu_stat_entry_from_dump(int fd, long int dstart_time) { ENTER; int ret = BATTERY_MONITOR_ERROR_NONE; const char *rid_str = NULL; int usage = 0; time_t crr_time = 0; time(&crr_time); - long int end_t = crr_time; + long int dend_time = crr_time; rid_str = bm_get_resource_id_string(2); resourceid_usage_s *res_use = - bm_server_query_resource_usage_resourceid_ci(rid_str, duration, end_t, &ret); + bm_server_query_resource_usage_resourceid_ci(rid_str, dstart_time, dend_time, &ret); if (res_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("For resourceid %s", rid_str); return ret; @@ -645,7 +646,7 @@ static int bd_get_and_print_gcpu_stat_entry_from_dump(int fd, long int duration) float usagemah = (float)usage/3600; bd_gl_cpu_stat_s *gcpu_stat = (bd_gl_cpu_stat_s *)calloc(1, sizeof(bd_gl_cpu_stat_s)); BM_CHECK_MEM_ALLOC(gcpu_stat, {BM_FREE(res_use); }); - ret = bm_server_battery_dump_query_from_db(gcpu_stat, 7, duration); + ret = bm_server_battery_dump_query_from_db(gcpu_stat, 7, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) { _ERR("Unable to fetch data from DB"); BM_FREE(gcpu_stat); @@ -685,8 +686,8 @@ static int bd_get_and_print_uid_info_entry_from_dump(int fd) GSList *iter = NULL; GString *dump_p = NULL; dump_p = g_string_sized_new(30); BM_CHECK_MEM_ALLOC(dump_p, {bm_set_free_gslist_appid_map(list); }); - g_string_append(dump_p, TIZEN_DUMP_VERSION); - g_string_append(dump_p, ",0,i,uid,1000,Tizen\n"); + g_string_append_printf(dump_p, "%s,0,i,uid,1000,Tizen\n", + TIZEN_DUMP_VERSION); if (write(fd, dump_p->str, dump_p->len) < 0) _WARN("write error"); g_string_free(dump_p, TRUE); @@ -694,25 +695,25 @@ static int bd_get_and_print_uid_info_entry_from_dump(int fd) for (iter = list; iter != NULL; iter = g_slist_next(iter)) { dump_p = g_string_sized_new(30); BM_CHECK_MEM_ALLOC(dump_p, {bm_set_free_gslist_appid_map(list); }); - g_string_append_printf(dump_p, "%s,0,i,uid,", - TIZEN_DUMP_VERSION); appid_map_s *amap_data = (appid_map_s *)iter->data; - g_string_append_printf(dump_p, "%d,", (amap_data->id+10000)); - gchar *temp_str = g_strdup(amap_data->AppId); - g_string_append(dump_p, amap_data->AppId); - g_string_append(dump_p, "\n"); + + g_string_append_printf(dump_p, "%s,0,i,uid,%d,%s\n", + TIZEN_DUMP_VERSION, (amap_data->id+10000), amap_data->AppId); + _DBG("%s", dump_p->str);//write if (write(fd, dump_p->str, dump_p->len) < 0) _WARN("write error"); g_string_free(dump_p, TRUE); + + char *temp_str = amap_data->AppId; int *temp_id = (int *)calloc(1, sizeof(int)); if (temp_id != NULL) { *temp_id = (amap_data->id + 10000); _DBG("Insert id %d, str %s, res %d", *temp_id, temp_str, - g_hash_table_insert(app_map, temp_id, temp_str)); + g_hash_table_insert(app_map, temp_id, g_strdup(temp_str))); } else { _WARN("Memory Allocation Failed"); - g_free(temp_str); + //g_free(temp_str); } } bm_set_free_gslist_appid_map(list); @@ -775,7 +776,6 @@ static int bd_get_history_detail_from_dump(int index, history_item_s* dump_node) if (dump_node->wakelock_tag == NULL) _DBG("Wakelock_Tag_NULL"); dump_node->wakereason_tag = history_data[index].wakereason_tag; - //:Not supported if (dump_node->wakereason_tag == NULL) _DBG("Wakereason_Tag_NULL"); @@ -873,12 +873,8 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo dump_p = g_string_sized_new(30); BM_CHECK_MEM_ALLOC(dump_p, {}); if (chkin) { - g_string_append(dump_p, TIZEN_DUMP_VERSION); - g_string_append_c(dump_p, ','); - _DBG("value %s", dump_p->str); - g_string_append(dump_p, DUMP_DATA_TAG); - g_string_append_c(dump_p, ','); - _DBG("value %s", dump_p->str); + g_string_append_printf(dump_p, "%s,%s,", TIZEN_DUMP_VERSION, + DUMP_DATA_TAG); if (old_state.time_s < 0) { g_string_append_printf(dump_p, "%lld", (new_state.time_s - base_time)); @@ -915,9 +911,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo g_string_append(dump_p, "TIME:"); _DBG("value %s", dump_p->str); if (chkin) { - g_string_append_printf(dump_p, "%lld", new_state.time_current); - _DBG("value %s", dump_p->str); - g_string_append(dump_p, "\n"); + g_string_append_printf(dump_p, "%lld\n", new_state.time_current); _DBG("value %s", dump_p->str); } else { //NC @@ -925,15 +919,11 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo } else if (new_state.cmd_s == CM_USAGE) { for (int i = 0; i < 32; i++) { if (new_state.usage_type == (1 << i)) { - g_string_append(dump_p, ","); - g_string_append_printf(dump_p, "%s", usage_map[i]); - g_string_append(dump_p, "="); - g_string_append_printf(dump_p, "%d", new_state.usage); - g_string_append(dump_p, ","); - g_string_append_printf(dump_p, "%lld", new_state.time_current); - g_string_append(dump_p, ","); - g_string_append_printf(dump_p, "%lld", (new_state.time_s - min_idle_check_time) / 1000); - g_string_append(dump_p, "\n"); + g_string_append_printf(dump_p, ",%s", usage_map[i]); + g_string_append_printf(dump_p, "=%d", new_state.usage); + g_string_append_printf(dump_p, ",%lld", new_state.time_current); + g_string_append_printf(dump_p, ",%lld\n", + (new_state.time_s - min_idle_check_time) / 1000); _DBG("value %d", new_state.usage); } } @@ -943,9 +933,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo } else { if (old_state.battery_level != new_state.battery_level) { old_state.battery_level = new_state.battery_level; - g_string_append(dump_p, ",Bl="); - _DBG("value %s", dump_p->str); - g_string_append_printf(dump_p, "%d", + g_string_append_printf(dump_p, ",Bl=%d", new_state.battery_level); _DBG("value %s", dump_p->str); } @@ -953,7 +941,6 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo if (old_state.battery_status != new_state.battery_status) { old_state.battery_status = new_state.battery_status; g_string_append(dump_p, ",Bs="); //:for NC - _DBG("value %s", dump_p->str); switch (old_state.battery_status) { case BD_BSTA_UNKN: g_string_append_c(dump_p, '?'); @@ -979,7 +966,6 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo if (old_state.battery_health != new_state.battery_health) { old_state.battery_health = new_state.battery_health; g_string_append(dump_p, ",Bh="); //:for NC - _DBG("value %s", dump_p->str); switch (old_state.battery_health) { case BD_BHLT_GOOD: g_string_append_c(dump_p, 'g'); @@ -1011,7 +997,6 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo if (old_state.battery_plugtype != new_state.battery_plugtype) { old_state.battery_plugtype = new_state.battery_plugtype; g_string_append(dump_p, ",Bp="); //:for NC - _DBG("value %s", dump_p->str); switch (old_state.battery_plugtype) { case BD_BPLT_DIS: g_string_append_c(dump_p, 'n'); @@ -1033,24 +1018,19 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo } if (old_state.battery_temperature != new_state.battery_temperature) { old_state.battery_temperature = new_state.battery_temperature; - g_string_append(dump_p, ",Bt="); //:for NC - g_string_append_printf(dump_p, "%d", + g_string_append_printf(dump_p, ",Bt=%d", new_state.battery_temperature); _DBG("value %s", dump_p->str); } if (old_state.battery_voltage != new_state.battery_voltage) { old_state.battery_voltage = new_state.battery_voltage; - g_string_append(dump_p, ",Bv="); //:for NC - _DBG("value %s", dump_p->str); - g_string_append_printf(dump_p, "%d", new_state.battery_voltage); + g_string_append_printf(dump_p, ",Bv=%d", new_state.battery_voltage); _DBG("value %s", dump_p->str); } if (old_state.battery_charge != new_state.battery_charge) { old_state.battery_charge = new_state.battery_charge; - g_string_append(dump_p, ",Bcc="); - _DBG("value %s", dump_p->str); //Charge in MAh - g_string_append_printf(dump_p, "%d", (new_state.battery_charge/1000)); + g_string_append_printf(dump_p, ",Bcc=%d", (new_state.battery_charge/1000)); _DBG("value %s", dump_p->str); } int change = (old_state.state_1 ^ new_state.state_1); @@ -1058,18 +1038,16 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo bool wake_fl = false; int k = 0; if ((change & ST1_BRIGHTNESS_MASK) != 0) { k = (new_state.state_1 & ST1_BRIGHTNESS_MASK); - g_string_append(dump_p, ",Sb="); k = k >> ST1_BRIGHTNESS_SHIFT; _DBG("Sb = %d", k); - g_string_append_printf(dump_p, "%d", k); + g_string_append_printf(dump_p, ",Sb=%d", k); k = 0; } if ((change & ST1_PHONE_SIGNAL_STRENGTH_MASK) != 0) { k = (new_state.state_1 & ST1_PHONE_SIGNAL_STRENGTH_MASK); - g_string_append(dump_p, ",Pss="); k = k >> ST1_PHONE_SIGNAL_STRENGTH_SHIFT; _DBG("Pss = %d", k); - g_string_append_printf(dump_p, "%d", k); + g_string_append_printf(dump_p, ",Pss=%d", k); k = 0; } int shifts = (1 << 14); @@ -1083,22 +1061,17 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo g_string_append_c(dump_p, '+'); else g_string_append_c(dump_p, '-'); - gchar *temp = g_strdup(state1_map[i]); - g_string_append(dump_p, temp); - g_free(temp); - //_DBG("value %s", dump_p->str); + g_string_append_printf(dump_p, "%s", state1_map[i]); if ((1 << i) == ST1_WAKE_LOCK_FLAG && new_state.wakelock_tag != NULL) { wake_fl = true; g_string_append_c(dump_p, '='); - //_DBG("value %s", dump_p->str); if (chkin) g_string_append_printf(dump_p, "%d", new_state.wakelock_tag->sp_idx); else { //: NC } - //_DBG("value %s", dump_p->str); } } else { //With non-negative shift @@ -1122,17 +1095,13 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo for (int i = 0; i < 32; i++) { if ((change & shifts) != 0) { g_string_append_c(dump_p, ','); - //_DBG("value %s", dump_p->str); int shift = -1; if (shift < 0) { if ((new_state.state_2 & (1 << i) & change) != 0) g_string_append_c(dump_p, '+'); else g_string_append_c(dump_p, '-'); - //_DBG("value %s", dump_p->str); - gchar *temp = g_strdup(state2_map[i]); - g_string_append(dump_p, temp); - g_free(temp); + g_string_append_printf(dump_p, "%s", state2_map[i]); _DBG("value %s", dump_p->str); } } @@ -1198,13 +1167,8 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo struct timeval tv; gettimeofday(&tv, NULL); - g_string_append(dump_tmp_p, TIZEN_DUMP_VERSION); - g_string_append_c(dump_tmp_p, ','); - g_string_append(dump_tmp_p, DUMP_DATA_TAG); - g_string_append_c(dump_tmp_p, ','); - g_string_append_printf(dump_tmp_p, "%lld", - ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000) - old_state.time_s); - g_string_append(dump_tmp_p, "\n"); + g_string_append_printf(dump_tmp_p, "%s,%s,%lld\n", TIZEN_DUMP_VERSION, DUMP_DATA_TAG, + ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000) - old_state.time_s); if (write(fd, dump_tmp_p->str, dump_tmp_p->len) < 0) _WARN("write error"); @@ -1215,36 +1179,36 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("UID data dump failed"); // Get Last charge time to dump "l" field - long int duration = 0; + long int dstart_time = 0; bd_get_last_charge_time(base_time/1000, &ret); - duration = lst_charge; + dstart_time = lst_charge; - ret = bd_get_and_print_gn_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_gn_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("GN dump failed"); - ret = bd_get_and_print_gwf_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_gwf_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("GWF data dump failed"); - ret = bd_get_and_print_gble_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_gble_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("GBL data dump failed"); - ret = bd_get_and_print_gbr_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_gbr_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("GBR data dump failed"); - ret = bd_get_and_print_gst_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_gst_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("GST data dump failed"); - ret = bd_get_and_print_gwst_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_gwst_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("GWST data dump failed"); - ret = bd_get_and_print_gcpu_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_gcpu_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("GCPU data dump failed"); - ret = bd_get_and_print_misc_stat_entry_from_dump(fd, duration); + ret = bd_get_and_print_misc_stat_entry_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("MISc data dump failed"); // Battery Usage Dump - ret = bd_get_and_print_battery_usage_from_dump(fd, duration); + ret = bd_get_and_print_battery_usage_from_dump(fd, dstart_time); if (ret != BATTERY_MONITOR_ERROR_NONE) _ERR("Battery Usage failed"); @@ -1465,7 +1429,7 @@ int bd_callback(const int fd, const int argc, char **argv) return -1; opt = argv[0][0]; - if (opt > 122 && opt < 97 && argv[0][1] != '\0') { + if (opt > 122 || opt < 97 || argv[0][1] != '\0') { _ERR("INVALID ARG"); return -1; } diff --git a/src/bm_server_db.c b/src/bm_server_db.c index 5b1686b..a3154e1 100644 --- a/src/bm_server_db.c +++ b/src/bm_server_db.c @@ -525,7 +525,6 @@ static void bm_convert_column_to_resourceid_usage(bm_stmt hstmt, resourceid_usag const char *textbuf = NULL; textbuf = bm_query_table_column_text(hstmt, BM_RESOURCEUSAGE_FIELD_RESID); bm_db_data_to_text(textbuf, &(bm_resource_type->ResourceId)); - _DBG("bm_resource_type->ResourceId =[%s]", bm_resource_type->ResourceId); bm_resource_type->log_time = -1; bm_resource_type->usage = bm_query_table_column_int(hstmt, BM_RESOURCEUSAGE_FIELD_USAGE); @@ -551,7 +550,6 @@ static void bm_convert_column_to_appid_usage(bm_stmt hstmt, appid_usage_s* bm_ap const char *textbuf = NULL; textbuf = bm_query_table_column_text(hstmt, BM_APPUSAGE_FIELD_APPID); bm_db_data_to_text(textbuf, &(bm_app_type->AppId)); - _DBG("bm_app_type->AppId =[%s]", bm_app_type->AppId); bm_app_type->log_time = -1; bm_app_type->rId_ble = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_BLE); bm_app_type->rId_wifi = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_WIFI); |