From the libsyscommon, dbus connection was continuously used in an initialized state.
However, it is correct for the user side to use the dbus connection handle
after obtaining the connection.
Thus deviced will get connection handle as private to use in deviced module.
Change-Id: If02139e54e4dc05e968d1ea2b8eedeff33cb26e0
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
static void bm_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
ht_apptime = g_hash_table_new_full(g_str_hash, g_str_equal, _ht_key_destroy, _ht_val_destroy);
if (!ht_apptime)
_E("Failed to init hash table");
- ret = gdbus_add_object(NULL, DBUS_DEVICED_BM_PATH, &bm_dbus_interface);
+ ret = gdbus_add_object(handle, DBUS_DEVICED_BM_PATH, &bm_dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
static void battery_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_BATTERY, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
static void lowbat_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_DELAYED_INIT, delayed_init_done);
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init);
- ret = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_BATTERY, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
}
static void power_supply_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
memset(&battery, 0, sizeof(struct battery_status));
memset(&old_battery, 0, sizeof(struct battery_status));
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_LCD, handle_display_state_changed);
- ret = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_BATTERY, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
static void board_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_BOARD, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_BOARD, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
}
static void control_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_SYSNOTI, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_SYSNOTI, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
GList *elem, *elem_n;
const struct device_ops *dev;
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
dev_head = g_list_sort(dev_head, compare_priority);
}
}
- ret = gdbus_add_object(NULL, DEVICED_PATH_CORE, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_CORE, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
/* register every objects */
- if (gdbus_register_object_all(NULL) < 0)
+ if (gdbus_register_object_all(handle) < 0)
_E("Failed to register dbus method: %d", ret);
}
static void event_handler_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_SYSNOTI, &eh_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_SYSNOTI, &eh_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
#define WATCHDOG_TIMEOUT 90
static GMainLoop *mainloop;
+static dbus_handle_h g_handle = NULL;
static void writepid(char *pidpath)
{
static int deviced_init(void *data)
{
int ret;
- dbus_handle_h handle = NULL;
guint timer;
char bootmode[32] = "normal";
int retval;
return 0;
}
- handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
- if (!handle)
+ g_handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, TRUE);
+ if (!g_handle)
_E("Failed to get dbus connection.");
load_plugins();
CRITICAL_LOG("bootmode=%s", bootmode);
resource_init();
- devices_init(NULL);
+ devices_init((void*)&g_handle);
- ret = gdbus_request_name(handle, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL);
+ ret = gdbus_request_name(g_handle, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL);
if (ret <= 0) {
_E("Failed to request bus name.");
gdbus_check_name_owner(NULL, DEVICED_BUS_NAME);
static int deviced_exit(void *data)
{
+ int ret = 0;
+
devices_exit(NULL);
resource_exit();
unload_plugins();
+
+ if (!g_handle)
+ return 0;
+
+ ret = gdbus_free_connection(g_handle);
+ if (ret < 0) {
+ _E("Failed to free dbus connection %d", ret);
+ g_handle = NULL;
+ return ret;
+ }
+
+ g_handle = NULL;
+
return 0;
}
static void pmqos_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
/* register dbus methods */
- ret = gdbus_add_object(NULL, DEVICED_PATH_PMQOS, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_PMQOS, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
int init_pm_dbus(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
display_add_actor(&display_api_actor);
display_add_actor(&display_gesture_actor);
- ret = gdbus_add_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_DISPLAY, &dbus_interface);
if (ret < 0)
_E("fail to init dbus method(%d)", ret);
_W("Failed to init: input devices poll init error");
_I("Dbus init.");
- ret = init_pm_dbus(NULL);
+ ret = init_pm_dbus(data);
if (ret != 0)
_W("Failed to init: dbus initialization error");
static void cradle_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_LCD, display_changed);
- ret = gdbus_add_object(NULL, DEVICED_PATH_SYSNOTI, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_SYSNOTI, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
}
static void extcon_init(void *data)
{
int retval;
+ dbus_handle_h handle = NULL;
- retval = gdbus_add_object(NULL, DEVICED_PATH_EXTCON, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ retval = gdbus_add_object(handle, DEVICED_PATH_EXTCON, &dbus_interface);
if (retval < 0)
_E("Failed to init dbus method: %d", retval);
static void hdmi_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_SYSNOTI, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_SYSNOTI, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
int input_dbus_init(void *data)
{
int ret = 0;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_INPUT, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_INPUT, &dbus_interface);
if (ret < 0) {
_E("Failed to init input device dbus interface(%d)", ret);
return ret;
input_devman_exit();
}
- ret = input_dbus_init(NULL);
+ ret = input_dbus_init(data);
if (ret < 0)
_E("Failed to init input device dbus interface(%d)", ret);
static void ir_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_IR, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_IR, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
- ret = gdbus_add_object(NULL, DEVICED_PATH_LED, &dbus_interface_legacy);
+ ret = gdbus_add_object(handle, DEVICED_PATH_LED, &dbus_interface_legacy);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
static void rgb_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_LED, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_LED, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
static void torch_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
/* init dbus interface */
- ret = gdbus_add_object(NULL, DEVICED_PATH_LED, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_LED, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
}
void power_dbus_init(void *data)
{
int retval;
+ dbus_handle_h handle = NULL;
- retval = gdbus_add_object(NULL, DEVICED_PATH_POWER, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ retval = gdbus_add_object(handle, DEVICED_PATH_POWER, &dbus_interface);
if (retval < 0)
_E("Failed to init dbus method.");
}
void power_off_init(void *data)
{
int ret_val;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
/* init dbus interface */
- ret_val = gdbus_add_object(NULL, DEVICED_PATH_POWEROFF, &dbus_interface);
+ ret_val = gdbus_add_object(handle, DEVICED_PATH_POWEROFF, &dbus_interface);
if (ret_val < 0)
_E("Failed to init dbus method: %d", ret_val);
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_DELAYED_INIT, delayed_init_callback);
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_REQUEST_TRANSITION_STATE, transition_request_callback);
- power_dbus_init(NULL);
- power_off_init(NULL);
+ power_dbus_init(data);
+ power_off_init(data);
power_suspend_init();
power_event_lock_init();
static void cpu_info_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_SYSNOTI, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_SYSNOTI, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
}
static void thermal_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
ret = syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_DELAYED_INIT, delayed_init_done);
if (ret < 0)
_E("Failed to register booting done notifier.");
- ret = gdbus_add_object(NULL, DEVICED_PATH_TEMPERATURE, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_TEMPERATURE, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
}
static void time_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_SYSNOTI, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_SYSNOTI, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
static void sensitivity_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
if (sensitivity_dev_available)
return;
_I("Touch sensitivity device structure load success.");
/* init dbus interface */
- ret = gdbus_add_object(NULL, DEVICED_PATH_TOUCH, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_TOUCH, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
static void touchscreen_init(void *data)
{
int ret, val;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
if (battery_plgn->handle) {
fp_get_var_battery_status = dlsym(battery_plgn->handle, "get_var_battery_status");
g_display_config->touch_wakeup = val;
- ret = gdbus_add_object(NULL, DEVICED_PATH_TOUCH, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_TOUCH, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method. (%d)", ret);
{
int ret;
_D("tzip_init");
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
tzip_lock_init();
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_DELAYED_INIT, delayed_init_done);
syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_POWEROFF, tzip_poweroff);
- ret = gdbus_add_object(NULL, DEVICED_PATH_TZIP, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_TZIP, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
int usb_dbus_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_USB, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_USB, &dbus_interface);
if (ret < 0)
_E("Failed to init dbus method for USB: %d", ret);
if (ret < 0)
_E("Failed to register udev event(%d) for USB", ret);
- ret = usb_dbus_init(NULL);
+ ret = usb_dbus_init(data);
if (ret < 0)
_E("Failed to init dbus(%d) for USB", ret);
static void usbhost_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
+
+ if (data)
+ handle = *(dbus_handle_h *)data;
if (g_display_config)
display_on_usb_conn_changed = g_display_config->display_on_usb_conn_changed;
_E("Failed to register usb uevent: %d", ret);
/* register usbhost interface and method */
- ret = gdbus_add_object(NULL, DEVICED_PATH_USBHOST, &dbus_interface);
+ ret = gdbus_add_object(handle, DEVICED_PATH_USBHOST, &dbus_interface);
if (ret < 0)
_E("Failed to register dbus interface and method: %d", ret);
static void usb_host_test_init(void *data)
{
int ret;
+ dbus_handle_h handle = NULL;
- ret = gdbus_add_object(NULL, DEVICED_PATH_USB_HOST_TEST, &dbus_interface);
+ if (data)
+ handle = *(dbus_handle_h *)data;
+
+ ret = gdbus_add_object(handle, DEVICED_PATH_USB_HOST_TEST, &dbus_interface);
if (ret < 0) {
_E("Failed to register dbus method! %d", ret);
return;