summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrohit <rohit1.kr@samsung.com>2021-01-22 13:52:34 +0530
committerrohit <rohit1.kr@samsung.com>2021-01-29 17:53:22 +0530
commit0dce9218540653daa40c1fe309b20300e7d4e8df (patch)
tree3a3d7bc3b97f1c341b17b57bb90ab97193b50bfe
parentf695775760af943c343019c086bfef557edfe270 (diff)
downloadbatterymonitor-0dce9218540653daa40c1fe309b20300e7d4e8df.tar.gz
batterymonitor-0dce9218540653daa40c1fe309b20300e7d4e8df.tar.bz2
batterymonitor-0dce9218540653daa40c1fe309b20300e7d4e8df.zip
[Non-ACR] GPS Plugin Power Consumption Calculation
Change-Id: I9740481aae81005b8f79de295bc0cb63e88b539a
-rwxr-xr-x[-rw-r--r--]config/bm_params.json0
-rwxr-xr-x[-rw-r--r--]config/bm_power_profile_params_TW3.json3
-rwxr-xr-x[-rw-r--r--]config/bm_power_profile_params_dummy.json3
-rwxr-xr-x[-rw-r--r--]include/bm_common.h0
-rwxr-xr-x[-rw-r--r--]include/bm_config_parser.h6
-rw-r--r--include/bm_listeners.h14
-rwxr-xr-x[-rw-r--r--]include/bm_plugin_interface.h1
-rwxr-xr-x[-rw-r--r--]include/bm_power_engine.h6
-rwxr-xr-x[-rw-r--r--]include/bm_private.h2
-rwxr-xr-x[-rw-r--r--]include/bm_util.h4
-rw-r--r--packaging/batterymonitor.service1
-rw-r--r--packaging/batterymonitor.spec2
-rw-r--r--src/battery_dump/bd_history_item.c83
-rw-r--r--src/battery_dump/bm_listeners.c421
-rwxr-xr-x[-rw-r--r--]src/bm_callback_handler.c4
-rwxr-xr-x[-rw-r--r--]src/bm_config_parser.c12
-rwxr-xr-x[-rw-r--r--]src/bm_plugin_manager.c26
-rwxr-xr-x[-rw-r--r--]src/bm_power_engine.c80
-rwxr-xr-x[-rw-r--r--]src/bm_server_db.c9
-rwxr-xr-x[-rw-r--r--]src/bm_util.c103
20 files changed, 520 insertions, 260 deletions
diff --git a/config/bm_params.json b/config/bm_params.json
index 37bdc5c..37bdc5c 100644..100755
--- a/config/bm_params.json
+++ b/config/bm_params.json
diff --git a/config/bm_power_profile_params_TW3.json b/config/bm_power_profile_params_TW3.json
index c3e1db7..d8786b2 100644..100755
--- a/config/bm_power_profile_params_TW3.json
+++ b/config/bm_power_profile_params_TW3.json
@@ -34,7 +34,8 @@
"p_dp_low": 10.31
},
"gps_sensor": {
- "p_gps_inuse": 0.0
+ "p_gps_inuse": 23.315,
+ "p_gps_insearching": 23.115
},
"cpu": {
"p_cpu_user": 22.36,
diff --git a/config/bm_power_profile_params_dummy.json b/config/bm_power_profile_params_dummy.json
index c3e1db7..d8786b2 100644..100755
--- a/config/bm_power_profile_params_dummy.json
+++ b/config/bm_power_profile_params_dummy.json
@@ -34,7 +34,8 @@
"p_dp_low": 10.31
},
"gps_sensor": {
- "p_gps_inuse": 0.0
+ "p_gps_inuse": 23.315,
+ "p_gps_insearching": 23.115
},
"cpu": {
"p_cpu_user": 22.36,
diff --git a/include/bm_common.h b/include/bm_common.h
index 33140eb..33140eb 100644..100755
--- a/include/bm_common.h
+++ b/include/bm_common.h
diff --git a/include/bm_config_parser.h b/include/bm_config_parser.h
index 88b233e..5b7f392 100644..100755
--- a/include/bm_config_parser.h
+++ b/include/bm_config_parser.h
@@ -39,9 +39,9 @@ int bm_get_device_network_power_params(double *signal_strength0, double *signal_
int bm_get_display_power_params(double *high, double *medium, double *low);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
-int bm_get_gps_sensor_power_params(double *gps_use);
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
+
+int bm_get_gps_sensor_power_params(double *gps_use, double *gps_searching);
+
int bm_get_cpu_power_params(double *fg, double *bg);
diff --git a/include/bm_listeners.h b/include/bm_listeners.h
index 25ecf64..9149aa9 100644
--- a/include/bm_listeners.h
+++ b/include/bm_listeners.h
@@ -15,9 +15,6 @@
*
*/
-
-
-
#include <wifi-manager.h>
#include <bluetooth.h>
#include <device/callback.h>
@@ -25,11 +22,10 @@
#include <device/display.h>
#include <pthread.h>
-#include "bm_dbg.h"
#include "bm_plugin_interface.h"
#include "bd_private.h"
-#define BATTERY_INFO_DELAY 1
+#define BATTERY_INFO_DELAY 1000
#define MAX_BUFF 1
#define LISTEN_BT_STATE 0
#define LISTEN_BT_CONNECTION_STATE 1
@@ -68,14 +64,10 @@ int bd_initialize_listeners(void);
int bd_deinitialize_listeners();
+int bm_reset_event_listener(int to_enable);
+
typedef struct _event_pool {
int type;
int val;
char *app;
} event_pool;
-
-
-
-
-
-
diff --git a/include/bm_plugin_interface.h b/include/bm_plugin_interface.h
index 5fa2065..bc6f8b6 100644..100755
--- a/include/bm_plugin_interface.h
+++ b/include/bm_plugin_interface.h
@@ -166,6 +166,7 @@ typedef struct {
typedef struct {
time_t connStartTime; /**< start time of feature data collection session */
time_t connStopTime; /**< stop time of feature data collection session */
+ uint searchingTime; /**< time elapsed in search operation */
GSList *atm_list; /**< application time map('app_time_map_st1') list for all active applications between start & stop */
GSList *gps_data_list; /**< list of nodes of 'bm_gps_st' for next consecutive sessions */
} bm_gps_st;
diff --git a/include/bm_power_engine.h b/include/bm_power_engine.h
index d274d3b..5c4791d 100644..100755
--- a/include/bm_power_engine.h
+++ b/include/bm_power_engine.h
@@ -42,9 +42,7 @@ struct bm_feature_data_handles_s {
bm_cpu_st *bm_cpu_handle;
bm_display_st *bm_display_handle;
bm_device_network_st *bm_dn_handle;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
bm_gps_st *bm_gps_handle;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
};
typedef struct bm_feature_data_handles_s *bm_feature_data_h; /**< handle for feature data handle structure */
@@ -55,9 +53,7 @@ struct bm_req_feature_data_handle_flag_s {
bool req_cpu_data;
bool req_dp_data;
bool req_dn_data;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
bool req_gps_data;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
};
void bm_engine_set_req_flag_handle(bm_plugin_id_e req_plugin_id, bool value);
@@ -82,9 +78,7 @@ int bm_display_calc_power_and_commit(bm_display_st *handle, bool mode);
int bm_device_network_calc_power_and_commit(bm_device_network_st *handle, bool mode);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
int bm_gps_calc_power_and_commit(bm_gps_st *handle);
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
int bm_battery_calc_power_and_commit(void);
diff --git a/include/bm_private.h b/include/bm_private.h
index 3cf421f..af86afa 100644..100755
--- a/include/bm_private.h
+++ b/include/bm_private.h
@@ -69,10 +69,8 @@ typedef enum {
BM_APPUSAGE_FIELD_RID_CPU,
BM_APPUSAGE_FIELD_RID_DISPLAY,
BM_APPUSAGE_FIELD_RID_DEV_NTW,
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
BM_APPUSAGE_FIELD_RID_GPS,
BM_APPUSAGE_FIELD_RID_BATTERY,
-#endif
BM_APPUSAGE_FIELD_END,
} BM_APPUSAGE_DB_IDX;
diff --git a/include/bm_util.h b/include/bm_util.h
index dd88ea6..dd7ee04 100644..100755
--- a/include/bm_util.h
+++ b/include/bm_util.h
@@ -55,6 +55,8 @@ GVariant* bm_marshal_serialized_data(const bm_total_consumption_h data);
const char *bm_get_resource_id_string(gint resource_id);
+void bm_get_name_for_pid(pid_t pid, char **pname);
+
int bm_set_dbus_connection_obj(GDBusConnection* conn);
GDBusConnection* bm_get_dbus_connection_obj(void);
@@ -87,9 +89,7 @@ void bm_set_free_display_data_handle(bm_display_st **display_handle);
void bm_set_free_device_network_data_handle(bm_device_network_st **dn_handle);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
void bm_set_free_gps_sensor_data_handle(bm_gps_st **gps_handle);
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
void bm_set_free_data_handles(bm_feature_data_h* data_h);
diff --git a/packaging/batterymonitor.service b/packaging/batterymonitor.service
index 9171950..c0dfd91 100644
--- a/packaging/batterymonitor.service
+++ b/packaging/batterymonitor.service
@@ -10,6 +10,7 @@ Type=dbus
SmackProcessLabel=System
BusName=org.tizen.battery.monitor
ExecStart=/usr/bin/batterymonitor-svcd
+MemoryMax=50M
Restart=always
RestartSec=0
KillSignal=SIGUSR1
diff --git a/packaging/batterymonitor.spec b/packaging/batterymonitor.spec
index db91a14..047e2ea 100644
--- a/packaging/batterymonitor.spec
+++ b/packaging/batterymonitor.spec
@@ -1,6 +1,6 @@
Name: batterymonitor
Summary: batterymonitor service daemon
-Version: 0.0.6
+Version: 0.0.7
Release: 1
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
diff --git a/src/battery_dump/bd_history_item.c b/src/battery_dump/bd_history_item.c
index 37dd684..71ca87b 100644
--- a/src/battery_dump/bd_history_item.c
+++ b/src/battery_dump/bd_history_item.c
@@ -30,6 +30,7 @@
#include "bm_private.h"
#include "bd_private.h"
#include "bm_config_parser.h"
+#include "bm_listeners.h"
//#define DUMP_DUMMY 1
#ifdef DUMP_DUMMY
@@ -38,6 +39,7 @@
static dump_data_s history_data[HISTORY_SIZE_MAX];
static int front = -1, end = -1, h_flag = false;
+static int prev_wake_state = 0;
/*Bit and string map*/
static char state1_map[32][4] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Wm",
@@ -186,7 +188,7 @@ static int bd_get_pool_entry_from_dump(int fd)
if (index_s > index_e)
index_e = HISTORY_SIZE_MAX + index_e;
- for (int k = index_s; k < index_e; k++) {
+ for (int k = index_s; k <= index_e && k >= 0; k++) {
i = k % HISTORY_SIZE_MAX;
history_tag_s *pool_info = NULL;
if (history_data[i].event_tag != NULL && (history_data[i].event_code & ET_FLAG_START)) {
@@ -195,7 +197,8 @@ static int bd_get_pool_entry_from_dump(int fd)
if (ret != BATTERY_MONITOR_ERROR_NONE)
return BATTERY_MONITOR_ERROR_INTERNAL;
}
- if (history_data[i].wakelock_tag != NULL) {
+ /* In case of disabled wake history */
+ if (history_data[i].wakelock_tag != NULL && prev_wake_state == 0) {
pool_info = history_data[i].wakelock_tag;
ret = bd_print_pool_entry(fd, i, pool_info);
if (ret != BATTERY_MONITOR_ERROR_NONE)
@@ -839,6 +842,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
}
int ret = BATTERY_MONITOR_ERROR_NONE;
+ h_flag = false;
history_item_s new_state;
history_item_s old_state;
@@ -863,7 +867,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
if (index_s > index_e)
index_e = HISTORY_SIZE_MAX + index_e;
- for (int k = index_s; k < index_e; k++) {
+ for (int k = index_s; k <= index_e && k >= 0; k++) {
i = k % HISTORY_SIZE_MAX;
ret = bd_get_history_detail_from_dump(i, &new_state);
if (ret != BATTERY_MONITOR_ERROR_NONE) {
@@ -876,9 +880,12 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
g_string_append_printf(dump_p, "%s,%s,", TIZEN_DUMP_VERSION,
DUMP_DATA_TAG);
if (old_state.time_s < 0) {
+ /*
g_string_append_printf(dump_p, "%lld",
(new_state.time_s - base_time));
_DBG("value %s", dump_p->str);
+ */
+ g_string_append(dump_p, "0");
} else {
g_string_append_printf(dump_p, "%lld",
(new_state.time_s - old_state.time_s));
@@ -1215,6 +1222,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
_DBG("DUMP COMPLETED/DELETE HASH TABLE");
g_hash_table_destroy(app_map);
+ h_flag = true;
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
@@ -1327,7 +1335,7 @@ static int bd_set_history_from_listener(history_item_s* nrec)
return BATTERY_MONITOR_ERROR_NONE;
}
-static int bd_reset_history()
+static int bd_reset_history(int to_enable)
{
ENTER;
int ret = BATTERY_MONITOR_ERROR_NONE;
@@ -1354,6 +1362,9 @@ static int bd_reset_history()
/* Call Battery Listener Reset Function from here
* Add listener reset call
* */
+ ret = bm_reset_event_listener(to_enable);
+ if (ret != BATTERY_MONITOR_ERROR_NONE)
+ _ERR("Listener Reset Fails");
EXIT;
return ret;
@@ -1412,6 +1423,7 @@ int bd_callback(const int fd, const int argc, char **argv)
int ret;
char opt = '\0';
bool checkin = false;
+ int to_enable = 0;
if (argc < 0) {
_ERR("Input Error From Dumpsys Callback");
@@ -1425,16 +1437,22 @@ int bd_callback(const int fd, const int argc, char **argv)
return -1;
}
} else {
+ _DBG("%d", argc);
if (argv[0] == NULL)
return -1;
opt = argv[0][0];
- if (opt > 122 || opt < 97 || argv[0][1] != '\0') {
+ if (opt > 122 || opt < 97) {
_ERR("INVALID ARG");
return -1;
}
switch (opt) {
case 'c':
+ if (strncmp(argv[0], "checkin", strlen("checkin")) != 0) {
+ _ERR("Unsupported Option");
+ return -1;
+ }
+
_WARN("Case %s", argv[0]);
checkin = true;
ret = bd_print_history_item_main(fd, -1, 0, checkin);
@@ -1444,8 +1462,59 @@ int bd_callback(const int fd, const int argc, char **argv)
}
break;
case 'r':
+ if (strncmp(argv[0], "reset", strlen("reset")) != 0) {
+ _ERR("Unsupported Option");
+ return -1;
+ }
+
+ to_enable = 0;
+ _WARN("Case %s", argv[0]);
+ ret = bd_reset_history(to_enable);
+ if (ret != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("bd_reset_history failed (%x)", ret);
+ return -1;
+ }
+ break;
+ case 'e':
+ if (argc != 2 || strncmp(argv[0], "enable", strlen("enable")) != 0
+ || strncmp(argv[1], "full-wake-history",
+ strlen("full-wake-history")) != 0) {
+ _ERR("Unsupported Option");
+ return -1;
+ }
+
+ to_enable = 1;
+ if (prev_wake_state == to_enable) {
+ _WARN("is already enabled");
+ return 0;
+ }
+
+ prev_wake_state = to_enable;
+
+ _WARN("Case %s", argv[0]);
+ ret = bd_reset_history(to_enable);
+ if (ret != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("bd_reset_history failed (%x)", ret);
+ return -1;
+ }
+ break;
+ case 'd':
+ if (argc != 2 || strncmp(argv[0], "disable", strlen("disable")) != 0
+ || strncmp(argv[1], "full-wake-history",
+ strlen("full-wake-history")) != 0) {
+ _ERR("Unsupported Option");
+ return -1;
+ }
+
+ to_enable = 0;
+ if (prev_wake_state == to_enable) {
+ _WARN("is already disabled");
+ return 0;
+ }
+ prev_wake_state = to_enable;
+
_WARN("Case %s", argv[0]);
- ret = bd_reset_history();
+ ret = bd_reset_history(to_enable);
if (ret != BATTERY_MONITOR_ERROR_NONE) {
_ERR("bd_reset_history failed (%x)", ret);
return -1;
@@ -1489,6 +1558,8 @@ int bd_initialize_battery_dump()
front = -1; end = -1; h_flag = true;
lst_charge = -1;
+ rst_time = -1;
+ prev_wake_state = 0;
#ifdef DUMP_DUMMY
bd_dummy_test_fn();
#else
diff --git a/src/battery_dump/bm_listeners.c b/src/battery_dump/bm_listeners.c
index 480d58d..63c796e 100644
--- a/src/battery_dump/bm_listeners.c
+++ b/src/battery_dump/bm_listeners.c
@@ -34,6 +34,11 @@ typedef struct ApplicationInfo {
int app_state;
} appInfo;
+typedef struct WakelockInfo {
+ int hsp_info;
+ int wake_state;
+} wakeInfo;
+
wifi_manager_h wifi = NULL;
struct timeval prev_event_time;
@@ -52,10 +57,25 @@ static int listener_hsp = -1;
static event_pool events_buf[10];
static int buff_count = 0;
static int lock_ref_count = 0;
+static int lock_hsp = 0;
+static int bt_hsp = 0;
+static int bt_scan_hsp = 0;
+static int wifi_hsp = 0;
+static int wifi_scan_hsp = 0;
+static int wifi_connected_hsp = 0;
+static int display_hsp = 0;
+static int gps_hsp = 0;
+static int app_hsp = 0;
+static int wakeup_hsp = 0;
+static int modem_hsp = 0;
+static int reset_val = 0;
+
GHashTable *app_list = NULL;
+GHashTable *wakelock_list = NULL;
static GHashTable *pid_map = NULL;
+
static void bd_set_free_data_object(void)
{
BD_CHECK_VALIDITY_RETURN((data_obj != NULL), {});
@@ -157,12 +177,14 @@ static int bd_listener_set_appId_info(char *app_id)
data_obj->event_tag->uid = 1000;
- data_obj->event_tag->string_info = g_string_new(app_id);
+ data_obj->event_tag->string_info = g_string_sized_new(7);
- BD_CHECK_FOR_VALIDITY((data_obj->event_tag->string_info != NULL), {},
- BATTERY_MONITOR_ERROR_OUT_OF_MEMORY);
+ if (!data_obj->event_tag->string_info) {
+ _ERR("memory allocation failed ");
+ return 1;
+ }
- _DBG("set string_info - [%s]", data_obj->event_tag->string_info->str);
+ g_string_append_printf(data_obj->event_tag->string_info, "%s", app_id);
EXIT;
return 0;
@@ -216,8 +238,8 @@ static int bd_listener_set_battery_info()
else
data_obj->battery_plugtype = BD_BPLT_NONE;
- _DBG("battery_level = %d, battery_status = %d, battery_health = %d, battery_plugtype = %d",
- data_obj->battery_level, data_obj->battery_status, \
+ _DBG("battery_level = %d, battery_status = %d, battery_health = %d, \
+ battery_plugtype = %d", data_obj->battery_level, data_obj->battery_status, \
data_obj->battery_health, data_obj->battery_plugtype);
data_obj->battery_temperature = info.temperature;
@@ -237,7 +259,6 @@ static void bd_listener_set_bt_adapter_state_change_data(int adapter_state)
{
ENTER;
- static int bt_hsp = 0;
int bt_state = -1;
if (adapter_state == BT_ADAPTER_ENABLED)
@@ -290,8 +311,7 @@ static void bd_listener_set_bt_device_discovery_state_change_data(int discovery_
_INFO("discovery_state = %d", discovery_state);
- static int bt_scan_hsp = 0, bt_flag = 0;
-
+ static int bt_flag = 0;
if (data_obj) {
switch (discovery_state) {
case BT_ADAPTER_DEVICE_DISCOVERY_STARTED:
@@ -390,8 +410,6 @@ static void bd_listener_set_wifi_device_state_data(int state)
(state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) ? _INFO("Activated") : _INFO("Deactivated");
- static int wifi_hsp = 0;
-
if (data_obj) {
if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
data_obj->event_code = ET_NONE;
@@ -435,7 +453,7 @@ static void bd_listener_set_wifi_scan_change_data(int state)
_INFO("scan state = %d", state);
- static int wifi_flag = 0, wifi_scan_hsp = 0;
+ static int wifi_flag = 0;
if (data_obj) {
if (state == WIFI_MANAGER_SCAN_STATE_SCANNING) {
@@ -484,8 +502,6 @@ static void bd_listener_set_wifi_connection_state_change_data(int state)
_INFO("connection state = %d", state);
- static int wifi_connected_hsp = 0;
-
if (data_obj) {
switch (state) {
case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
@@ -532,8 +548,6 @@ static void bd_listener_set_device_display_change_data(int value)
_INFO("device display state = %d", value);
- static int display_hsp = 0;
-
switch (value) {
case DISPLAY_STATE_NORMAL:
_DBG("Display on");
@@ -665,8 +679,6 @@ static void bd_listener_set_sleep_wakeup_change_data(int val)
_INFO("sleep wakeup change = %d", val);
- static int wakeup_hsp = 0;
-
if (val) {
data_obj->event_code = ET_NONE;
data_obj->event_tag = NULL;
@@ -724,8 +736,6 @@ static void bd_listener_set_location_change_data(int gps)
_INFO("location change = %d", gps);
- static int gps_hsp = 0;
-
if (data_obj) {
if (gps) {
data_obj->event_code = ET_NONE;
@@ -772,54 +782,190 @@ static int bd_listener_set_power_lock_unlock_change_data(int lock, char *app_id)
_INFO("lock change - %d, app - %s", lock, app_id);
- static int lock_hsp = 0;
- static int prev_lock = -1;
-
- if (prev_lock == lock) {
- _WARN("same lock event");
- BM_FREE(app_id);
- return 1;
- }
+ int error_code = 0;
+ void *prv_data = NULL, *prv_app_id = NULL;
if (lock) {
data_obj->event_code = ET_NONE;
data_obj->event_tag = NULL;
data_obj->wakelock_tag = NULL;
+ lock_hsp = listener_hsp + 1;
+
+ /* check if exists in hash-table */
+ if (g_hash_table_lookup_extended(wakelock_list, app_id, &prv_app_id, &prv_data) == true) {
+ wakeInfo *prevInfo = (wakeInfo *)prv_data;
+
+ /*check if an app try to lock again without sending unlock event*/
+ if (prevInfo->wake_state) {
+ error_code = 1;
+ _ERR(" two consecutive lock events for same app_id");
+ goto out;
+ }
+ prevInfo->hsp_info = lock_hsp;
+ prevInfo->wake_state = lock;
+
+ _DBG(" sp index for this app id is = %d and lock_hsp= %d",
+ prevInfo->hsp_info, lock_hsp);
+ } else {
+ /* first time for app_id , insert into hash-table */
+ wakeInfo *info = (wakeInfo *)calloc(1, sizeof(wakeInfo));
+ if (info == NULL) {
+ _ERR("memory allocation failed");
+ error_code = 1;
+ lock_ref_count++;
+ goto out;
+ }
+ info->hsp_info = lock_hsp;
+ info->wake_state = lock;
+
+ _DBG("inserting in table - [%s], hsp-info = %d, wake_state= %d", app_id, info->hsp_info, info->wake_state);
+ g_hash_table_insert(wakelock_list, g_strdup(app_id), info);
+ }
+ if (reset_val) {
+ /* Check if Reset is Enabled, set EWL event */
+ data_obj->event_code |= ET_WAKE_LOCK;
+ data_obj->event_code |= ET_FLAG_START;
+ data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
+ if (data_obj->event_tag) {
+ data_obj->event_tag->sp_idx = lock_hsp;
+ if (bd_listener_set_appId_info(app_id)) {
+ error_code = 1;
+ lock_ref_count++;
+ _ERR("bd_listener_set_appId_info failure ");
+ BM_FREE(data_obj->event_tag);
+ goto out;
+ }
+ } else {
+ _ERR(" object creation failure ");
+ error_code = 1;
+ lock_ref_count++;
+ goto out;
+ }
+ } else {
+ /* If Reset is Disabled, Don't set EWL event*/
+ if (lock_ref_count > 0) {
+ error_code = 1;
+ _DBG(" Reset Disabled no need to send event ");
+ lock_ref_count++;
+ goto out;
+ }
+
+ }
data_obj->wakelock_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
if (data_obj->wakelock_tag) {
-
- lock_hsp = ++listener_hsp;
data_obj->wakelock_tag->sp_idx = lock_hsp;
data_obj->wakelock_tag->uid = 1000;
-
data_obj->wakelock_tag->string_info = g_string_new(app_id);
- BD_CHECK_FOR_VALIDITY((data_obj->wakelock_tag->string_info != NULL), {},
- BATTERY_MONITOR_ERROR_OUT_OF_MEMORY);
+ BD_CHECK_FOR_VALIDITY((data_obj->wakelock_tag->string_info != NULL), { BM_FREE(app_id); BM_FREE(data_obj->wakelock_tag); },
+ BATTERY_MONITOR_ERROR_OUT_OF_MEMORY);
_DBG("wakelock tag created, string_info - [%s]",
- data_obj->wakelock_tag->string_info->str);
-
+ data_obj->wakelock_tag->string_info->str);
} else {
- _ERR(" object creation failure ");
+ _ERR("wakelock tag object creation failure ");
BM_FREE(app_id);
+ lock_ref_count++;
return 1;
}
- data_obj->state_1 |= ST1_WAKE_LOCK_FLAG;
+
+ /* Set wake lock state*/
+ if (lock_ref_count == 0) {
+ _DBG(" ref_count = 0, set the wake lock state ");
+ data_obj->state_1 |= ST1_WAKE_LOCK_FLAG;
+ }
+
+ lock_ref_count++;
+ listener_hsp++;
+ BM_FREE(app_id);
+ return 0;
} else {
data_obj->event_code = ET_NONE;
- data_obj->wakelock_tag = NULL;
data_obj->event_tag = NULL;
- //WAKE LOCK TAG INFORMATION NOT REQ. AT UNSET.
- data_obj->state_1 &= ~(ST1_WAKE_LOCK_FLAG);
+ data_obj->wakelock_tag = NULL; //WAKE LOCK TAG INFORMATION NOT REQ. AT UNSET.
+
+ /* Unlock before a lock should be ignored*/
+ if (lock_ref_count == 0) {
+ error_code = 1;
+ goto out;
+ }
+
+ if (lock_ref_count >= 1) {
+ if (g_hash_table_lookup_extended(wakelock_list, app_id, &prv_app_id, &prv_data) == true) {
+ wakeInfo *prevInfo = (wakeInfo *)prv_data;
+
+ _DBG("app available in list - app_id[%s], prev_app_id[%s], wake_state[%d]",
+ app_id, (char *)prv_app_id, prevInfo->wake_state);
+
+ /* Check if an app try to Unlock without sending lock event*/
+ if (prevInfo->wake_state == 0) {
+ error_code = 1;
+ _ERR(" two consecutive un-lock events for same app_id");
+ goto out;
+ }
+
+ if (prevInfo->wake_state == 1 && lock == 0) {
+ prevInfo->wake_state = lock; /* update new value for wake lock state */
+
+ /* Set -Ewl event if Reset is enabled*/
+ if (reset_val) {
+ data_obj->event_code = ET_NONE;
+ data_obj->event_code |= ET_WAKE_LOCK;
+ data_obj->event_code |= ET_FLAG_FINISH;
+ data_obj->event_tag = NULL;
+
+ data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
+ if (data_obj->event_tag) {
+ lock_hsp = prevInfo->hsp_info;
+ error_code = 0;
+ data_obj->event_tag->sp_idx = lock_hsp;
+ if (bd_listener_set_appId_info(app_id)) {
+ error_code = 1;
+ _ERR("set app id failure ");
+ lock_ref_count--;
+ BM_FREE(data_obj->event_tag);
+ goto out;
+ }
+ } else {
+ _ERR(" data_obj->event_tag object creation fails ");
+ error_code = 1;
+ lock_ref_count--;
+ goto out;
+ }
+ }
+ } else {
+ _DBG("event-tag not created - prev_appid[%s], prev_state[%d], val[%d]",
+ (char *)prv_app_id, prevInfo->wake_state, lock);
+ error_code = 1;
+ lock_ref_count--;
+ goto out;
+ }
+ } else {
+ _DBG("application not available in list ");
+ error_code = 1;
+ goto out;
+ }
+
+ }
+ if (lock_ref_count > 1 && reset_val == 0)
+ error_code = 1;
+
+ /* Unset wake lock state */
+ if (lock_ref_count == 1) {
+ _DBG(" unset the wake lock state ref_count ==1 ");
+ data_obj->state_1 &= ~(ST1_WAKE_LOCK_FLAG);
+ }
+ lock_ref_count--;
}
- prev_lock = lock;
- BM_FREE(app_id);
+out:
+ if (app_id)
+ g_free(app_id);
+ _DBG(" Error code =%d, lock_ref_count = %d ", error_code, lock_ref_count);
EXIT;
- return 0;
+ return error_code;
}
static int bd_listener_set_app_status_change_data(int val, char *app_id)
@@ -908,8 +1054,7 @@ static int bd_listener_set_app_status_change_data(int val, char *app_id)
/* event tag is created only when app transits from foreground to either
* background or terminate state. No event tag is created when transition
* is from background state to terminate state */
- if (prevInfo->app_state == 1 && (val == 0 || val == -1))
- {
+ if (prevInfo->app_state == 1 && (val == 0 || val == -1)) {
prevInfo->app_state = val; /* update new value for app_id */
data_obj->event_code = ET_NONE;
@@ -957,8 +1102,6 @@ static void bd_listener_set_modem_power_state_change_data(int state)
_INFO("modem state = %d", state);
- static int modem_hsp = 0;
-
if (data_obj && state == 0) { /* ON */
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_ACTIVE;
@@ -1077,11 +1220,11 @@ static void bd_listener_create_event_data(int type, int val, char *app)
gettimeofday(&tv, NULL);
data_obj->time_s = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
- double time_taken;
- time_taken = (tv.tv_sec - prev_event_time.tv_sec) * 1000000;
- time_taken = (time_taken + (tv.tv_usec - prev_event_time.tv_usec)) * 0.000001;
+ long long time_taken = 0;
+ time_taken = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
+ time_taken = time_taken - (((long long)prev_event_time.tv_sec * 1000) + ((long long)prev_event_time.tv_usec / 1000));
- _DBG("time_taken = %lf ", time_taken);
+ _DBG("time_taken = %lld ", time_taken);
if (time_taken >= BATTERY_INFO_DELAY) {
if (bd_listener_set_battery_info() != DEVICE_ERROR_NONE)
@@ -1099,7 +1242,7 @@ static void bd_listener_create_event_data(int type, int val, char *app)
prev_battery_level = data_obj->battery_level;
}
- if (data_obj->event_tag && type != LISTEN_APP_STATUS) {
+ if (data_obj->event_tag && type != LISTEN_APP_STATUS && type != LISTEN_POWERLOCKUNLOCK_STATE) {
data_obj->event_tag->uid = 1000;
data_obj->event_tag->string_info = g_string_new("Tizen");
@@ -1112,9 +1255,12 @@ static void bd_listener_create_event_data(int type, int val, char *app)
data_obj->event_tag->string_info->str, data_obj->event_tag->sp_idx);
}
- if (type == LISTEN_POWERLOCKUNLOCK_STATE)
- data_obj->event_tag = NULL;
- else
+ if (type == LISTEN_POWERLOCKUNLOCK_STATE) {
+ if (reset_val)
+ _DBG(" Powerlockunlock in Reset Enabled state");
+ else
+ data_obj->event_tag = NULL;
+ } else
data_obj->wakelock_tag = NULL;
if (type != LISTEN_SLEEP_WAKEUP_STATE)
@@ -1772,31 +1918,22 @@ static void _bd_listener_powerlock_signal_cb(GDBusConnection *conn, const gchar
g_variant_get(params, "(&sii)", &lock_type, &pid, &timeout);
BD_CHECK_VALIDITY_RETURN((pid > 0), {});
- _DBG("lock[%s], pid[%d], timeout[%d], ref_count[%d]", lock_type, pid, timeout, lock_ref_count);
-
- if (lock_ref_count == 0) {
-
- bm_get_symlink_for_pid(pid, &pname);
-
- _DBG("creating wake-lock event, pid[%d], process[%s]", pid, pname);
-
- /* get event object */
- event_pool *event = bd_listener_get_event_obj(LISTEN_POWERLOCKUNLOCK_STATE, 1, pname);
- if (event == NULL) {
- _ERR("Failed to get event pool object");
- BM_FREE(pname);
- return;
- }
-
- /* create thread */
- bd_create_producer_thread(event, "lock_event");
+ _DBG("lock[%s], pid[%d], timeout[%d]", lock_type, pid, timeout);
+ bm_get_symlink_for_pid(pid, &pname);
- ++lock_ref_count;
+ _DBG("creating wake-lock event, pid[%d], process[%s]", pid, pname);
- } else {
- _DBG("lock acquired, ref_count[%d]", ++lock_ref_count);
+ /* get event object */
+ event_pool *event = bd_listener_get_event_obj(LISTEN_POWERLOCKUNLOCK_STATE, 1, pname);
+ if (event == NULL) {
+ _ERR("Failed to get event pool object");
+ BM_FREE(pname);
+ return;
}
+ /* create thread */
+ bd_create_producer_thread(event, "lock_event");
+
EXIT;
return;
}
@@ -1814,35 +1951,21 @@ static void _bd_listener_powerunlock_signal_cb(GDBusConnection *conn, const gcha
g_variant_get(params, "(&sii)", &lock_type, &pid, &timeout);
BD_CHECK_VALIDITY_RETURN((pid > 0), {});
- _DBG("un-lock[%s], pid[%d], timeout[%d], ref_count[%d]", lock_type, pid, timeout, lock_ref_count);
+ _DBG("un-lock[%s], pid[%d], timeout[%d]", lock_type, pid, timeout);
+ bm_get_symlink_for_pid(pid, &pname);
+
+ _DBG("creating wake-unlock event, pid[%d], process[%s]", pid, pname);
- if (lock_ref_count == 0) {
- _ERR("improper wakelock, no event created");
+ /* get event object */
+ event_pool *event = bd_listener_get_event_obj(LISTEN_POWERLOCKUNLOCK_STATE, 0, pname);
+ if (event == NULL) {
+ _ERR("Failed to get event pool object");
+ BM_FREE(pname);
return;
- } else if (lock_ref_count > 0) {
- --lock_ref_count;
- _DBG("received unlock event, count[%d]", lock_ref_count);
}
- if (lock_ref_count == 0) {
-
- bm_get_symlink_for_pid(pid, &pname);
-
- _DBG("creating wake-unlock event, pid[%d], process[%s]", pid, pname);
-
- /* get event object */
- event_pool *event = bd_listener_get_event_obj(LISTEN_POWERLOCKUNLOCK_STATE, 0, pname);
- if (event == NULL) {
- _ERR("Failed to get event pool object");
- BM_FREE(pname);
- return;
- }
-
- /* create thread */
- bd_create_producer_thread(event, "lock_event");
- } else {
- _DBG("still holding lock, ref_count[%d]", lock_ref_count);
- }
+ /* create thread */
+ bd_create_producer_thread(event, "lock_event");
EXIT;
return;
@@ -2302,6 +2425,12 @@ static int bd_initialize_data_items()
return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
}
+ /* wakeup-list hash table */
+ wakelock_list = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ if (wakelock_list == NULL) {
+ _ERR("failed to create wakelock-list table");
+ return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
+ }
/* pid-app_id map */
pid_map = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
if (pid_map == NULL) {
@@ -2335,6 +2464,88 @@ static int bd_initialize_data_items()
return BATTERY_MONITOR_ERROR_NONE;
}
+static int bm_start_recording_event()
+{
+ ENTER;
+ _DBG("History Recorder Started");
+ listener_hsp = -1;
+
+ // Reinitialize the hsp variables
+
+ bt_hsp = 0; bt_scan_hsp = 0;
+ wifi_hsp = 0; wifi_scan_hsp = 0; wifi_connected_hsp = 0;
+ display_hsp = 0; gps_hsp = 0; lock_hsp = 0; app_hsp = 0;
+ wakeup_hsp = 0; modem_hsp = 0; lock_ref_count = 0;
+
+ app_list = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+
+ wakelock_list = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+
+ EXIT;
+ return 0;
+}
+
+static int bm_stop_recording_event()
+{
+ ENTER;
+ _DBG("History Recorder Stopped");
+
+ if (data_obj == NULL) {
+ _ERR("data obj is unavailable");
+ return -1;
+ }
+
+ data_obj->event_code = ET_NONE;
+ if (data_obj->event_tag != NULL) {
+ g_string_free(data_obj->event_tag->string_info, TRUE);
+ free(data_obj->event_tag);
+ }
+ if (data_obj->wakelock_tag != NULL) {
+ g_string_free(data_obj->wakelock_tag->string_info, TRUE);
+ free(data_obj->wakelock_tag);
+ }
+ if (data_obj->wakereason_tag != NULL) {
+ g_string_free(data_obj->wakereason_tag->string_info, TRUE);
+ free(data_obj->wakereason_tag);
+ }
+
+ if (app_list)
+ g_hash_table_destroy(app_list);
+
+ if (wakelock_list)
+ g_hash_table_destroy(wakelock_list);
+ EXIT;
+ return BATTERY_MONITOR_ERROR_NONE;
+}
+
+int bm_reset_event_listener(int to_enable)
+{
+ ENTER;
+
+ int ret = BATTERY_MONITOR_ERROR_NONE;
+ _DBG("stop recording");
+ ret = bm_stop_recording_event();
+ if (ret != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("unable to stop recording");
+ return ret;
+ }
+
+ _DBG("start recording");
+ ret = bm_start_recording_event();
+ if (ret != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("unable to start recording");
+ return ret;
+ }
+
+ if (to_enable)
+ _DBG("is enabled");
+
+ reset_val = to_enable;
+
+ EXIT;
+ return ret;
+}
+
int bd_initialize_listeners(void)
{
ENTER;
@@ -2355,8 +2566,7 @@ int bd_initialize_listeners(void)
_ERR("pthread_attr_init failed");
return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
}
-
- if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
+ if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
_ERR("pthread_attr_setdetachstate failed");
/* Wifi callbacks */
@@ -2471,6 +2681,11 @@ int bd_deinitialize_listeners()
app_list = NULL;
}
+ if (wakelock_list) {
+ g_hash_table_destroy(wakelock_list);
+ wakelock_list = NULL;
+ }
+
if (pid_map) {
g_hash_table_destroy(pid_map);
pid_map = NULL;
diff --git a/src/bm_callback_handler.c b/src/bm_callback_handler.c
index 941bd94..6843637 100644..100755
--- a/src/bm_callback_handler.c
+++ b/src/bm_callback_handler.c
@@ -175,7 +175,6 @@ void bm_receive_device_network_feature_data(bm_plugin_error_e result, bm_data_h
return;
}
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
void bm_receive_gps_sensor_feature_data(bm_plugin_error_e result, bm_data_h *handle)
{
ENTER;
@@ -206,7 +205,6 @@ void bm_receive_gps_sensor_feature_data(bm_plugin_error_e result, bm_data_h *han
EXIT;
return;
}
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
bm_callbacks_st bm_receiver_callbacks[BATTERY_MONITOR_CALLBACKS_MAX] = \
{ { .provide_feature_data = bm_receive_ble_feature_data },
@@ -214,7 +212,5 @@ bm_callbacks_st bm_receiver_callbacks[BATTERY_MONITOR_CALLBACKS_MAX] = \
{ .provide_feature_data = bm_receive_cpu_feature_data },
{ .provide_feature_data = bm_receive_display_feature_data },
{ .provide_feature_data = bm_receive_device_network_feature_data },
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
{ .provide_feature_data = bm_receive_gps_sensor_feature_data }
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
};
diff --git a/src/bm_config_parser.c b/src/bm_config_parser.c
index abfd775..076ab76 100644..100755
--- a/src/bm_config_parser.c
+++ b/src/bm_config_parser.c
@@ -376,8 +376,7 @@ END:
return ret;
}
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
-int bm_get_gps_sensor_power_params(double *gps_use)
+int bm_get_gps_sensor_power_params(double *gps_use, double *gps_searching)
{
ENTER;
@@ -387,6 +386,7 @@ int bm_get_gps_sensor_power_params(double *gps_use)
json_object *jmain = NULL, *jdouble = NULL, *jvalue = NULL;
BM_CHECK_INPUT_PARAM(gps_use);
+ BM_CHECK_INPUT_PARAM(gps_searching);
contents = bm_read_content_from_file(BATTERY_MONITOR_POWER_PROFILE_CONFIG_FILE_PATH);
@@ -409,6 +409,13 @@ int bm_get_gps_sensor_power_params(double *gps_use)
_DBG("gps-sensor power params - gps[%lf]", *gps_use);
+ json_object_object_get_ex(jvalue, "p_gps_insearching", &jdouble);
+ if (!jdouble)
+ goto END;
+ *gps_searching = json_object_get_double(jdouble);
+
+ _DBG("gps-sensor searching power params - gps[%lf]", *gps_searching);
+
ret = BATTERY_MONITOR_ERROR_NONE;
END:
g_free(contents);
@@ -418,7 +425,6 @@ END:
EXIT;
return ret;
}
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
int bm_get_cpu_power_params(double *user, double *system)
{
diff --git a/src/bm_plugin_manager.c b/src/bm_plugin_manager.c
index e855ec5..5b2586d 100644..100755
--- a/src/bm_plugin_manager.c
+++ b/src/bm_plugin_manager.c
@@ -27,9 +27,7 @@ const bm_callbacks_st wifi_cb;
const bm_callbacks_st cpu_cb;
const bm_callbacks_st display_cb;
const bm_callbacks_st device_network_cb;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
const bm_callbacks_st gps_cb;
-#endif
static bm_plugin_info_h *plugins[BATTERY_MONITOR_PLUGINS_MAX];
@@ -40,9 +38,7 @@ inline void bm_populate_callbacks(void)
bm_receiver_callbacks[BM_DATA_TYPE_CPU] = &cpu_cb;
bm_receiver_callbacks[BM_DATA_TYPE_DISPLAY] = &display_cb;
bm_receiver_callbacks[BM_DATA_TYPE_DEVICE_NETWORK] = &device_network_cb;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
bm_receiver_callbacks[BM_DATA_TYPE_GPS_SENSOR] = &gps_cb;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
return;
}
@@ -55,9 +51,7 @@ const char *bm_get_plugin_name(bm_plugin_id_e id)
BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_CPU)
BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_DISPLAY)
BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_DEVICE_NETWORK)
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
BM_ENUM_ID_TO_STR(BM_PLUGIN_ID_GPS_SENSOR)
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
default:
return "UNKNOWN PLUGIN NAME";
}
@@ -72,11 +66,7 @@ void bm_get_feature_plugin_handle(bm_plugin_info_h **handle, bm_plugin_id_e id)
return;
}
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
if (id >= BM_PLUGIN_ID_MAX) {
-#else
- if (id > BM_PLUGIN_ID_DEVICE_NETWORK) {
-#endif
*handle = NULL;
_ERR("invalid plugin id");
goto END;
@@ -105,12 +95,7 @@ static int bm_init_loaded_plugins()
const bm_callbacks_st *bm_cb = NULL;
bm_populate_callbacks();
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
for (id = BM_PLUGIN_ID_BLE; id < BM_PLUGIN_ID_MAX; ++id) {
-#else
- for (id = BM_PLUGIN_ID_BLE; id <= BM_PLUGIN_ID_DEVICE_NETWORK; ++id) {
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
-
bm_plugin = plugins[id];
bm_cb = bm_receiver_callbacks[id];
@@ -145,11 +130,7 @@ static int bm_add_plugin(void *handle, bm_plugin_st *plugin)
_INFO("Plugin Info - name[%s], id[%d], version[%s]",
plugin->name, plugin->id, plugin->version);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
if (BATTERY_MONITOR_PLUGINS_MAX < plugin->id) {
-#else
- if (BM_PLUGIN_ID_DEVICE_NETWORK < plugin->id) {
-#endif
_ERR("Unknown plugin id[%d] for [%s]", plugin->id, plugin->name);
return BATTERY_MONITOR_ERROR_PLUGIN_ADD;
}
@@ -160,8 +141,7 @@ static int bm_add_plugin(void *handle, bm_plugin_st *plugin)
}
if (g_str_equal(plugin->version, BATTERY_MONITOR_VERSION) == FALSE) {
- _ERR("Version (%s) mismatch for %s",
- plugin->version, plugin->name);
+ _ERR("Version (%s) mismatch for %s",plugin->version, plugin->name);
return BATTERY_MONITOR_ERROR_PLUGIN_ADD;
}
@@ -301,11 +281,7 @@ void deinitialize_plugin_manager(void)
int id;
bm_plugin_info_h *bm_plugin = NULL;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
for (id = BM_PLUGIN_ID_BLE; id < BM_PLUGIN_ID_MAX; ++id) {
-#else
- for (id = BM_PLUGIN_ID_BLE; id <= BM_PLUGIN_ID_DEVICE_NETWORK; ++id) {
-#endif
bm_plugin = plugins[id];
diff --git a/src/bm_power_engine.c b/src/bm_power_engine.c
index 5763f50..a8caef9 100644..100755
--- a/src/bm_power_engine.c
+++ b/src/bm_power_engine.c
@@ -96,12 +96,10 @@ int bm_engine_get_mah_usage_by_app_id_for_resource_id_ci(const gchar* app_id, gi
*battery_usage = bm_calc_individual_mah_consumption(app_usage->rId_display, cmah);
else if (resource_id == BM_PLUGIN_ID_DEVICE_NETWORK)
*battery_usage = bm_calc_individual_mah_consumption(app_usage->rId_device_network, cmah);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
else if (resource_id == BM_PLUGIN_ID_GPS_SENSOR)
*battery_usage = bm_calc_individual_mah_consumption(app_usage->rId_gps, cmah);
else
*battery_usage = -1;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
bm_appid_usage_free(app_usage);
@@ -134,9 +132,7 @@ int bm_engine_get_total_mah_usage_by_app_id_ci(const gchar* app_id, gint64 start
}
int total_consumption = (app_usage->rId_ble + app_usage->rId_wifi + app_usage->rId_cpu + \
app_usage->rId_display + app_usage->rId_device_network);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
total_consumption += app_usage->rId_gps;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
*battery_usage = bm_calc_individual_mah_consumption(total_consumption, cmah);
_INFO("total battery consumption is [%lf] for app-id[%s]", *battery_usage, app_id);
@@ -211,11 +207,8 @@ int bm_engine_get_all_resource_usage_handle_ci(const gchar* app_id, gint64 start
battery_data->cpu_val = app_usage->rId_cpu;
battery_data->dp_val = app_usage->rId_display;
battery_data->dn_val = app_usage->rId_device_network;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
battery_data->gps_val = app_usage->rId_gps;
battery_data->bat_val = app_usage->rId_battery;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
-
bm_appid_usage_free(app_usage);
EXIT;
@@ -247,11 +240,9 @@ void bm_engine_set_req_flag_handle(bm_plugin_id_e req_plugin_id, bool value)
case BM_PLUGIN_ID_DEVICE_NETWORK:
bm_req_flag_h->req_dn_data = value;
break;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
case BM_PLUGIN_ID_GPS_SENSOR:
bm_req_flag_h->req_gps_data = value;
break;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
default:
_DBG("Invalid plugin ID");
break;
@@ -275,9 +266,7 @@ void bm_set_req_flag_handles(bool value)
bm_req_flag_h->req_cpu_data = value;
bm_req_flag_h->req_dp_data = value;
bm_req_flag_h->req_dn_data = value;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
bm_req_flag_h->req_gps_data = value;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
_INFO("request flags set-[%s]", (value == true) ? "TRUE" : "FALSE");
@@ -309,10 +298,8 @@ static int bm_appid_session_usage_map(char *app_id, int app_usage, bm_plugin_id_
temp->rId_display += app_usage;
else if (resource_id == BM_PLUGIN_ID_DEVICE_NETWORK)
temp->rId_device_network += app_usage;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
else if (resource_id == BM_PLUGIN_ID_GPS_SENSOR)
temp->rId_gps += app_usage;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
_DBG("update - app_usage for app_id(%s), for resource(%d), by usage(%d)", app_id, resource_id, app_usage);
//_DBG("session usage bt %d, wifi %d, cpu %d, dsp %d, dn %d", temp->rId_ble, temp->rId_wifi, temp->rId_cpu,
@@ -334,10 +321,8 @@ static int bm_appid_session_usage_map(char *app_id, int app_usage, bm_plugin_id_
temp->rId_display = app_usage;
else if (resource_id == BM_PLUGIN_ID_DEVICE_NETWORK)
temp->rId_device_network = app_usage;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
else if (resource_id == BM_PLUGIN_ID_GPS_SENSOR)
temp->rId_gps = app_usage;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
_DBG("insert - app_usage app_id(%s), for resource(%d), by usage(%d)", app_id, resource_id, app_usage);
@@ -1247,7 +1232,6 @@ int bm_device_network_calc_power_and_commit(bm_device_network_st *handle, bool m
return ret_val;
}
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
int bm_gps_calc_power_and_commit(bm_gps_st *handle)
{
ENTER;
@@ -1263,21 +1247,23 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle)
/* creating hash-map with (key, value) = (app-id, data) */
GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
- long int edTime = 0;
- long int stTime = 0;
- int sesTime = 0;
- int onTime = 0;
+ guint64 stTime = 0;
+ guint64 edTime = 0;
+ guint64 searchTime = 0;
+ guint64 connTime = 0;
+ guint64 onTime = 0;
/* iterating over list for data accumulation */
for (gps_data_iterator = handle->gps_data_list; gps_data_iterator; gps_data_iterator = gps_data_iterator->next) {
bm_gps_st *datalistnode = (bm_gps_st *)(gps_data_iterator->data);
- edTime = datalistnode->connStartTime;
- stTime = datalistnode->connStopTime;
- sesTime = edTime - stTime;
+ stTime = datalistnode->connStartTime;
+ edTime = datalistnode->connStopTime;
+ searchTime += datalistnode->searchingTime;
+ connTime += (edTime - stTime - datalistnode->searchingTime);
gps_atm_iterator = datalistnode->atm_list;
for ( ; gps_atm_iterator; gps_atm_iterator = gps_atm_iterator->next) {
app_time_map_st1 *gps_atm_node = (app_time_map_st1 *)gps_atm_iterator->data;
if (!gps_atm_node) {
- _DBG("no bt data available");
+ _DBG("no gps data available");
continue;
}
_DBG("gps data available");
@@ -1288,36 +1274,35 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle)
_DBG("previous app_id = %s", (char *)prv_app_id);
app_time_map_st1 *gps_atm_prv_node = (app_time_map_st1 *)prv_data;
gps_atm_node->time += gps_atm_prv_node->time;
- _DBG("update - app_id(%s), time(%d)", gps_atm_node->app_id, gps_atm_node->time);
+ _DBG("update - app_id(%s), time(%u)", gps_atm_node->app_id, gps_atm_node->time);
_INFO("updated - %d", g_hash_table_replace(hash, gps_atm_node->app_id, gps_atm_node));
} else {
- _DBG("insert - app_id(%s), time(%d)", gps_atm_node->app_id, gps_atm_node->time);
+ _DBG("insert - app_id(%s), time(%u)", gps_atm_node->app_id, gps_atm_node->time);
_INFO("inserted - %d", g_hash_table_insert(hash, gps_atm_node->app_id, gps_atm_node));
}
}
- }
-
+}
+ _DBG("gps-sensor searching duration(%llu), gps-sensor connected duration(%llu)",searchTime, connTime);
/* Read standard Rated Values from Device Spec File/Power Profile File */
- double sP_power_gps_conn = 0;
-
- ret_val = bm_get_gps_sensor_power_params(&sP_power_gps_conn);
+ double sP_power_gps_conn = 0, sP_power_gps_searching = 0;
+ ret_val = bm_get_gps_sensor_power_params(&sP_power_gps_conn, &sP_power_gps_searching);
if (ret_val != BATTERY_MONITOR_ERROR_NONE)
_ERR("failed to get gps-sensor power params");
- _DBG("gps-sensor power params - gps[%lf]", sP_power_gps_conn);
+ _DBG("gps-sensor power coefficients - gps connected[%lf], gps searching[%lf]", sP_power_gps_conn, sP_power_gps_searching);
/* GPS power consumption Level - 1 at the Resource Level */
- int P_power_gps = 0, P_power_conn = 0;
- P_power_conn = ((sP_power_gps_conn * sesTime));
-
- P_power_gps = P_power_conn;
- _DBG("Calculated Power for GPS P_power_gps (%d), P_power_conn (%d)", P_power_gps, P_power_conn);
+ double P_power_gps = 0, P_power_conn = 0, P_power_searching = 0;
+ P_power_conn = ((sP_power_gps_conn * connTime));
+ P_power_searching = ((sP_power_gps_searching * searchTime));
+ P_power_gps = P_power_conn + P_power_searching;
+ _DBG("calculated gps-sensor power consumption - P_power_gps(%lf), P_power_conn(%lf), P_power_searching(%lf)", P_power_gps, P_power_conn, P_power_searching);
/* GPS power consumption Level - 2 at the Application Level */
GHashTableIter iter;
gpointer key, value;
g_hash_table_iter_init(&iter, hash);
- int P_power_app_gps = 0, P_power_app_conn = 0;
+ double P_power_app_gps = 0;
char *appid = NULL;
int apptime = 0;
long int ret_time = bm_get_log_time(data_collection_period);
@@ -1325,21 +1310,21 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle)
appid_usage_s app_usage = {0};
while (g_hash_table_iter_next(&iter, &key, &value)) {
- P_power_app_gps = 0; P_power_app_conn = 0;
+ P_power_app_gps = 0;
apptime = 0;
app_time_map_st1 *temp = (app_time_map_st1 *)value;
appid = temp->app_id; apptime = temp->time;
- if (onTime != 0)
- P_power_app_conn = (P_power_conn * apptime)/onTime; //check for 0 denominator & same units
- P_power_app_gps = P_power_app_conn;
+ if (onTime != 0) {
+ P_power_app_gps = (P_power_gps * apptime)/onTime; //check for 0 denominator & same units
+ }
app_usage.AppId = appid;
app_usage.rId_gps = P_power_app_gps;
app_usage.log_time = ret_time;
total_app_pw += P_power_app_gps;
/* Call Insert Function */
- _DBG("Calculated Power for Appid (%s) P_power_app_gps (%d), P_power_app_conn (%d)", appid, P_power_app_gps, P_power_app_conn);
+ _DBG("calculated gps-sensor power consumed by app(%s), P_power_app_gps(%lf)", appid, P_power_app_gps);
ret_val = bm_server_app_usage_insert_to_db(&app_usage);
if (ret_val != BATTERY_MONITOR_ERROR_NONE)
_ERR("Insert of GPS App failed ");
@@ -1369,7 +1354,6 @@ int bm_gps_calc_power_and_commit(bm_gps_st *handle)
EXIT;
return ret_val;
}
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
int bm_get_data_from_handles(void)
{
@@ -1440,7 +1424,6 @@ int bm_get_data_from_handles(void)
}
_DBG("completed device-network data request");
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
/* parsing gps data */
if (bm_data_handle->bm_gps_handle != NULL && bm_req_flag_h->req_gps_data) {
_DBG("parsing gps data");
@@ -1451,7 +1434,6 @@ int bm_get_data_from_handles(void)
bm_engine_set_req_flag_handle(BM_PLUGIN_ID_GPS_SENSOR, true);
}
_DBG("completed gps data request");
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
ret_val = bm_insert_appid_session_usage_to_db();
BM_CHECK_VAL((ret_val == BATTERY_MONITOR_ERROR_NONE), "battery session logging failure");
@@ -1493,11 +1475,7 @@ int bm_start_getting_feature_data(void)
bm_update_plugin_request_time();
/* request data from each plugin & store its handle */
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
for (id = BM_PLUGIN_ID_BLE; id < BM_PLUGIN_ID_MAX; ++id) {
-#else
- for (id = BM_PLUGIN_ID_BLE; id <= BM_PLUGIN_ID_DEVICE_NETWORK; ++id) {
-#endif
bm_get_feature_plugin_handle(&bm_plugin, id);
handle = NULL;
if (!bm_plugin || !bm_plugin->api) {
@@ -1562,7 +1540,6 @@ int bm_start_getting_feature_data(void)
bm_data_handle->bm_dn_handle = (bm_device_network_st *)(handle);
}
break;
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
case BM_PLUGIN_ID_GPS_SENSOR: /* GPS Sensor Data */
ret_val = bm_plugin->api->get_feature_data(&handle, id);
if (ret_val != BATTERY_MONITOR_ERROR_NONE) {
@@ -1574,7 +1551,6 @@ int bm_start_getting_feature_data(void)
bm_data_handle->bm_gps_handle = (bm_gps_st *)(handle);
}
break;
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
default:
break;
}
diff --git a/src/bm_server_db.c b/src/bm_server_db.c
index a3154e1..24923a2 100644..100755
--- a/src/bm_server_db.c
+++ b/src/bm_server_db.c
@@ -366,10 +366,8 @@ static int bm_appid_usage_convert_to_sql(appid_usage_s *bm_app_type, bm_stmt hst
bm_query_bind_int(hstmt, count++, bm_app_type->rId_cpu);
bm_query_bind_int(hstmt, count++, bm_app_type->rId_display);
bm_query_bind_int(hstmt, count++, bm_app_type->rId_device_network);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
bm_query_bind_int(hstmt, count++, bm_app_type->rId_gps);
bm_query_bind_int(hstmt, count++, bm_app_type->rId_battery);
-#endif
EXIT;
return count;
}
@@ -556,10 +554,8 @@ static void bm_convert_column_to_appid_usage(bm_stmt hstmt, appid_usage_s* bm_ap
bm_app_type->rId_cpu = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_CPU);
bm_app_type->rId_display = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_DISPLAY);
bm_app_type->rId_device_network = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_DEV_NTW);
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
bm_app_type->rId_gps = bm_query_table_column_int(hstmt, BM_APPUSAGE_FIELD_RID_GPS);
bm_app_type->rId_battery = -1;
-#endif
EXIT;
return;
@@ -1076,14 +1072,9 @@ static int bm_appid_usage_insert_to_db(sqlite3 *bm_db_handle, appid_usage_s *bm_
return BATTERY_MONITOR_ERROR_INVALID_PARAMETER;
BM_MEMSET(query, 0x00, sizeof(query));
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
BM_SNPRINTF(query, sizeof(query), \
"INSERT INTO %s( AppId, log_time, rId_ble, rId_wifi, rId_cpu, rId_display, rId_device_network, rId_gps, rId_battery ) values "
"(?, ?, ?, ?, ?, ?, ?, ?, ?)", BATTERY_MONITOR_APP_ID_USAGE_TABLE);
-#else
- BM_SNPRINTF(query, sizeof(query), "INSERT INTO %s( AppId, log_time, rId_ble, rId_wifi, rId_cpu, rId_display, rId_device_network) values "
- "(?, ?, ?, ?, ?, ?, ?)", BATTERY_MONITOR_APP_ID_USAGE_TABLE);
-#endif
hstmt = bm_prepare_query(bm_db_handle, query);
if (bm_db_err_code(bm_db_handle) == SQLITE_PERM) {
diff --git a/src/bm_util.c b/src/bm_util.c
index 0539c5e..efefc0f 100644..100755
--- a/src/bm_util.c
+++ b/src/bm_util.c
@@ -287,10 +287,8 @@ GVariant* bm_marshal_serialized_data(const bm_total_consumption_h data)
g_variant_builder_add(&builder, "{sv}", BATTERY_MONITOR_DN_DATA_ID,
g_variant_new_int32(in_data->dn_val));
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
g_variant_builder_add(&builder, "{sv}", BATTERY_MONITOR_GPS_DATA_ID,
g_variant_new_int32(in_data->gps_val));
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
g_variant_builder_add(&builder, "{sv}", BATTERY_MONITOR_BATTERY_DATA_ID,
g_variant_new_int32(in_data->bat_val));
@@ -309,9 +307,7 @@ const char *bm_get_resource_id_string(gint resource_id)
BM_RESOURCE_ID_TO_STR(BM_PLUGIN_ID_DISPLAY, BATTERY_MONITOR_DP_DATA_ID)
BM_RESOURCE_ID_TO_STR(BM_PLUGIN_ID_DEVICE_NETWORK, BATTERY_MONITOR_DN_DATA_ID)
BM_RESOURCE_ID_TO_STR(BM_PLUGIN_ID_GPS_SENSOR, BATTERY_MONITOR_GPS_DATA_ID)
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
BM_RESOURCE_ID_TO_STR(BM_PLUGIN_CONST_BATTERY, BATTERY_MONITOR_BATTERY_DATA_ID)
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
default:
EXIT;
@@ -319,6 +315,59 @@ const char *bm_get_resource_id_string(gint resource_id)
}
}
+void bm_get_symlink_for_pid(pid_t pid, char **pname)
+{
+ _INFO("pid = [%d]", pid);
+
+ char *app_id = NULL;
+
+ app_manager_get_app_id(pid, &app_id);
+
+ if (app_id == NULL) { /*it might be a daemon, ex-/usr/bin/batterymonitor-svcd*/
+ char path[PATH_BUFFER_SIZE], buf[BUFFERSIZE];
+ int path_len = 0, lst = 0;
+ ssize_t len = -1;
+ struct stat st_buf;
+ char err_buf[128] = {0,};
+
+ /* prepare pid-exe path */
+ path_len = snprintf(path, PATH_BUFFER_SIZE, "/proc/%d/exe", pid);
+ if (path_len < 1 || path_len >= PATH_BUFFER_SIZE) {
+ _ERR("insufficient buffer size");
+ return;
+ }
+
+ _DBG("exe path - [%s]", path);
+
+ /* check availability */
+ lst = lstat(path, &st_buf);
+ if (lst != 0 || !S_ISLNK(st_buf.st_mode)) {
+ _ERR("sym-link un-available");
+ return;
+ }
+
+ /* read symbolic link */
+ len = readlink(path, buf, sizeof(buf)-1);
+ if (len != -1) {
+ buf[len] = '\0';
+ } else {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ _ERR("read bytes - [%zd], error [%s]", len, err_buf);
+ return;
+ }
+
+ _DBG("read sym-link - [%s]", buf);
+
+ app_id = strdup(buf);
+ }
+
+ *pname = app_id;
+
+ _INFO("pid - [%d], name - [%s]", pid, *pname);
+
+ return;
+}
+
int bm_set_dbus_connection_obj(GDBusConnection* conn)
{
BM_CHECK_INPUT_PARAM(conn);
@@ -354,7 +403,7 @@ void bd_get_focussed_app_id(char **app_name)
}
return_val = app_context_get_app_id(app_context, &app_id);
- if(return_val != APP_MANAGER_ERROR_NONE) {
+ if (return_val != APP_MANAGER_ERROR_NONE) {
_ERR("failed to get app_id");
app_context_destroy(app_context);
return;
@@ -376,7 +425,7 @@ void bd_get_focussed_app_id(char **app_name)
return;
}
-void bm_get_symlink_for_pid(pid_t pid, char **pname)
+void bm_get_name_for_pid(pid_t pid, char **pname)
{
_INFO("pid = [%d]", pid);
@@ -385,38 +434,34 @@ void bm_get_symlink_for_pid(pid_t pid, char **pname)
app_manager_get_app_id(pid, &app_id);
if (app_id == NULL) { /*it might be a daemon, ex-/usr/bin/batterymonitor-svcd*/
- char path[PATH_BUFFER_SIZE], buf[BUFFERSIZE];
- int path_len = 0, lst = 0;
- ssize_t len = -1;
- struct stat st_buf;
+ char buf[PATH_MAX];
+ int fd, r;
- /* prepare pid-exe path */
- path_len = snprintf(path, PATH_BUFFER_SIZE, "/proc/%d/exe", pid);
- if (path_len < 1 || path_len >= PATH_BUFFER_SIZE) {
- _ERR("insufficient buffer size");
+ snprintf(buf, PATH_MAX, "/proc/%d/cmdline", pid);
+
+ if (access(buf, F_OK) != 0) {
+ _ERR("maybe pid no more exists");
return;
}
- _DBG("exe path - [%s]", path);
-
- /* check availability */
- lst = lstat(path, &st_buf);
- if (lst != 0 || !S_ISLNK(st_buf.st_mode)) {
- _ERR("sym-link un-available");
+ fd = open(buf, O_RDONLY);
+ if (fd < 0) {
+ _ERR("process(%d) does not exist now.", pid);
return;
}
- /* read symbolic link */
- len = readlink(path, buf, sizeof(buf)-1);
- if (len != -1) {
- buf[len] = '\0';
+ r = read(fd, buf, PATH_MAX);
+ if ((r >= 0) && (r < PATH_MAX)) {
+ buf[r] = '\0';
} else {
- _ERR("read bytes -[%d], error [%s]", (int)len, strerror(errno));
+ _ERR("read error");
+ if (close(fd) == -1)
+ _ERR("fd close error");
return;
}
- _DBG("read sym-link - [%s]", buf);
-
+ if (close(fd) == -1)
+ _ERR("fd close error");
app_id = strdup(buf);
}
@@ -795,7 +840,6 @@ void bm_set_free_device_network_data_handle(bm_device_network_st **dn_handle)
return;
}
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
void bm_set_free_gps_sensor_data_handle(bm_gps_st **gps_handle)
{
ENTER;
@@ -842,7 +886,6 @@ void bm_set_free_gps_sensor_data_handle(bm_gps_st **gps_handle)
EXIT;
return;
}
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
void bm_set_free_data_handles(bm_feature_data_h* data_hdl)
{
@@ -853,9 +896,7 @@ void bm_set_free_data_handles(bm_feature_data_h* data_hdl)
bm_set_free_cpu_data_handle(&((*data_hdl)->bm_cpu_handle));
bm_set_free_display_data_handle(&((*data_hdl)->bm_display_handle));
bm_set_free_device_network_data_handle(&((*data_hdl)->bm_dn_handle));
-#ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
bm_set_free_gps_sensor_data_handle(&((*data_hdl)->bm_gps_handle));
-#endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
BM_FREE(*data_hdl);