ENDIF()
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED hal-backend-device-common)
+pkg_check_modules(pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION ${HAL_LICENSE_DIR}/${PROJECT_NAME})
ADD_SUBDIRECTORY(hw/battery)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-battery_pkgs REQUIRED hal-backend-device-common glib-2.0 gio-2.0 libsyscommon)
+pkg_check_modules(hal-backend-device-battery_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-battery_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE battery.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE battery.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-battery_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
#include <hal/hal-device-battery-interface.h>
#include <hal/hal-common-interface.h>
-#include <libsyscommon/file.h>
-#include <libsyscommon/libgdbus.h>
-
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#define BATTERY_BUS "org.tizen.system.deviced"
#define BATTERY_OBJECT "/Org/Tizen/System/DeviceD/SysNoti"
} sdata = { 0, };
static guint signal_id; /* signal handler id */
+static dbus_handle_s *dh;
static int get_power_source(int online, hal_device_battery_power_source_type_e *src)
{
return -EEXIST;
}
- signal_id = gdbus_signal_subscribe(NULL, BATTERY_OBJECT,
- BATTERY_IFACE, BATTERY_SIGNAL,
- signal_delivered, &sdata, NULL);
+ if (!dh) {
+ dh = (dbus_handle_s*)dbus_get_default_connection();
+ if (!dh) {
+ _E("failed to get default connection, bustype:%d", (int)dbus_get_default_bus_type());
+ return -EPERM;
+ }
+ }
+
+ if (!dh->conn) {
+ _E("connection is null. check bus status");
+ return -EPERM;
+ }
+
+ signal_id = g_dbus_connection_signal_subscribe(dh->conn, NULL, BATTERY_IFACE, BATTERY_SIGNAL, BATTERY_OBJECT, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, signal_delivered, &sdata, NULL);
+
if (signal_id <= 0) {
_E("Failed to register signal");
return -ENOMEM;
hal_device_battery_updated_cb updated_cb)
{
if (signal_id > 0) {
- gdbus_signal_unsubscribe(NULL, signal_id);
+ if (!dh) {
+ dh = (dbus_handle_s*)dbus_get_default_connection();
+ if (!dh) {
+ _E("failed to get default connection, bustype:%d", (int)dbus_get_default_bus_type());
+ return;
+ }
+ }
+
+ if (!dh->conn) {
+ _E("connection is null. check bus status");
+ return;
+ }
+
+ g_dbus_connection_signal_unsubscribe(dh->conn, signal_id);
signal_id = 0;
}
sdata.updated_cb = NULL;
info.name = BATTERY_HARDWARE_DEVICE_ID;
- ret = sys_get_str(FILE_BATTERY_CAPACITY, capacity_str, sizeof(capacity_str));
+ ret = sysfs_read_str(FILE_BATTERY_CAPACITY, capacity_str, sizeof(capacity_str));
if (ret < 0) {
_E("Failed to get value of (%s, %d)", FILE_BATTERY_CAPACITY, ret);
return ret;
it sometimes returns an empty string. */
if (capacity_str[0] == 0) {
_E("/sys/class/power_supply/battery/capacity returns null string, retry read it again");
- ret = sys_get_str(FILE_BATTERY_CAPACITY, capacity_str, sizeof(capacity_str));
+ ret = sysfs_read_str(FILE_BATTERY_CAPACITY, capacity_str, sizeof(capacity_str));
if (ret < 0) {
_E("Failed to get value of (%s, %d)", FILE_BATTERY_CAPACITY, ret);
return ret;
}
}
- ret = sys_get_str(FILE_BATTERY_CHARGER_ONLINE, charger_str, sizeof(charger_str));
+ ret = sysfs_read_str(FILE_BATTERY_CHARGER_ONLINE, charger_str, sizeof(charger_str));
if (ret < 0) {
_E("Failed to get value of (%s, %d)", FILE_BATTERY_CHARGER_ONLINE, ret);
return ret;
}
- ret = sys_get_str(FILE_BATTERY_CHARGE_FULL, charge_full_str, sizeof(charge_full_str));
+ ret = sysfs_read_str(FILE_BATTERY_CHARGE_FULL, charge_full_str, sizeof(charge_full_str));
if (ret < 0) {
_E("Failed to get value of (%s, %d)", FILE_BATTERY_CHARGE_FULL, ret);
return ret;
}
- ret = sys_get_str(FILE_BATTERY_CHARGE_NOW, charge_now_str, sizeof(charge_now_str));
+ ret = sysfs_read_str(FILE_BATTERY_CHARGE_NOW, charge_now_str, sizeof(charge_now_str));
if (ret < 0) {
_E("Failed to get value of (%s, %d)", FILE_BATTERY_CHARGE_NOW, ret);
return ret;
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-display_pkgs REQUIRED hal-backend-device-common libsyscommon)
+pkg_check_modules(hal-backend-device-display_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${display_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE display.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE display.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-display_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
#include <hal/hal-device-display-interface.h>
#include <hal/hal-common-interface.h>
-#include <libsyscommon/file.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#ifndef BACKLIGHT_PATH
#define BACKLIGHT_PATH "/sys/class/backlight/emulator"
return -EINVAL;
if (max < 0) {
- r = sys_get_int(BACKLIGHT_PATH"/max_brightness", &max);
+ r = sysfs_read_int(BACKLIGHT_PATH"/max_brightness", &max);
if (r < 0)
return r;
}
return -EINVAL;
}
- r = sys_get_int(BACKLIGHT_PATH"/brightness", &v);
+ r = sysfs_read_int(BACKLIGHT_PATH"/brightness", &v);
if (r < 0) {
_E("fail to get brightness (errno:%d)", r);
return r;
return -EINVAL;
}
- r = sys_set_int(BACKLIGHT_PATH"/brightness", brightness);
+ r = sysfs_write_int(BACKLIGHT_PATH"/brightness", brightness);
if (r < 0) {
_E("fail to set brightness (errno:%d)", r);
return r;
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-external-connection_pkgs REQUIRED hal-backend-device-common glib-2.0 gio-2.0 libsyscommon)
+pkg_check_modules(hal-backend-device-external-connection_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-external-connection_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE external_connection.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE external_connection.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-external-connection_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
#include <hal/hal-device-external_connection-interface.h>
#include <hal/hal-common-interface.h>
-#include <libsyscommon/file.h>
-#include <libsyscommon/libgdbus.h>
-
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
void *data;
} sdata = { 0, };
+static dbus_handle_s *dh;
+
static void signal_delivered(GDBusConnection *conn,
const gchar *sender,
const gchar *object,
return -EEXIST;
}
- signal_id = gdbus_signal_subscribe(NULL, EXTCON_OBJECT,
- EXTCON_IFACE, EXTCON_SIGNAL,
- signal_delivered, &sdata, NULL);
+ if (!dh) {
+ dh = (dbus_handle_s*)dbus_get_default_connection();
+ if (!dh) {
+ _E("failed to get default connection, bustype:%d", (int)dbus_get_default_bus_type());
+ return -EPERM;
+ }
+ }
+
+ if (!dh->conn) {
+ _E("connection is null. check bus status");
+ return -EPERM;
+ }
+
+ signal_id = g_dbus_connection_signal_subscribe(dh->conn, NULL, EXTCON_IFACE, EXTCON_SIGNAL, EXTCON_OBJECT, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, signal_delivered, &sdata, NULL);
+
if (signal_id <= 0) {
_E("Failed to register signal");
return -ENOMEM;
hal_device_external_connection_updated_cb updated_cb)
{
if (signal_id > 0) {
- gdbus_signal_unsubscribe(NULL, signal_id);
+ if (!dh) {
+ dh = (dbus_handle_s*)dbus_get_default_connection();
+ if (!dh) {
+ _E("failed to get default connection, bustype:%d", (int)dbus_get_default_bus_type());
+ return;
+ }
+ }
+
+ if (!dh->conn) {
+ _E("connection is null. check bus status");
+ return;
+ }
+
+ g_dbus_connection_signal_unsubscribe(dh->conn, signal_id);
signal_id = 0;
}
sdata.updated_cb = NULL;
return -EINVAL;
for (i = 0 ; i < ARRAY_SIZE(extcon_devices) ; i++) {
- ret = sys_get_int(extcon_devices[i].path, &val);
+ ret = sysfs_read_int(extcon_devices[i].path, &val);
if (ret < 0) {
_E("Failed to get value of (%s, ret:%d)",
extcon_devices[i].path, ret);
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(haptic_pkgs REQUIRED
- hal-backend-device-common
- glib-2.0
- libsyscommon
- capi-system-info)
+pkg_check_modules(haptic_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${haptic_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE emulator.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE emulator.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${haptic_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
#include <errno.h>
#include <stdbool.h>
#include <system_info.h>
-#include <libsyscommon/list.h>
#include <hal/hal-device-haptic-interface.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
static GList *handle_list;
static int unique_number = 0;
while (found != true) {
++unique_number;
- elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = g_list_find(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
handle = unique_number;
- SYS_G_LIST_APPEND(handle_list, (gpointer)(long)handle);
+ handle_list = g_list_append(handle_list, (gpointer)(long)handle);
if (device_handle)
*device_handle = handle;
static int close_device(int device_handle)
{
- SYS_G_LIST_REMOVE(handle_list, (gpointer)(long)device_handle);
+ handle_list = g_list_remove(handle_list, (gpointer)(long)device_handle);
return 0;
}
{
GList *elem;
- elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)device_handle);
+ elem = g_list_find(handle_list, (gpointer)(long)device_handle);
if (!elem)
return -EINVAL;
{
GList *elem;
- elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)device_handle);
+ elem = g_list_find(handle_list, (gpointer)(long)device_handle);
if (!elem)
return -EINVAL;
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-memory_pkgs REQUIRED dlog)
+pkg_check_modules(hal-backend-device-memory_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-memory_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE memory.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE memory.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-memory_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
#include <hal/hal-device-memory-interface.h>
#include <hal/hal-common-interface.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
static int memory_get_gpu_info(const int pid, hal_device_memory_gpu_info_s *info)
{
--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <assert.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-unix.h>
+#include <gio/gunixfdlist.h>
+#include <stdarg.h>
+
+#ifdef FEATURE_DLOG
+ #define LOG_TAG "HAL_BACKEND_DEVICE_EMULATOR"
+ #include <dlog.h>
+ #define _D(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args)
+ #define _I(fmt, args...) dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args)
+ #define _W(fmt, args...) dlog_print(DLOG_WARN, LOG_TAG, fmt, ##args)
+ #define _E(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args)
+#else
+ #define _D(x, ...)
+ #define _I(x, ...)
+ #define _W(x, ...)
+ #define _E(x, ...)
+#endif
+
+#define EXPORT __attribute__ ((visibility("default")))
+
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#define MAX_BUF_SIZE 255
+
+typedef struct {
+ GDBusConnection *conn;
+ GBusType bus_type;
+ gboolean priv;
+ GList *list_names; /* dbus_name */
+ GList *list_object; /* dbus_object_handle_s */
+ pthread_mutex_t mutex;
+} dbus_handle_s;
+
+int sysfs_read_int(char *path, int *val);
+int sysfs_read_str(char *path, char *str, int len);
+int sysfs_write_int(char *path, int val);
+int sysfs_write_str(char *path, char *str);
+dbus_handle_s * dbus_get_default_connection(void);
+GBusType dbus_get_default_bus_type(void);
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(hal-api-common)
-BuildRequires: pkgconfig(hal-api-device)
-BuildRequires: pkgconfig(libsyscommon)
-BuildRequires: pkgconfig(capi-system-info)
-BuildRequires: pkgconfig(hal-backend-device-common)
+BuildRequires: pkgconfig(hal-rootstrap)
%description
Device HAL backend drivers for emulator targets
--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "util.h"
+
+static GBusType g_default_bus_type = G_BUS_TYPE_SYSTEM;
+pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
+/* global shared bus : system, session */
+static dbus_handle_s g_dh[2];
+
+#define dbus_lock(handle) do {\
+ assert(handle);\
+ pthread_mutex_lock(&((handle)->mutex));\
+} while (0);
+
+#define dbus_unlock(handle) do {\
+ assert(handle);\
+ pthread_mutex_unlock(&(handle)->mutex);\
+} while (0);
+
+static int sysfs_read_buf(char *path, char *buf, int len)
+{
+ int r, fd;
+
+ if ((!path) || (!buf) || (len < 0))
+ return -EINVAL;
+
+ fd = open(path, O_RDONLY);
+ if (fd == -1)
+ return -ENOENT;
+
+ r = read(fd, buf, len);
+ close(fd);
+
+ if ((r < 0) || (r > len))
+ return -EIO;
+
+ /* Replace '\n' with space (ascii code is 32) */
+ buf[strcspn(buf, "\n")] = (char)32;
+ buf[r] = '\0';
+
+ return 0;
+}
+
+static int sysfs_write_buf(char *path, char *buf)
+{
+ int w, fd;
+
+ if ((!path) || (!buf))
+ return -EINVAL;
+
+ fd = open(path, O_WRONLY);
+ if (fd == -1)
+ return -ENOENT;
+
+ w = write(fd, buf, strlen(buf));
+ close(fd);
+
+ if (w < 0)
+ return -EIO;
+
+ return 0;
+}
+
+int sysfs_read_int(char *path, int *val)
+{
+ char buf[MAX_BUF_SIZE + 1];
+ int r;
+
+ if ((!path) || (!val))
+ return -EINVAL;
+
+ r = sysfs_read_buf(path, buf, MAX_BUF_SIZE);
+ if (r < 0)
+ return r;
+
+ *val = atoi(buf);
+ return 0;
+}
+
+int sysfs_read_str(char *path, char *str, int len)
+{
+ int r;
+
+ if ((!path) || (!str) || (len <= 0))
+ return -EINVAL;
+
+ r = sysfs_read_buf(path, str, len);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
+int sysfs_write_int(char *path, int val)
+{
+ char buf[MAX_BUF_SIZE + 1];
+ int w;
+
+ if (!path)
+ return -EINVAL;
+
+ snprintf(buf, MAX_BUF_SIZE, "%d", val);
+ w = sysfs_write_buf(path, buf);
+ if (w < 0)
+ return w;
+
+ return 0;
+}
+
+int sysfs_write_str(char *path, char *str)
+{
+ int w;
+
+ if ((!path) || (!str))
+ return -EINVAL;
+
+ w = sysfs_write_buf(path, str);
+ if (w < 0)
+ return w;
+
+ return 0;
+}
+
+static GDBusConnection * _get_bus(GBusType bus_type)
+{
+ GDBusConnection *conn = NULL;
+ GError *err = NULL;
+
+ if (bus_type != G_BUS_TYPE_SYSTEM && bus_type != G_BUS_TYPE_SESSION) {
+ _E("Wrong bus_type %d", bus_type);
+ return NULL;
+ }
+
+ conn = g_bus_get_sync(bus_type, NULL, &err);
+ if (!conn || err) {
+ _E("failed to get bus:type:%d, %s\n", bus_type, err->message);
+ g_error_free(err);
+ return NULL;
+ }
+
+ return conn;
+}
+
+/* ref cout is 1 */
+static dbus_handle_s *_dbus_get_connection(GBusType bus_type)
+{
+ int ibus = bus_type - 1;
+ dbus_handle_s *dh = NULL;
+
+ if (bus_type != G_BUS_TYPE_SYSTEM && bus_type != G_BUS_TYPE_SESSION) {
+ _E("Unknown bus type %d", bus_type);
+ return NULL;
+ }
+ dh = &g_dh[ibus];
+
+ dbus_lock(dh);
+
+ if (!dh->conn) {
+ dh->conn = _get_bus(bus_type);
+ if (!dh->conn) {
+ dbus_unlock(dh);
+ return NULL;
+ }
+ dh->priv = FALSE;
+ dh->bus_type = bus_type;
+ }
+
+ dbus_unlock(dh);
+
+ return dh;
+}
+
+GBusType dbus_get_default_bus_type(void)
+{
+ GBusType type;
+
+ pthread_mutex_lock(&g_mutex);
+ type = g_default_bus_type;
+ pthread_mutex_unlock(&g_mutex);
+
+ return type;
+}
+
+dbus_handle_s* dbus_get_default_connection(void)
+{
+ return _dbus_get_connection(dbus_get_default_bus_type());
+}
\ No newline at end of file