char usage_map[32][4] = {"Bu", "Wu", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
GHashTable *app_map = NULL;
+static long int lst_charge = -1;
static int bd_print_pool_entry(int fd, int idx, history_tag_s *pool_info)
{
GHashTableIter iter;
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;
float usageMAh = 0; int battery_capacity = 500;//default
ret = bm_get_battery_power_params(&battery_capacity);
_DBG("%d %s", *uid_n, appid); usageMAh = 0;
// Currently giving app usage of last one week;
// Modify it wrt to time
- appid_usage_s *app_use = bm_server_query_app_usage_by_appid(appid, 1, &ret);
+ appid_usage_s *app_use = bm_server_query_app_usage_by_appid_ci(appid, duration, end_t, &ret);
if (app_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) {
_ERR("For appid %s", appid);
continue;
return BATTERY_MONITOR_ERROR_INTERNAL;
}
resourceid_usage_s *res_use =
- bm_server_query_resource_usage_resourceid(rid_str, 1, &ret);
+ bm_server_query_resource_usage_resourceid_ci(rid_str, duration, end_t, &ret);
if (res_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) {
_ERR("For resourceid %s", rid_str);
continue;
g_string_append_printf(dump_p, "%ld,", on_time);
g_string_append_printf(dump_p, "%ld", off_time);
g_string_append(dump_p, "\n");
+/*
_DBG("%s", dump_p->str);
if (write(fd, dump_p->str, dump_p->len) < 0)
- _WARN("write error");
+ _WARN("write error");*/
g_string_free(dump_p, TRUE);
BM_FREE(gbr_stat);
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;
rid_str = bm_get_resource_id_string(2);
resourceid_usage_s *res_use =
- bm_server_query_resource_usage_resourceid(rid_str, 1, &ret);
+ bm_server_query_resource_usage_resourceid_ci(rid_str, duration, end_t, &ret);
if (res_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) {
_ERR("For resourceid %s", rid_str);
return ret;
dump_node->event_tag = history_data[index].event_tag;
if (dump_node->event_tag == NULL)
_DBG("Event_Tag_NULL");
- else//Remove
- _DBG("%d %d %s", dump_node->event_tag->uid, dump_node->event_tag->sp_idx,
- dump_node->event_tag->string_info->str);
dump_node->wakelock_tag = history_data[index].wakelock_tag;
if (dump_node->wakelock_tag == NULL)
_DBG("Wakelock_Tag_NULL");
if (ret != BATTERY_MONITOR_ERROR_NONE)
_ERR("UID data dump failed");
// Get Last charge time to dump "l" field
- // for the time being dumping all data
- long int duration = 0; //Time of last charge
+ long int duration = 0;
+ if (lst_charge < 0)
+ duration = base_time/1000;
+ else
+ duration = lst_charge;
+
ret = bd_get_and_print_gn_stat_entry_from_dump(fd, duration);
if (ret != BATTERY_MONITOR_ERROR_NONE)
_ERR("GN dump failed");
if (ret != BATTERY_MONITOR_ERROR_NONE)
_ERR("MISc data dump failed");
// Battery Usage Dump
- // Add usage for each of the resource
- // and each of the application
ret = bd_get_and_print_battery_usage_from_dump(fd, duration);
if (ret != BATTERY_MONITOR_ERROR_NONE)
_ERR("Battery Usage failed");
history_data[h_count].time_s = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
#endif
+ if (nrec->battery_plugtype > BD_BPLT_DIS)
+ lst_charge = tv.tv_sec;
+
dvar1 = ((nrec->cmd_s) & 0xff) | ((nrec->battery_level << 8) & 0xff00) |
((nrec->battery_status << 16) & 0xf0000) |
((nrec->battery_health << 20) & 0xf00000) |