#include "bm_listeners.h"
#include "bm_dbg.h"
#include <bm_common.h>
+#include <bm_util.h>
#include <bd_history_item.h>
#include <vconf.h>
#include <pthread.h>
#define DBUS_DEVICED_SLEEP_MEMBER "sleep"
#define DBUS_DEVICED_WAKEUP_MEMBER "wakeup"
-static GDBusConnection *dbus_connection;
+/*static GDBusConnection *dbus_connection;
static int bm_listener_dbus_init(void)
{
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
-}
+}*/
static int fill_AppId_info(char *app_id)
{
ENTER;
guint ret = 0;
- if (!dbus_connection) {
+ GDBusConnection* dbus_connection = bm_get_dbus_connection_obj();
+ if (dbus_connection == NULL) {
_ERR("dbus connection is null");
EXIT;
return 1;
}
- ret = g_dbus_connection_signal_subscribe(dbus_connection,
- NULL,
- DBUS_DEVICED_IFACE,
- DBUS_DEVICED_PL_MEMBER,
- DBUS_DEVICED_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __powerlock_signal_callback,
- NULL,
- NULL);
+ ret = g_dbus_connection_signal_subscribe(dbus_connection, NULL, DBUS_DEVICED_IFACE,
+ DBUS_DEVICED_PL_MEMBER, DBUS_DEVICED_PATH, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, __powerlock_signal_callback,
+ NULL, NULL);
if (ret == 0) {
_ERR("Failed to subscrive bus signal"); //LCOV_EXCL_LINE System Error
return 1;
}
- ret = g_dbus_connection_signal_subscribe(dbus_connection,
- NULL,
- DBUS_DEVICED_IFACE,
- DBUS_DEVICED_PU_MEMBER,
- DBUS_DEVICED_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __powerunlock_signal_callback,
- NULL,
- NULL);
+ ret = g_dbus_connection_signal_subscribe(dbus_connection, NULL, DBUS_DEVICED_IFACE,
+ DBUS_DEVICED_PU_MEMBER, DBUS_DEVICED_PATH,
+ NULL, G_DBUS_SIGNAL_FLAGS_NONE, __powerunlock_signal_callback,
+ NULL, NULL);
if (ret == 0) {
_ERR("Failed to subscrive bus signal"); //LCOV_EXCL_LINE System Error
ENTER;
guint ret = 0;
+ GDBusConnection* dbus_connection = bm_get_dbus_connection_obj();
if (!dbus_connection) {
_ERR("dbus connection is null");
EXIT;
return 1;
}
- ret = g_dbus_connection_signal_subscribe(dbus_connection,
- NULL,
- DBUS_DEVICED_IFACE,
- DBUS_DEVICED_SLEEP_MEMBER,
- DBUS_DEVICED_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __sleep_signal_callback,
- NULL,
- NULL);
+ ret = g_dbus_connection_signal_subscribe(dbus_connection, NULL, DBUS_DEVICED_IFACE,
+ DBUS_DEVICED_SLEEP_MEMBER, DBUS_DEVICED_PATH, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, __sleep_signal_callback, NULL, NULL);
if (ret == 0) {
_ERR("Failed to subscrive bus signal"); //LCOV_EXCL_LINE System Error
return 1;
}
- ret = g_dbus_connection_signal_subscribe(dbus_connection,
- NULL,
- DBUS_DEVICED_IFACE,
- DBUS_DEVICED_WAKEUP_MEMBER,
- DBUS_DEVICED_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __wakeup_signal_callback,
- NULL,
- NULL);
+ ret = g_dbus_connection_signal_subscribe(dbus_connection, NULL, DBUS_DEVICED_IFACE,
+ DBUS_DEVICED_WAKEUP_MEMBER, DBUS_DEVICED_PATH, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, __wakeup_signal_callback, NULL, NULL);
if (ret == 0) {
_ERR("Failed to subscrive bus signal"); //LCOV_EXCL_LINE System Error
ENTER;
guint ret = 0;
+ GDBusConnection* dbus_connection = bm_get_dbus_connection_obj();
if (!dbus_connection) {
_ERR("dbus connection is null");
EXIT;
return 1;
}
- ret = g_dbus_connection_signal_subscribe(dbus_connection,
- NULL,
- "org.tizen.aul.AppStatus",
- "AppStatusChange",
- "/Org/Tizen/Aul/AppStatus",
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __app_status_signal_callback,
- NULL,
- NULL);
+ ret = g_dbus_connection_signal_subscribe(dbus_connection, NULL, "org.tizen.aul.AppStatus",
+ "AppStatusChange", "/Org/Tizen/Aul/AppStatus", NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, __app_status_signal_callback, NULL, NULL);
if (ret == 0) {
_ERR("Failed to subscrive bus signal"); //LCOV_EXCL_LINE System Error
if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
_ERR("pthread_attr_setdetachstate failed");
- /*Initialize DBus*/
+ /*Initialize DBus*
if (bm_listener_dbus_init())
- _ERR("bm_listener_dbus_init failed \n");
+ _ERR("bm_listener_dbus_init failed \n"); */
/* Wifi callbacks */
if (!bm_wifi_subscribe_listeners())
tel_deinit(handle);
}
- /*Dbus Deinitialize*/
+ /*Dbus Deinitialize*
if (bm_listener_dbus_deinit())
- _ERR("failed to de-init dbus ");
+ _ERR("failed to de-init dbus "); */
/* de-initialize pthread attributes */
if (pthread_attr_destroy(&attr) != 0)
{
ENTER;
- BM_RETURN_VAL((iface != NULL), {}, BATTERY_MONITOR_ERROR_INVALID_PARAMETER, "interface handle is null");
+ BM_RETURN_VAL((iface != NULL), {}, \
+ BATTERY_MONITOR_ERROR_INVALID_PARAMETER, "interface handle is null");
- iface->handle_get_mah_usage_by_app_id_for_resource_id_custom_interval = &bm_get_mah_usage_by_app_id_for_resource_id_custom_interval;
+ iface->handle_get_mah_usage_by_app_id_for_resource_id_custom_interval = \
+ &bm_get_mah_usage_by_app_id_for_resource_id_custom_interval;
- iface->handle_get_total_mah_usage_by_app_id_custom_interval = &bm_get_total_mah_usage_by_app_id_custom_interval;
+ iface->handle_get_total_mah_usage_by_app_id_custom_interval = \
+ &bm_get_total_mah_usage_by_app_id_custom_interval;
- iface->handle_get_total_mah_usage_by_resource_id_custom_interval = &bm_get_total_mah_usage_by_resource_id_custom_interval;
+ iface->handle_get_total_mah_usage_by_resource_id_custom_interval = \
+ &bm_get_total_mah_usage_by_resource_id_custom_interval;
- iface->handle_get_usage_handle_by_app_id_for_all_resource_id_custom_interval = &bm_get_usage_handle_by_app_id_for_all_resource_id_custom_interval;
+ iface->handle_get_usage_handle_by_app_id_for_all_resource_id_custom_interval = \
+ &bm_get_usage_handle_by_app_id_for_all_resource_id_custom_interval;
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
return;
}
+ /* set dbus connection object */
+ bm_set_dbus_connection_obj(g_dbus_interface_skeleton_get_connection(interface));
+
_INFO("connecting battery-monitor signals start");
if (BATTERY_MONITOR_ERROR_NONE != bm_set_dbus_interface_handles(iface)) {