static inline void stack_trim(void);
static gboolean __bt_hal_device_is_hid_keyboard(unsigned int dev_class);
+static gboolean __bt_hal_is_hid_device_connectable(void);
static int __bt_hal_device_generate_passkey(char *passkey, int size);
static gboolean __bt_hal_device_is_auto_response(uint32_t dev_class,
const gchar *address, const gchar *name);
INFO("Device is not Trusted, so prompt user to accept or reject authorization \n");
}
+ if (!strcasecmp(uuid, BT_HAL_HID_UUID)) {
+ gboolean is_connectable = __bt_hal_is_hid_device_connectable();
+ DBG("Automatically %s authorization for HID",
+ is_connectable ? "accept" : "reject");
+ if (is_connectable == TRUE)
+ gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT, NULL);
+ else
+ gap_agent_reply_authorize(agent, GAP_AGENT_REJECT, NULL);
+ goto done;
+ }
+
if (!strcasecmp(uuid, BT_HAL_HFP_AUDIO_GATEWAY_UUID) ||
!strcasecmp(uuid, BT_HAL_HSP_AUDIO_GATEWAY_UUID) ||
!strcasecmp(uuid, BT_HAL_HFP_HF_UUID) ||
!strcasecmp(uuid, BT_HAL_HSP_HS_UUID) ||
!strcasecmp(uuid, BT_HAL_A2DP_PROFILE_UUID) ||
- !strcasecmp(uuid, BT_HAL_HID_UUID) ||
!strcasecmp(uuid, BT_HAL_HID_DEVICE_UUID) ||
!strcasecmp(uuid, BT_HAL_SAP_UUID_OLD) ||
!strcasecmp(uuid, BT_HAL_SAP_UUID_NEW) ||
return FALSE;
}
+static gboolean __bt_hal_is_hid_device_connectable(void)
+{
+ GDBusProxy *proxy = NULL;
+ GVariant *reply = NULL;
+ GError *err = NULL;
+ gboolean connectable = FALSE;
+
+ proxy = _bt_hal_get_hid_agent_proxy();
+ if(proxy == NULL)
+ return FALSE;
+
+ reply = g_dbus_proxy_call_sync(proxy, "IsHidConnectable", NULL,
+ G_DBUS_CALL_FLAGS_NONE, 2000, NULL, &err);
+ if (reply == NULL) {
+ ERR("Error returned in method call");
+ if (err != NULL) {
+ ERR("Error message = %s", err->message);
+ g_error_free(err);
+ }
+ connectable = FALSE;
+ } else {
+ g_variant_get(reply, "(b)", &connectable);
+ g_variant_unref(reply);
+ }
+ g_object_unref(proxy);
+
+ INFO("HID Device is %s",
+ connectable ? "Connectable" : "Non-connectable");
+
+ return connectable;
+}
+
static int __bt_hal_device_generate_passkey(char *passkey, int size)
{
int i;
struct avrcp_proxy proxy_array[BT_AUDIO_SOURCE_MAX];
-static GDBusConnection *system_gconn = NULL;
-
static guint bus_id;
GDBusNodeInfo *new_conn_node;
static const gchar rfcomm_agent_xml[] =
" </interface>"
"</node>";
-GDBusConnection *_bt_hal_gdbus_init_system_gconn(void)
+static GDBusConnection *__bt_hal_init_session_conn(void)
+{
+ if (session_conn == NULL)
+ session_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
+
+ return session_conn;
+}
+
+GDBusConnection *_bt_hal_get_session_gconn(void)
+{
+ return (session_conn) ? session_conn : __bt_hal_init_session_conn();
+}
+
+static GDBusConnection *__bt_hal_init_system_gconn(void)
{
GError *error = NULL;
- if (system_gconn != NULL)
- return system_gconn;
+ if (system_conn != NULL)
+ return system_conn;
- system_gconn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (!system_gconn) {
+ if (!system_conn) {
ERR("Unable to connect to dbus: %s", error->message);
g_clear_error(&error);
}
- return system_gconn;
+ return system_conn;
}
-GDBusConnection *_bt_hal_gdbus_get_system_gconn(void)
+GDBusConnection *_bt_hal_get_system_gconn(void)
{
GDBusConnection *local_system_gconn = NULL;
GError *error = NULL;
- if (system_gconn == NULL) {
- system_gconn = _bt_hal_gdbus_init_system_gconn();
- } else if (g_dbus_connection_is_closed(system_gconn)) {
+ if (system_conn == NULL) {
+ system_conn = __bt_hal_init_system_gconn();
+ } else if (g_dbus_connection_is_closed(system_conn)) {
local_system_gconn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
g_clear_error(&error);
}
- system_gconn = local_system_gconn;
+ system_conn = local_system_gconn;
}
- return system_gconn;
+ return system_conn;
}
static GDBusProxy *__bt_hal_init_manager_proxy(void)
return transport_path;
}
-static GDBusConnection *__bt_hal_init_system_gconn(void)
-{
- if (system_conn == NULL)
- system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
-
- return system_conn;
-}
-
static GDBusProxy *__bt_hal_init_avrcp_ctrl_proxy(bt_bdaddr_t *bd_addr)
{
GDBusProxy *manager_proxy;
GDBusConnection *gconn = NULL;
int i;
- gconn = _bt_hal_gdbus_get_system_gconn();
+ gconn = _bt_hal_get_system_gconn();
if (gconn == NULL)
return NULL;
return proxy;
}
-static GDBusConnection *__bt_hal_init_session_conn(void)
-{
- if (session_conn == NULL)
- session_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
-
- return session_conn;
-}
-
-GDBusConnection *_bt_hal_get_session_gconn(void)
-{
- return (session_conn) ? session_conn : __bt_hal_init_session_conn();
-}
-
-GDBusConnection *_bt_hal_get_system_gconn(void)
-{
- return (system_conn) ? system_conn : __bt_hal_init_system_gconn();
-}
-
GDBusProxy *_bt_hal_get_manager_proxy(void)
{
DBG("+");
}
}
+GDBusProxy *_bt_hal_get_hid_agent_proxy(void)
+{
+ GDBusConnection *conn;
+ GDBusProxy *proxy;
+ GError *err = NULL;
+
+ conn = _bt_hal_get_system_gconn();
+ if (conn == NULL) {
+ ERR("_bt_hal_get_system_gconn failed");
+ return NULL;
+ }
+
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ BT_HAL_HID_SERVICE_NAME, BT_HAL_HID_AGENT_OBJECT_PATH,
+ BT_HAL_HID_SERVICE_INTERFACE, NULL, &err);
+ if (proxy == NULL) {
+ if (err != NULL) {
+ ERR("Unable to create proxy: %s", err->message);
+ g_clear_error(&err);
+ }
+ return NULL;
+ }
+
+ return proxy;
+}
+
void _bt_hal_convert_device_path_to_address(const char *device_path,
char *device_address)
{
#define BT_HAL_NAME_OWNER_CHANGED "NameOwnerChanged"
#define BT_HAL_PROPERTIES_CHANGED "PropertiesChanged"
+#define BT_HAL_HID_SERVICE_NAME "org.bluez.hid_agent"
+#define BT_HAL_HID_AGENT_OBJECT_PATH "/org/bluez/hid_agent"
+#define BT_HAL_HID_SERVICE_INTERFACE "org.tizen.HidApp"
+
/**
* This is Bluetooth error code
*/
gboolean _bt_hal_is_adapter_powered(gboolean *powered);
char *_bt_hal_get_device_object_path(char *address);
- void _bt_hal_convert_device_path_to_address(const char *device_path, char *device_address);
+ GDBusProxy *_bt_hal_get_hid_agent_proxy(void);
+
+ void _bt_hal_convert_device_path_to_address(const char *device_path, char *device_address);
void _bt_hal_convert_addr_string_to_type(unsigned char *addr, const char *address);
void _bt_hal_convert_addr_type_to_string(char *address, const unsigned char *addr);
void _bt_hal_convert_uuid_string_to_type(unsigned char *uuid, const char *device_uuid);