extern guint nap_connected_device_count;
-static char *passkey_watcher = NULL;
+static char *passkey_watcher;
#define G_VARIANT_UNREF(variant) \
g_variant_unref(variant); \
return _bt_is_headset_type_connected(BT_AUDIO_A2DP, NULL);
}
+static gboolean __bt_agent_is_hid_device_connectable(void)
+{
+ GDBusProxy *proxy = NULL;
+ GVariant *reply = NULL;
+ GError *err = NULL;
+ gboolean connectable = FALSE;
+
+ proxy = _bt_gdbus_get_hid_agent_proxy();
+ retv_if(proxy == NULL, FALSE);
+
+ reply = g_dbus_proxy_call_sync(proxy, "IsHidConnectable", NULL,
+ G_DBUS_CALL_FLAGS_NONE, 2000, NULL, &err);
+ if (reply == NULL) {
+ BT_ERR("Error returned in method call");
+ if (err != NULL) {
+ BT_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);
+
+ BT_INFO("HID Device is %s",
+ connectable ? "Connectable" : "Non-connectable");
+
+ return connectable;
+}
+
static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device,
const char *uuid)
{
}
/* Check completed */
+ if (!strcasecmp(uuid, HID_UUID)) {
+ gboolean is_connectable = __bt_agent_is_hid_device_connectable();
+ BT_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, HFP_AUDIO_GATEWAY_UUID) ||
!strcasecmp(uuid, HSP_AUDIO_GATEWAY_UUID) ||
!strcasecmp(uuid, HFP_HS_UUID) ||
!strcasecmp(uuid, HSP_HS_UUID) ||
!strcasecmp(uuid, A2DP_UUID) ||
- !strcasecmp(uuid, HID_UUID) ||
!strcasecmp(uuid, HID_DEVICE_UUID) ||
!strcasecmp(uuid, SAP_UUID_OLD) ||
!strcasecmp(uuid, SAP_UUID_NEW) ||
return BLUETOOTH_ERROR_NONE;
}
+