GHashTable *app_map = NULL;
static long int lst_charge = -1;
+static long long min_idle_check_time;
+
static int bd_print_pool_entry(int fd, int idx, int pc, history_tag_s *pool_info)
{
ENTER;
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");
_DBG("value %d", new_state.usage);
}
}
if (nrec->cmd_s == CM_CRR_TIME || nrec->cmd_s == CM_RST)
history_data[h_count].time_current = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
+ else if (nrec->cmd_s == CM_USAGE)
+ history_data[h_count].time_current = nrec->time_current;
history_data[h_count].state_1 = nrec->state_1;
history_data[h_count].state_2 = nrec->state_2;
return 0;
}
+void bd_get_idle_check_time()
+{
+ ENTER;
+
+ int ret;
+ int not_used_int;
+ int data_collection_try_period;
+ int data_collection_accept_count;
+
+ ret = bm_get_job_scheduler_params(¬_used_int, &data_collection_try_period, &data_collection_accept_count, ¬_used_int);
+ if (ret != BATTERY_MONITOR_ERROR_NONE) {
+ min_idle_check_time = 0;
+ return;
+ }
+
+ min_idle_check_time = (long long)data_collection_try_period * data_collection_accept_count;
+
+ EXIT;
+ return;
+}
+
int bd_initialize_battery_dump()
{
ENTER;
return BATTERY_MONITOR_ERROR_NOT_INITIALIZED;
}
+ bd_get_idle_check_time();
+
_INFO("Battery Dump Init Successful");
EXIT;
int gtimeo_id[2];
static int data_collection_period = 600000;
+static struct timeval last_plugin_request_time;
+static struct timeval cur_plugin_request_time;
+
+void bm_update_plugin_request_time(void)
+{
+ ENTER;
+
+ if (!memcpy(&last_plugin_request_time, &cur_plugin_request_time, sizeof(struct timeval))) {
+ _ERR("memcpy failed");
+ return;
+ }
+
+ if (gettimeofday(&cur_plugin_request_time, NULL) != 0) {
+ _ERR("gettimeofday failed : %m");
+ return;
+ }
+
+ EXIT;
+ return;
+}
+
int bm_engine_get_mah_usage_by_app_id_for_resource_id_ci(const gchar* app_id, gint resource_id, gint64 start_time, gint64 end_time, double *battery_usage)
{
ENTER;
history_item_s hi;
bd_print_history_item_reset(&hi);
+ hi.time_current = (long long)last_plugin_request_time.tv_sec;
+
hi.cmd_s = CM_USAGE;
hi.usage_type = USAGE_BLUETOOTH;
hi.usage = (RX_system + TX_system + RX_app + TX_app) / ((double)data_collection_period / 60000); // bytes / minute
history_item_s hi;
bd_print_history_item_reset(&hi);
+ hi.time_current = (long long)last_plugin_request_time.tv_sec;
+
hi.cmd_s = CM_USAGE;
hi.usage_type = USAGE_WIFI;
hi.usage = (RX + TX) / ((double)data_collection_period / 60000); // bytes / minute
}
}
+ bm_update_plugin_request_time();
+
/* request data from each plugin & store its handle */
#ifdef DISABLE_FEATURE_DATA_FROM_GPS_HRM_PLUGIN
for (id = BM_PLUGIN_ID_BLE; id < BM_PLUGIN_ID_MAX; ++id) {
_ERR("unable ro read battery capacity");
battery_capacity *= cmah; //Battery Capacity in mAs
+ bm_update_plugin_request_time();
+
EXIT;
return ret_val;
}