// Functions for the other part of the service
int bd_initialize_battery_dump(void);
int bd_deinitialize_battery_dump(void);
-int bd_print_history_item_main(int fd, int num_h_items, long base_time, bool chkin);
+int bd_print_history_item_main(int fd, int num_h_items, long long base_time, bool chkin);
int bd_store_history_item(history_item_s* nrec);
int bd_print_history_item_reset(history_item_s* old_state);
//ret = bm_engine_get_total_usage_by_app_id(appid, 1, &usage);
usageMAh = (usageMAh/1000);
dump_p = g_string_sized_new(30);
- BM_CHECK_MEM_ALLOC(dump_p, {});
+ BM_CHECK_MEM_ALLOC(dump_p, { BM_FREE(app_use); });
g_string_append(dump_p, TIZEN_DUMP_VERSION);
g_string_append_printf(dump_p, ",%d,l,pwi,uid,", *uid_n);
g_string_append_printf(dump_p, "%0.2f", usageMAh);
}
resourceid_usage_s *res_use =
bm_server_query_resource_usage_resourceid(rid_str, 1, &ret);
+ if (res_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("For resourceid %s", rid_str);
+ continue;
+ }
+ dump_p = g_string_sized_new(30);
+ BM_CHECK_MEM_ALLOC(dump_p, {BM_FREE(res_use); });
usage = res_use->usage;
usageMAh = (float)usage/1000;
- dump_p = g_string_sized_new(30);
- BM_CHECK_MEM_ALLOC(dump_p, {});
g_string_append(dump_p, TIZEN_DUMP_VERSION);
switch (i) {
case 0://BT
return BATTERY_MONITOR_ERROR_NONE;
}
-int bd_print_history_item_main(int fd, int num_h_items, long base_time, bool chkin)
+int bd_print_history_item_main(int fd, int num_h_items, long long base_time, bool chkin)
{
ENTER;
time_t current_time = tv.tv_sec;
-// history_data[h_count].time_s = current_time;// comment for testing with test fn
+
+#ifdef DUMP_DUMMY
history_data[h_count].time_s = nrec->time_s;
+#else
+ history_data[h_count].time_s = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
+#endif
dvar1 = ((nrec->cmd_s) & 0xff) | ((nrec->battery_level << 8) & 0xff00) |
((nrec->battery_status << 16) & 0xf0000) |
if (nrec->wakereason_tag != NULL)
history_data[h_count].wakereason_tag = nrec->wakereason_tag;
if (nrec->event_code != ET_NONE) {
- _DBG("HI");
if (nrec->event_tag == NULL)
_ERR("IT is NULL");
history_data[h_count].event_code = nrec->event_code;
history_data[h_count].usage_type = nrec->usage_type;
history_data[h_count].usage = nrec->usage;
- if (h_count < HISTORY_SIZE_MAX)
+ if (h_count < HISTORY_SIZE_MAX - 1)
h_count++;
else {
- //: Give some buffer
// FIXME modify 1st argument (fd)
int ret = bd_print_history_item_main(-1, 0, current_time, 1);
- if (ret != BATTERY_MONITOR_ERROR_NONE)
+ if (ret != BATTERY_MONITOR_ERROR_NONE) {
+ h_count = 0;
return ret;
+ }
h_count = 0;
}
ts->event_tag->sp_idx = pool_idx_map_s2[mask];
} else {
ts->event_tag->sp_idx = pool_idx_map_s2[mask];
- pool_idx_map_s1[mask] = -1;
+ pool_idx_map_s2[mask] = -1;
}
} else
ts->event_tag->sp_idx = pool_idx++;
- if (on)
- temp = g_string_append(temp, "tizen");
- else
- temp = g_string_append(temp, "tizen");
+ _DBG("Value of ON is %d:" on);
+ temp = g_string_append(temp, "tizen");
ts->event_tag->string_info = temp;
_DBG("%s", ts->event_tag->string_info->str);
}
GString *temp = ts->wakelock_tag->string_info;
temp = g_string_sized_new(30);
BM_CHECK_MEM_ALLOC(temp, {});
- ts->wakelock_tag->uid = 0;
+ ts->wakelock_tag->uid = 1000;
if (state == 1) {
if (pool_idx_map_s1[mask] == -1) {
pool_idx_map_s1[mask] = pool_idx++;
} else
ts->wakelock_tag->sp_idx = pool_idx++;
- if (on)
- temp = g_string_append(temp, "tizen");
- else
- temp = g_string_append(temp, "tizen");
+ _DBG("Value of ON is %d:" on);
+ temp = g_string_append(temp, "tizen");
ts->wakelock_tag->string_info = temp;
_DBG("%s", ts->wakelock_tag->string_info->str);
}