int battery_temperature;
int battery_voltage;
int battery_charge;//UAh
+ int usage_type;
+ int usage;
// SPool related fields
int event_code;
history_tag_s* event_tag;
int state_1;
int state_2;
int battery_chargeUAh;
+ int usage_type;
+ int usage;
int event_code;
history_tag_s* event_tag;
history_tag_s* wakelock_tag;
#define CM_RST 7
#define CM_SHTDN 8
#define CM_OVRFL 6 //:Used in NC
+#define CM_USAGE 9
// Functions for the other part of the service
int bd_initialize_battery_dump(void);
static const int ET_WAKEUP_AP = 0x0013;
static const int ET_LONG_WAKE_LOCK = 0x0014;
static const int ET_COUNT = 0x0016;
+
/*
static const int ET_TYPE_MASK = ~(ET_FLAG_START|ET_FLAG_FINISH);
static const int ET_PROC_START = ET_PROC | ET_FLAG_START;
static const int ET_LONG_WAKE_LOCK_FINISH = ET_LONG_WAKE_LOCK | ET_FLAG_FINISH;
*/
+static const int USAGE_BLUETOOTH = 1 << 0;
+static const int USAGE_WIFI = 1 << 1;
+
#ifdef __cplusplus
}
#endif
"", "Ud", "Chtp", "bles", "ca", "b", "Pcl", "ch", "", "", "fl", "W", "Ww", "v", "ps"};
char event_map[32][4] = {"Enl", "Epr", "Efg", "Etp", "Esy", "Ewl", "Ejb", "Eur", "Euf", "Ecn",
"Eac", "Epi", "Epu", "Eal", "Est", "Eai", "Eaa", "Etw", "Esw", "Ewa", "Elw", "Eec"};
+char usage_map[32][4] = {"Bu", "Wu", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
GHashTable *app_map = NULL;
static int bd_print_pool_entry(int fd, int idx, history_tag_s *pool_info)
dump_node->time_current = history_data[index].time_current;
_DBG("C TIME is %lld", dump_node->time_current);
+ dump_node->usage_type = history_data[index].usage_type;
+ _DBG("Usage type is %d", dump_node->usage_type);
+
+ dump_node->usage = history_data[index].usage;
+ _DBG("Usage is %d", dump_node->usage);
+
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
}
old_state->time_s = -1;
old_state->state_1 = 0;
old_state->state_2 = 0;
+ old_state->usage_type = 0;
+ old_state->usage = 0;
//TEMP: Change to 0;
old_state->battery_level = -1;
old_state->battery_status = -1;
old_state->battery_voltage = -1;
old_state->battery_charge = -1;
+ old_state->event_tag = NULL;
+ old_state->wakelock_tag = NULL;
+ old_state->wakereason_tag = NULL;
+
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
}
}
dump_p = g_string_append(dump_p, "*OVERFLOW*\n");
_DBG("value %s", dump_p->str);
+ } else if (new_state.cmd_s == CM_USAGE) {
+ for (int i = 0; i < 32; i++) {
+ if (new_state.usage_type == (1 << i)) {
+ dump_p = g_string_append(dump_p, ",");
+ g_string_append_printf(dump_p, "%s", usage_map[i]);
+ dump_p = g_string_append(dump_p, "=");
+ g_string_append_printf(dump_p, "%d", new_state.usage);
+ dump_p = g_string_append(dump_p, "\n");
+ _DBG("value %d", new_state.usage);
+ }
+ }
} else {
if (!chkin) {
//NC
history_data[h_count].state_1 = nrec->state_1;
history_data[h_count].state_2 = nrec->state_2;
+ history_data[h_count].usage_type = nrec->usage_type;
+ history_data[h_count].usage = nrec->usage;
+
if (h_count < HISTORY_SIZE_MAX)
h_count++;
else {
*
*/
+#include <sys/time.h>
+
#include <device/battery.h>
#include <device/callback.h>
#include "bm_private.h"
#include "bd_private.h"
#include "bm_util.h"
+#include "bd_history_item.h"
bm_feature_data_h bm_data_handle = NULL;
GHashTable *gl_hash = NULL;
/* Free the hash map */
g_hash_table_destroy(hash);
+ /* Dump resource usage */
+ _DBG("BLE usage : %d", RX + TX);
+ if (RX > 0 || TX > 0) {
+ history_item_s hi;
+ bd_print_history_item_reset(&hi);
+
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+
+ hi.time_s = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
+
+ hi.cmd_s = CM_USAGE;
+ hi.usage_type = USAGE_BLUETOOTH;
+ hi.usage = RX + TX;
+
+ bd_store_history_item(&hi);
+ }
+
EXIT;
return ret_val;
}
/* Free the Hash Map */
g_hash_table_destroy(hash);
+ /* Dump resource usage */
+ _DBG("Wi-Fi usage : %ld", RX + TX);
+ if (RX > 0 || TX > 0) {
+ history_item_s hi;
+ bd_print_history_item_reset(&hi);
+
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+
+ hi.time_s = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
+
+ hi.cmd_s = CM_USAGE;
+ hi.usage_type = USAGE_WIFI;
+ hi.usage = RX + TX;
+
+ bd_store_history_item(&hi);
+ }
+
EXIT;
return ret_val;
}