return BT_STATUS_PARM_INVALID;
}
- DBG("Set authotrize [%d]", authorize);
+ DBG("Set authorize [%d]", authorize);
result = g_dbus_proxy_call_sync(device_proxy, "Set",
g_variant_new("(ssv)", BT_HAL_DEVICE_INTERFACE, "Trusted", g_variant_new("b", authorize)),
G_DBUS_CALL_FLAGS_NONE,
return NULL;
}
+bt_trusted_profile_t _bt_hal_get_trusted_profile_enum(const char *uuid)
+{
+ if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0)
+ return BT_TRUSTED_PROFILE_PBAP;
+ else if (g_strcmp0("00001132-0000-1000-8000-00805f9b34fb", uuid) == 0)
+ return BT_TRUSTED_PROFILE_MAP;
+ else if (g_strcmp0("0000112D-0000-1000-8000-00805f9b34fb", uuid) == 0)
+ return BT_TRUSTED_PROFILE_SAP;
+
+ return 0; /* 0 - Unknown Profile */
+}
+
int _bt_hal_device_set_trusted_profile(const bt_bdaddr_t *bd_addr,
bt_trusted_profile_t profile, uint8_t trust)
{
int _bt_hal_device_register_osp_server(uint32_t type, char *uuid, char *path, int fd);
int _bt_hal_device_unregister_osp_server(uint32_t type, char *uuid);
+bt_trusted_profile_t _bt_hal_get_trusted_profile_enum(const char *uuid);
+
int _bt_hal_device_set_trusted_profile(const bt_bdaddr_t *bd_addr,
bt_trusted_profile_t profile, uint8_t trust);
#include <dlog.h>
#include "bt-hal-adapter-dbus-handler.h"
+#include "bt-hal-device-dbus-handler.h"
#include "bt-hal-dbus-common-utils.h"
static GDBusConnection *connection = NULL;
priv->exec_type = GAP_AGENT_EXEC_AUTHORZATION;
priv->reply_context = invocation;
+ priv->uuid = g_strdup(uuid);
addr = strstr(path, "dev_");
if (addr != NULL) {
if (accept == GAP_AGENT_ACCEPT) {
g_dbus_method_invocation_return_value(priv->reply_context, NULL);
} else if (accept == GAP_AGENT_ACCEPT_ALWAYS) {
- /* TODO: Enable below logic after set authorization API implementation */
+ bluetooth_device_address_t addr = { { 0, } };
+ int result;
+ bt_trusted_profile_t profile;
+
+ _bt_hal_convert_addr_string_to_type(addr.addr,
+ priv->authorize_addr);
+
+ profile = _bt_hal_get_trusted_profile_enum(priv->uuid);
+
+ if (profile)
+ result = _bt_hal_device_set_trusted_profile((bt_bdaddr_t *)(&addr), profile, TRUE);
+ else
+ result = _bt_hal_device_set_trust((bt_bdaddr_t *)(&addr), TRUE);
+
+ if (result == BT_STATUS_SUCCESS) {
+ INFO("[%s] Profile added as trusted for Device[%s]",
+ priv->uuid, priv->authorize_addr);
+ }
+
g_dbus_method_invocation_return_value(priv->reply_context, NULL);
} else {
switch (accept) {
priv->reply_context = NULL;
memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+ if (priv->uuid) {
+ g_free(priv->uuid);
+ priv->uuid = NULL;
+ }
return ret;
}