Battery information in Battery Dump 95/222595/1
authorDewal Agarwal <d1.agarwal@samsung.com>
Thu, 16 Jan 2020 10:10:05 +0000 (15:40 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Thu, 16 Jan 2020 10:10:05 +0000 (15:40 +0530)
Change-Id: Icc29202348efe4f1c291c765d2e9e67a713cb1fc
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
include/bd_private.h
include/bm_private.h
src/battery_dump/bd_history_item.c

index 7b2c690..20ddaba 100644 (file)
@@ -27,6 +27,7 @@ extern "C"
 {
 #endif
 
+/* Battery Dump db structures */
 typedef struct _gbl_ble_stat_s {
        long int time_s;
        long int ble_idle_time;
@@ -94,6 +95,17 @@ typedef struct _gbl_bst_stat_s {
        long int high_time;
 } bd_gl_bst_stat_s;
 
+typedef struct _unt_ntw_stat_s {
+       long int time_s;
+       char *appid;
+       long int dn_rx_byt;
+       long int dn_tx_byt;
+       long int wifi_rx_byt;
+       long int wifi_tx_byt;
+       long int app_rt;
+} bd_ul_ntw_stat_s;
+
+/* Battery Dump db enumerations */
 typedef enum {
        BD_GBLESTAT_NONE = -1,
        BD_GBLESTAT_IDLE,
@@ -143,8 +155,6 @@ typedef enum {
        BD_GSGTSTAT_GRT,
 } BD_GSGTSTAT_DB_IDX;
 
-// Check if separate enums are really reqiured for wst?
-
 typedef enum {
        BD_GBSTSTAT_NONE = -1,
        BD_GBSTSTAT_OFF,
@@ -153,6 +163,47 @@ typedef enum {
        BD_GBSTSTAT_HIGH,
 } BD_GBSTSTAT_DB_IDX;
 
+typedef enum {
+       BD_UNTWSTAT_NONE = -1,
+       BD_UNTWSTAT_APP,
+       BD_UNTWSTAT_DN_RXB,
+       BD_UNTWSTAT_DN_TXB,
+       BD_UNTWSTAT_WIFI_RXB,
+       BD_UNTWSTAT_WIFI_TXB,
+       BD_UNTWSTAT_RT,
+} BD_UNTWSTAT_DB_IDX;
+
+/* Battery Specific Enumeration */
+typedef enum {
+       BD_BSTA_NONE = -1,
+       BD_BSTA_INVD,
+       BD_BSTA_UNKN,
+       BD_BSTA_CHAR,
+       BD_BSTA_DISC,
+       BD_BSTA_NCHA,
+       BD_BSTA_FULL,
+} BD_BSTA_IDX; //B Status
+
+typedef enum {
+       BD_BHLT_NONE = -1,
+       BD_BHLT_INVD,
+       BD_BHLT_GOOD,
+       BD_BHLT_UNKN,
+       BD_BHLT_OVRH,
+       BD_BHLT_DEAD,
+       BD_BHLT_OVRV,
+       BD_BHLT_UNSP,
+       BD_BHLT_CLD,
+} BD_BHLT_IDX;//B Health
+
+typedef enum {
+       BD_BPLT_NONE = -1,
+       BD_BPLT_DIS,
+       BD_BPLT_AC,
+       BD_BPLT_USB,
+       BD_BPLT_WL,
+} BD_BPLT_IDX;//B PlugT
+
 #ifdef __cplusplus
 }
 #endif
index e6639d9..ad95b19 100644 (file)
@@ -21,9 +21,6 @@
 #define __BM_PRIVATE_H__
 
 #include <stdlib.h>
-#include <tizen.h>
-#include <glib.h>
-#include <system_info.h>
 
 #ifdef __cplusplus
 extern "C"
index 0dfcea7..7278ba2 100644 (file)
@@ -19,6 +19,7 @@
 #include <time.h>
 #include <glib/gprintf.h>
 #include <stdio.h>
+//#include <vconf.h>
 #include "bd_history_item.h"
 #include "bm_util.h"
 #include "bm_dbg.h"
@@ -28,6 +29,7 @@
 #include "bd_private.h"
 //#include "bm_power_engine.h"
 
+
 dump_data_s history_data[HISTORY_SIZE_MAX];
 int h_count = 0; int h_flag = false;
 char state1_map[32][4] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Wm",
@@ -199,8 +201,9 @@ static int bd_get_and_print_battery_usage_from_dump(long int duration)
                        _ERR("For appid %s", appid);
                        continue;
                }
-               usageMAh = (app_use->rId_ble + app_use->rId_wifi + app_use->rId_cpu + app_use->rId_display +
-                               app_use->rId_device_network + app_use->rId_gps + app_use->rId_hrm);
+               usageMAh = (app_use->rId_ble + app_use->rId_wifi + app_use->rId_cpu +
+                               app_use->rId_display + app_use->rId_device_network +
+                               app_use->rId_gps + app_use->rId_hrm);
                //ret = bm_engine_get_total_usage_by_app_id(appid, 1, &usage);
                usageMAh = (usageMAh/1000);
                dump_p = g_string_sized_new(30);
@@ -215,25 +218,45 @@ static int bd_get_and_print_battery_usage_from_dump(long int duration)
                g_free(dump_p->str);
        }
        // Resource usage;
-       const char *resource_id_str = NULL;
-       for (int i = 0; i < 5; i++) {
+       const char *rid_str = NULL;
+       for (int i = 0; i < 6; i++) {
                int usage = 0;
-               //ret = bm_engine_get_total_usage_by_resource_id(i, 1, &usage);i
-               resource_id_str = bm_get_resource_id_string(i);
-               if (g_strcmp0(resource_id_str, "UNKNOWN RESOURCE-ID") == 0) {
+               //ret = bm_engine_get_total_usage_by_resource_id(i, 1, &usage);
+               rid_str = bm_get_resource_id_string(i);
+               if (g_strcmp0(rid_str, "UNKNOWN RESOURCE-ID") == 0) {
                        _ERR("invalid resource-id");
                        return BATTERY_MONITOR_ERROR_INTERNAL;
                }
-               resourceid_usage_s *resource_usage = bm_server_query_resource_usage_resourceid(resource_id_str, 1, &ret);
-               usage = resource_usage->usage;
+               resourceid_usage_s *res_use =
+                       bm_server_query_resource_usage_resourceid(rid_str, 1, &ret);
+               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);
-               g_string_append_printf(dump_p, ",%d,l,pwi,%s,", *uid_n, resource_id_str);
+               switch (i) {
+               case 0://BT
+                       g_string_append(dump_p, ",0,l,pwi,blue,");
+                       break;
+               case 1://WIFI
+                       g_string_append(dump_p, ",0,l,pwi,wifi,");
+                       break;
+               case 2://CPU
+                       g_string_append(dump_p, ",0,l,pwi,phone,");
+                       break;
+               case 3://DISP
+                       g_string_append(dump_p, ",0,l,pwi,scrn,");
+                       break;
+               case 4://DEVICE NT
+                       g_string_append(dump_p, ",0,l,pwi,cell,");
+                       break;
+               default://GPS HRM
+                       g_string_append(dump_p, ",0,l,pwi,unacc,");
+                       break;
+               }
                g_string_append_printf(dump_p, "%0.2f", usageMAh);
                g_string_append(dump_p, "\n");
-               bm_resourceid_usage_free(resource_usage);
+               bm_resourceid_usage_free(res_use);
                _DBG("%s", dump_p->str);
                //fputs(dump_p->str, fp);//TEMP
                g_free(dump_p->str);
@@ -728,10 +751,23 @@ int bd_print_history_item_main(int num_h_items, long base_time, bool chkin)
                                dump_p = g_string_append(dump_p, ",Bs="); //:for NC
                                _DBG("value %s", dump_p->str);
                                switch (old_state.battery_status) {
-                                       //: write for substates
+                               case BD_BSTA_UNKN:
+                                       g_string_append_c(dump_p, '?');
+                                       break;
+                               case BD_BSTA_CHAR:
+                                       g_string_append_c(dump_p, 'c');
+                                       break;
+                               case BD_BSTA_DISC:
+                                       g_string_append_c(dump_p, 'd');
+                                       break;
+                               case BD_BSTA_NCHA:
+                                       g_string_append_c(dump_p, 'n');
+                                       break;
+                               case BD_BSTA_FULL:
+                                       g_string_append_c(dump_p, 'f');
+                                       break;
                                default:
-                                       g_string_append_printf(dump_p, "%d",
-                                                       new_state.battery_status);
+                                       g_string_append_c(dump_p, '?');
                                        _DBG("value %s", dump_p->str);
                                        break;
                                }
@@ -741,10 +777,29 @@ int bd_print_history_item_main(int num_h_items, long base_time, bool chkin)
                                dump_p = g_string_append(dump_p, ",Bh="); //:for NC
                                _DBG("value %s", dump_p->str);
                                switch (old_state.battery_health) {
-                                       //: write for substates
+                               case BD_BHLT_GOOD:
+                                       g_string_append_c(dump_p, 'g');
+                                       break;
+                               case BD_BHLT_UNKN:
+                                       g_string_append_c(dump_p, '?');
+                                       break;
+                               case BD_BHLT_OVRH:
+                                       g_string_append_c(dump_p, 'h');
+                                       break;
+                               case BD_BHLT_DEAD:
+                                       g_string_append_c(dump_p, 'd');
+                                       break;
+                               case BD_BHLT_OVRV:
+                                       g_string_append_c(dump_p, 'v');
+                                       break;
+                               case BD_BHLT_UNSP:
+                                       g_string_append_c(dump_p, 'f');
+                                       break;
+                               case BD_BHLT_CLD:
+                                       g_string_append_c(dump_p, 'c');
+                                       break;
                                default:
-                                       g_string_append_printf(dump_p, "%d",
-                                                       new_state.battery_health);
+                                       g_string_append_c(dump_p, '?');
                                        _DBG("value %s", dump_p->str);
                                        break;
                                }
@@ -754,10 +809,20 @@ int bd_print_history_item_main(int num_h_items, long base_time, bool chkin)
                                dump_p = g_string_append(dump_p, ",Bp="); //:for NC
                                _DBG("value %s", dump_p->str);
                                switch (old_state.battery_plugtype) {
-                                       //: write for substates
+                               case BD_BPLT_DIS:
+                                       g_string_append_c(dump_p, 'n');
+                                       break;
+                               case BD_BPLT_AC:
+                                       g_string_append_c(dump_p, 'a');
+                                       break;
+                               case BD_BPLT_USB:
+                                       g_string_append_c(dump_p, 'u');
+                                       break;
+                               case BD_BPLT_WL:
+                                       g_string_append_c(dump_p, 'w');
+                                       break;
                                default:
-                                       g_string_append_printf(dump_p, "%d",
-                                               new_state.battery_plugtype);
+                                       g_string_append_c(dump_p, 'n');
                                        _DBG("value %s", dump_p->str);
                                        break;
                                }
@@ -765,15 +830,9 @@ int bd_print_history_item_main(int num_h_items, long base_time, bool chkin)
                        if (old_state.battery_temperature != new_state.battery_temperature) {
                                old_state.battery_temperature = new_state.battery_temperature;
                                dump_p = g_string_append(dump_p, ",Bt="); //:for NC
+                               g_string_append_printf(dump_p, "%d",
+                                               new_state.battery_temperature);
                                _DBG("value %s", dump_p->str);
-                               switch (old_state.battery_temperature) {
-                                       //: write for substates
-                               default:
-                                       g_string_append_printf(dump_p, "%d",
-                                                       new_state.battery_temperature);
-                                       _DBG("value %s", dump_p->str);
-                                       break;
-                               }
                        }
                        if (old_state.battery_voltage != new_state.battery_voltage) {
                                old_state.battery_voltage = new_state.battery_voltage;
@@ -801,21 +860,21 @@ int bd_print_history_item_main(int num_h_items, long base_time, bool chkin)
                                                int shift = -1;
                                                if (shift < 0) {
                                                        if ((new_state.state_1 & (1 << i)) != 0)
-                                                               dump_p = g_string_append_c(dump_p, '+');
+                                                               g_string_append_c(dump_p, '+');
                                                        else
-                                                               dump_p = g_string_append_c(dump_p, '-');
+                                                               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);
                                                        if ((1 << i) == ST1_WAKE_LOCK_FLAG &&
-                                                                       new_state.wakelock_tag != NULL) {
+                                                               new_state.wakelock_tag != NULL) {
                                                                wake_fl = true;
-                                                               dump_p = g_string_append_c(dump_p, '=');
+                                                               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);
+                                                                       g_string_append_printf(dump_p,
+                                                               "%d", new_state.wakelock_tag->sp_idx);
                                                                else{
                                                                        //: NC
                                                                }
@@ -847,9 +906,9 @@ int bd_print_history_item_main(int num_h_items, long base_time, bool chkin)
                                                int shift = -1;
                                                if (shift < 0) {
                                                        if ((new_state.state_2 & (1 << i) & change) != 0)
-                                                               dump_p = g_string_append_c(dump_p, '+');
+                                                               g_string_append_c(dump_p, '+');
                                                        else
-                                                               dump_p = g_string_append_c(dump_p, '-');
+                                                               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);