#include <gio/gio.h>
#include <dlog.h>
#include <string.h>
+#include <syspopup_caller.h>
#include <vconf.h>
#include <bundle_internal.h>
#include "bt-service-network.h"
#include "bt-service-adapter.h"
#include "bt-service-gap-agent.h"
-#include "bt-service-pbap.h"
#define BT_SYSPOPUP_IPC_RESPONSE_OBJECT "/org/projectx/bt_syspopup_res"
#define BT_SYSPOPUP_INTERFACE "User.Bluetooth.syspopup"
#define BT_LE_CONN_PARAM_LOW_POWER_SLAVE_LATENCY 2 /* event */
#define PROFILE_SUPPORTED 0x3 /* This corresponds to binary 0b11*/
-#define PROFILE_TRUSTED 0x2 /* This corresponds to binary 0b10*/
-#define PROFILE_BLOCKED 0x1 /* This corresponds to binary 0b01*/
-#define PROFILE_SHOW_AUTH 0x0 /* This corresponds to binary 0b00*/
typedef struct {
int req_id;
static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
gpointer user_data);
-static int __bt_retry_bond(void);
-
-
/*static void __bt_decline_pair_request()
{
GVariant *out_param1;
BT_DBG("-");
} */
+#ifdef TIZEN_PROFILE_WEARABLE
+static gboolean __bt_syspopup_timer_cb(gpointer user_data)
+{
+ int ret;
+ bundle *b;
+ retv_if(user_data == NULL, FALSE);
+
+ b = (bundle *)user_data;
+
+ ret = syspopup_launch("bt-syspopup", b);
+ if (ret < 0) {
+ BT_ERR("Sorry!! Cannot launch popup return = %d, Retrying...", ret);
+ } else {
+ BT_DBG("Hurray!!! Finally Popup launched");
+ bundle_free(b);
+ }
+ return (ret < 0) ? TRUE : FALSE;
+}
+
+static gboolean __bt_launch_unable_to_pairing_syspopup(int result)
+{
+ BT_DBG("+");
+ int ret = 0;
+ bundle *b = NULL;
+ GDBusConnection *conn;
+
+ conn = _bt_gdbus_get_system_gconn();
+ if (conn == NULL)
+ return FALSE;
+
+ b = bundle_create();
+ if (b == NULL)
+ return FALSE;
+
+ bundle_add(b, "event-type", "unable-to-pairing");
+
+ if (result == BLUETOOTH_ERROR_TIMEOUT)
+ bundle_add(b, "error", "timeout");
+ else if (result == BLUETOOTH_ERROR_AUTHENTICATION_FAILED)
+ bundle_add(b, "error", "authfailed");
+ else
+ bundle_add(b, "error", "error");
+
+ ret = syspopup_launch("bt-syspopup", b);
+ if (0 > ret) {
+ BT_ERR("Popup launch failed...retry %d \n", ret);
+ g_timeout_add(200, (GSourceFunc) __bt_syspopup_timer_cb,
+ b);
+ } else {
+ bundle_free(b);
+ }
+
+ BT_DBG("-");
+ return TRUE;
+}
+#endif
+
gboolean _bt_is_device_creating(void)
{
return is_device_creating;
ret_if(value == NULL);
ret_if(info == NULL);
- gsize uuid_count = 0;
-
- info->uuids = g_variant_dup_strv(value, &uuid_count);
- info->uuid_count = (unsigned int)uuid_count;
-
- BT_DBG("uuid count : %d", uuid_count);
+ info->uuid_count = g_variant_get_size(value);
+ info->uuids = g_variant_dup_strv(value, &info->uuid_count);
}
bt_remote_dev_info_t *_bt_get_remote_device_info(char *address)
g_variant_unref(tmp_value);
}
- tmp_value = g_variant_lookup_value(value, "ManufacturerDataLen", G_VARIANT_TYPE_UINT16);
+ tmp_value = g_variant_lookup_value(value, "LegacyManufacturerDataLen", G_VARIANT_TYPE_UINT16);
if (tmp_value) {
dev_info->manufacturer_data_len = g_variant_get_uint16(tmp_value);
if (dev_info->manufacturer_data_len > BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX) {
} else
dev_info->manufacturer_data_len = 0;
- tmp_value = g_variant_lookup_value(value, "ManufacturerData", G_VARIANT_TYPE_ARRAY);
+ tmp_value = g_variant_lookup_value(value, "LegacyManufacturerData", G_VARIANT_TYPE_ARRAY);
if (tmp_value) {
if ((dev_info->manufacturer_data_len == 0) ||
dev_info->manufacturer_data_len != g_variant_get_size(tmp_value)) {
g_variant_get(tmp_value, "ay", &value_iter);
while (g_variant_iter_loop(value_iter, "y", &m_value))
dev_info->manufacturer_data[i++] = m_value;
+
+ g_variant_iter_free(value_iter);
}
g_variant_unref(tmp_value);
} else {
g_variant_get(tmp_value, "s", &address);
g_variant_unref(tmp_value);
- dev_info->address = g_strdup(address);
- dev_info->name = g_strdup(name);
- g_free(name);
+ dev_info->address = address;
+ dev_info->name = name;
g_variant_unref(value);
} else {
BT_ERR("result is NULL\n");
/* First Cancel the ongoing pairing in bluez otherwise if we send
* pair request bluez will send inprogress and we again retry bond so
* this cycle continues */
- GError *err = NULL;
- g_dbus_proxy_call_sync(bonding_info->device_proxy, "CancelPairing",
+ GError *err = NULL;
+ GVariant *result;
+ result = g_dbus_proxy_call_sync(bonding_info->device_proxy, "CancelPairing",
NULL, G_DBUS_CALL_FLAGS_NONE,
10000, NULL, &err);
- if (err) {
- BT_ERR("Cancelling bonding request error msg (%s)", err->message);
- g_clear_error(&err);
- return BLUETOOTH_ERROR_PARING_FAILED;
+ if (!result) {
+ if (err) {
+ BT_ERR("Cancelling bonding request error msg (%s)", err->message);
+ g_clear_error(&err);
+ return BLUETOOTH_ERROR_PARING_FAILED;
+ }
+ } else {
+ g_variant_unref(result);
}
return BLUETOOTH_ERROR_NONE;
}
-static int __bt_retry_bond(void)
-{
- BT_CHECK_PARAMETER(bonding_info, return);
- BT_CHECK_PARAMETER(bonding_info->addr, return);
-
- is_device_creating = TRUE;
-
- g_dbus_proxy_call(bonding_info->device_proxy, "Pair",
- g_variant_new("(y)", bonding_info->conn_type),
- G_DBUS_CALL_FLAGS_NONE,
- BT_MAX_DBUS_TIMEOUT,
- NULL,
- (GAsyncReadyCallback)__bt_bond_device_cb,
- NULL);
-
- return BLUETOOTH_ERROR_NONE;
-}
-
-
-static int __bt_remove_and_bond(void)
-{
- GDBusProxy *adapter_proxy;
- GVariant *result = NULL;
- GError *err = NULL;
- char *device_path = NULL;
-
- BT_CHECK_PARAMETER(bonding_info, return);
- BT_CHECK_PARAMETER(bonding_info->addr, return);
-
- adapter_proxy = _bt_get_adapter_proxy();
- retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- result = g_dbus_proxy_call_sync(adapter_proxy, "FindDevice",
- g_variant_new("(s)", bonding_info->addr),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- NULL);
- if (result == NULL)
- return BLUETOOTH_ERROR_INTERNAL;
-
- g_variant_get(result , "(o)", &device_path);
- g_variant_unref(result);
-
- retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- result = g_dbus_proxy_call_sync(adapter_proxy, "UnpairDevice",
- g_variant_new("(o)", device_path),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &err);
- g_free(device_path);
- if (err != NULL) {
- BT_ERR("UnpairDevice Fail: %s", err->message);
- g_error_free(err);
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- return __bt_retry_bond();
-}
-
-static int __bt_cancel_and_bond(void)
-{
- int ret = BLUETOOTH_ERROR_NONE;
-
- ret = _bt_agent_reply_cancellation();
- if (ret != BLUETOOTH_ERROR_NONE) {
- BT_ERR("Fail to call reply cancellation");
- return ret;
- }
- return __bt_retry_bond();
-}
-
-
static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
gpointer user_data)
{
GVariant *out_param1;
request_info_t *req_info;
bluetooth_device_info_t dev_info;
- bt_remote_dev_info_t *remote_dev_info;
- GVariant *manufacture_data;
- GVariant *param;
/* Terminate ALL system popup */
- if (headed_plugin_info->plugin_headed_enabled)
- headed_plugin_info->headed_plugin->bt_destroy_popup_all();
+ syspopup_destroy_all();
reply = g_dbus_proxy_call_finish(proxy, res, &err);
if (reply)
BT_ERR("Error occured in CreateBonding [%s]", err->message);
if (g_strrstr(err->message, "Already Exists")) {
- BT_INFO("Existing Bond, remove and retry");
- ret_if(__bt_remove_and_bond() == BLUETOOTH_ERROR_NONE);
-
- result = BLUETOOTH_ERROR_PARING_FAILED;
+ BT_INFO("Existing Bond");
+ result = BLUETOOTH_ERROR_ALREADY_CONNECT;
} else if (_bt_agent_is_canceled() ||
g_strrstr(err->message, "Authentication Canceled")) {
BT_INFO("Cancelled by USER");
BT_INFO("REJECTED");
result = BLUETOOTH_ERROR_ACCESS_DENIED;
} else if (g_strrstr(err->message, "In Progress")) {
- BT_INFO("Bond in progress, cancel and retry");
- ret_if(__bt_cancel_and_bond() == BLUETOOTH_ERROR_NONE);
-
- result = BLUETOOTH_ERROR_PARING_FAILED;
+ BT_INFO("Bond in progress");
+ result = BLUETOOTH_ERROR_IN_PROGRESS;
} else if (g_strrstr(err->message, "Authentication Failed")) {
BT_INFO("Authentication Failed");
if (bonding_info->is_autopair == TRUE) {
result == BLUETOOTH_ERROR_AUTHENTICATION_FAILED ||
result == BLUETOOTH_ERROR_TIMEOUT ||
result == BLUETOOTH_ERROR_HOST_DOWN) {
- if (TIZEN_PROFILE_WEARABLE) {
- int is_sw_running = 0;
+#ifdef TIZEN_PROFILE_WEARABLE
+ int is_sw_running = 0;
- if (vconf_get_int(VCONFKEY_SETUP_WIZARD_STATE, &is_sw_running))
- BT_ERR("vconf_get_int for setup wizard state failed");
+ if (vconf_get_int(VCONFKEY_SETUP_WIZARD_STATE, &is_sw_running))
+ BT_ERR("vconf_get_int for setup wizard state failed");
- if (!is_sw_running) {
- if (headed_plugin_info->plugin_headed_enabled)
- headed_plugin_info->headed_plugin->bt_launch_unable_to_pairing_syspopup(result);
- } else {
- BT_ERR("Unable to pair");
- }
- }
+ if (!is_sw_running)
+ __bt_launch_unable_to_pairing_syspopup(result);
+ else
+ BT_ERR("Unable to pair");
+#endif
bonding_info->result = result;
}
goto dbus_return;
}
- remote_dev_info = _bt_get_remote_device_info(bonding_info->addr);
- if (!remote_dev_info)
- goto dbus_return;
-
- GVariant *uuids = NULL;
- GVariantBuilder *builder = NULL;
- int i = 0;
- builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
- for (i = 0; i < remote_dev_info->uuid_count; i++) {
- g_variant_builder_add(builder, "s",
- remote_dev_info->uuids[i]);
- }
- uuids = g_variant_new("as", builder);
- g_variant_builder_unref(builder);
- manufacture_data = g_variant_new_from_data((const GVariantType *)"ay",
- remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
- TRUE, NULL, NULL);
-
- param = g_variant_new("(isunsbub@asn@ay)",
- result,
- bonding_info->addr,
- remote_dev_info->class,
- remote_dev_info->rssi,
- remote_dev_info->name,
- remote_dev_info->paired,
- remote_dev_info->connected,
- remote_dev_info->trust,
- uuids,
- remote_dev_info->manufacturer_data_len,
- manufacture_data);
-
-
- /* Send the event to application */
- _bt_send_event(BT_ADAPTER_EVENT,
- BLUETOOTH_EVENT_BONDING_FINISHED,
- param);
-
- _bt_free_device_info(remote_dev_info);
-
dbus_return:
if (req_info->context == NULL)
goto done;
g_dbus_method_invocation_return_value(req_info->context,
g_variant_new("(iv)", result, out_param1));
+ g_variant_unref(out_param1);
+
_bt_delete_request_list(req_info->req_id);
done:
if (err)
BT_DBG("uuid %s [%s]", uuid, _bt_convert_uuid_to_string(uuid));
object_path = _bt_get_device_object_path(address);
- if (!object_path) {
- BT_ERR("object_path is NULL");
- g_free(uuid);
- return BLUETOOTH_ERROR_NOT_PAIRED;
- }
-
+ retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
+ BT_DBG("object_path: %s", object_path);
device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
NULL, BT_BLUEZ_NAME,
object_path, BT_DEVICE_INTERFACE, NULL, NULL);
static gboolean __bt_connect_le_timer_cb(gpointer user_data)
{
- int ret;
-
BT_INFO("Try to initiate pending LE connection");
pending_le_conn_timer_id = 0;
- ret = __bt_connect_le_device_internal(pending_le_conn_info->req_id,
- &pending_le_conn_info->bd_addr,
- pending_le_conn_info->auto_connect);
- if (ret != BLUETOOTH_ERROR_NONE) {
- request_info_t *req_info = NULL;
- GVariant *out_param1;
-
- req_info = _bt_get_request_info(pending_le_conn_info->req_id);
- if (req_info == NULL) {
- BT_ERR("req_info is NULL");
- goto done;
- }
-
- if (req_info->context == NULL) {
- BT_ERR("req_info->context is NULL");
- _bt_delete_request_list(req_info->req_id);
- goto done;
- }
-
- out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
- &pending_le_conn_info->bd_addr,
- sizeof(bluetooth_device_address_t), TRUE,
- NULL, NULL);
+ __bt_connect_le_device_internal(pending_le_conn_info->req_id,
+ &pending_le_conn_info->bd_addr,
+ pending_le_conn_info->auto_connect);
- g_dbus_method_invocation_return_value(req_info->context,
- g_variant_new("(iv)", ret, out_param1));
- }
-
-done:
g_free(pending_le_conn_info);
pending_le_conn_info = NULL;
GDBusProxy *adapter_proxy;
GDBusConnection *conn;
int ret = BLUETOOTH_ERROR_NONE;
+ GVariant *result;
BT_CHECK_PARAMETER(bd_addr, return);
g_free(device_path);
retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- g_dbus_proxy_call_sync(device_proxy, "ConnectIpsp",
+ result = g_dbus_proxy_call_sync(device_proxy, "ConnectIpsp",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
- if (error) {
- BT_ERR("ConnectIpsp Call Error %s[%s]", error->message, device_address);
- g_error_free(error);
- g_object_unref(device_proxy);
- return BLUETOOTH_ERROR_INTERNAL;
+ if (!result) {
+ if (error) {
+ BT_ERR("ConnectIpsp Call Error %s[%s]", error->message, device_address);
+ g_error_free(error);
+ g_object_unref(device_proxy);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ } else {
+ g_variant_unref(result);
}
- g_object_unref(device_proxy);
-
- /* IPSP daemon launch */
- GDBusProxy *ipsp_proxy;
- ipsp_proxy = _bt_get_ipsp_proxy();
- retv_if(ipsp_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- g_dbus_proxy_call(ipsp_proxy, "EnableIpsp",
- NULL, G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, NULL, NULL);
+ g_object_unref(device_proxy);
return ret;
}
GDBusProxy *adapter_proxy;
GDBusConnection *conn;
int ret = BLUETOOTH_ERROR_NONE;
+ GVariant *result;
BT_CHECK_PARAMETER(bd_addr, return);
g_free(device_path);
retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- g_dbus_proxy_call_sync(device_proxy, "DisconnectIpsp",
+ result = g_dbus_proxy_call_sync(device_proxy, "DisconnectIpsp",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
- if (error) {
- BT_ERR("DisconnectIpsp Call Error %s[%s]", error->message, device_address);
- g_error_free(error);
- g_object_unref(device_proxy);
- return BLUETOOTH_ERROR_INTERNAL;
+ if (!result) {
+ if (error) {
+ BT_ERR("DisconnectIpsp Call Error %s[%s]", error->message, device_address);
+ g_error_free(error);
+ g_object_unref(device_proxy);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ } else {
+ g_variant_unref(result);
}
g_object_unref(device_proxy);
BT_CHECK_PARAMETER(device_address, return);
- BT_INFO("Sender %s, Min interval: %f, Max interval: %f, Latency: %u, Supervision timeout: %u",
+ BT_DBG("Sender %s, Min interval: %f, Max interval: %f, Latency: %u, Supervision timeout: %u",
sender, interval_min, interval_max, latency, time_out);
if (interval_min > interval_max ||
int _bt_get_trusted_profile_from_flag(bluetooth_trusted_profile_t profile,
guint trusted_profile_flag, guint *trusted)
{
- int trust_profile = FALSE;
+ int trust_profile;
*trusted = FALSE;
switch (profile) {
else
return BLUETOOTH_ERROR_NOT_SUPPORT;
break;
- case TRUSTED_PROFILE_HFP_HF: {
- guint flag = (trusted_profile_flag & (PROFILE_SUPPORTED << 6)) >> 6;
- BT_DBG("trusted_profile_flag %x", trusted_profile_flag);
- if (flag != PROFILE_BLOCKED)
- trust_profile = TRUE;
- else
- *trusted = FALSE;
- break;
- }
- case TRUSTED_PROFILE_A2DP: {
- guint flag = (trusted_profile_flag & (PROFILE_SUPPORTED << 8)) >> 8;
- BT_DBG("trusted_profile_flag %x", trusted_profile_flag);
- if (flag != PROFILE_BLOCKED)
- trust_profile = TRUE;
- else
- *trusted = FALSE;
- break;
- }
case TRUSTED_PROFILE_ALL: /* Return Flag for All profiles*/
*trusted = trusted_profile_flag;
return BLUETOOTH_ERROR_NONE;
return BLUETOOTH_ERROR_NONE;
}
+int _bt_get_restricted_profile_from_flag(bluetooth_restricted_profile_t profile,
+ guint restricted_profile_flag, guint *restricted)
+{
+ int restrict_profile;
+ *restricted = FALSE;
+
+ switch (profile) {
+ case RESTRICTED_PROFILE_HFP_HS:
+ restrict_profile = restricted_profile_flag & (1 << 0);
+ break;
+ case RESTRICTED_PROFILE_A2DP:
+ restrict_profile = restricted_profile_flag & (1 << 2);
+ break;
+ default:
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+ }
+
+ if (restrict_profile)
+ *restricted = TRUE;
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
char *_bt_get_trusted_profile_uuid(bluetooth_trusted_profile_t profile)
{
switch (profile) {
return g_strdup("00001134-0000-1000-8000-00805f9b34fb");
case TRUSTED_PROFILE_SAP:
return g_strdup("0000112D-0000-1000-8000-00805f9b34fb");
- case TRUSTED_PROFILE_HFP_HF:
- return g_strdup("0000111e-0000-1000-8000-00805f9b34fb");
- case TRUSTED_PROFILE_A2DP:
- return g_strdup("0000110b-0000-1000-8000-00805f9b34fb");
case TRUSTED_PROFILE_ALL:
return NULL;
}
return NULL;
}
+char *_bt_get_restricted_profile_uuid(bluetooth_restricted_profile_t profile)
+{
+ switch (profile) {
+ case RESTRICTED_PROFILE_HFP_HS:
+ return g_strdup("0000111e-0000-1000-8000-00805f9b34fb");
+ case RESTRICTED_PROFILE_A2DP:
+ return g_strdup("0000110b-0000-1000-8000-00805f9b34fb");
+ }
+
+ return NULL;
+}
+
bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid)
{
if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0)
return ret;
}
+int _bt_set_restrict_profile(bluetooth_device_address_t *bd_addr,
+ bluetooth_restricted_profile_t profile, gboolean restricted)
+{
+ int ret = BLUETOOTH_ERROR_NONE;
+ GDBusConnection *conn;
+ GDBusProxy *proxy;
+ GError *error = NULL;
+ char *device_path = NULL;
+ char *uuid = NULL;
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ GVariant *reply;
+
+ BT_CHECK_PARAMETER(bd_addr, return);
+ BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
+ bd_addr->addr[0], bd_addr->addr[1],
+ bd_addr->addr[2], bd_addr->addr[3],
+ bd_addr->addr[4], bd_addr->addr[5],
+ profile, restricted);
+
+ conn = _bt_gdbus_get_system_gconn();
+ retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ _bt_convert_addr_type_to_string(address, bd_addr->addr);
+
+ device_path = _bt_get_device_object_path(address);
+ retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_BLUEZ_NAME, device_path,
+ BT_DEVICE_INTERFACE, NULL, NULL);
+
+ g_free(device_path);
+ retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ uuid = _bt_get_restricted_profile_uuid(profile);
+ if (uuid == NULL) {
+ g_object_unref(proxy);
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+ }
+
+ reply = g_dbus_proxy_call_sync(proxy, "SetRestrictedProfile",
+ g_variant_new("(sb)", uuid, restricted),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, &error);
+ g_object_unref(proxy);
+
+ if (reply == NULL) {
+ BT_ERR("Failed to Set Profile Restricted");
+ ret = BLUETOOTH_ERROR_INTERNAL;
+ if (error) {
+ BT_ERR("Error %s[%s]", error->message, address);
+ g_error_free(error);
+ }
+ goto finish;
+ }
+ g_variant_unref(reply);
+
+finish:
+ g_free(uuid);
+ return ret;
+}
+
+int _bt_get_restrict_profile(bluetooth_device_address_t *bd_addr,
+ bluetooth_restricted_profile_t profile, guint *restricted)
+{
+ int ret = BLUETOOTH_ERROR_NONE;
+ GDBusConnection *conn;
+ GDBusProxy *proxy;
+ GError *error = NULL;
+ char *device_path = NULL;
+ guint restricted_profile_flag;
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ GVariant *reply;
+
+ BT_CHECK_PARAMETER(bd_addr, return);
+ BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
+ bd_addr->addr[0], bd_addr->addr[1],
+ bd_addr->addr[2], bd_addr->addr[3],
+ bd_addr->addr[4], bd_addr->addr[5],
+ profile, *restricted);
+
+ conn = _bt_gdbus_get_system_gconn();
+ retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ _bt_convert_addr_type_to_string(address, bd_addr->addr);
+
+ device_path = _bt_get_device_object_path(address);
+ retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_BLUEZ_NAME, device_path,
+ BT_PROPERTIES_INTERFACE, NULL, NULL);
+
+ g_free(device_path);
+ retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ reply = g_dbus_proxy_call_sync(proxy, "Get",
+ g_variant_new("(ss)", BT_DEVICE_INTERFACE, "RestrictedProfiles"),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, &error);
+ g_object_unref(proxy);
+
+ if (reply == NULL) {
+ BT_ERR("Failed to Get Profile Restricted");
+ ret = BLUETOOTH_ERROR_INTERNAL;
+ if (error) {
+ BT_ERR("Error %s[%s]", error->message, address);
+ g_error_free(error);
+ }
+ *restricted = 0;
+ } else {
+ GVariant *temp;
+ g_variant_get(reply, "(v)", &temp);
+ restricted_profile_flag = g_variant_get_uint32(temp);
+ BT_DBG("Restricted_FLAG %d", restricted_profile_flag);
+
+ ret = _bt_get_restricted_profile_from_flag(profile,
+ restricted_profile_flag, restricted);
+ g_variant_unref(temp);
+ g_variant_unref(reply);
+ }
+
+ BT_DBG("TRUST %d", *restricted);
+ return ret;
+}
+
static void __bt_request_att_mtu_device_cb(GDBusProxy *proxy, GAsyncResult *res,
gpointer user_data)
{
BT_DBG("ATT MTU : %d", *mtu);
g_variant_unref(value);
g_variant_unref(result);
+
+ if (*mtu == 0) {
+ g_object_unref(device_proxy);
+ return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
}
g_object_unref(device_proxy);
retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
- NULL, BT_BLUEZ_NAME,
- device_path, BT_DEVICE_INTERFACE, NULL, NULL);
+ NULL, BT_BLUEZ_NAME,
+ device_path, BT_DEVICE_INTERFACE, NULL, NULL);
g_free(device_path);
if (!device_proxy) {
BT_ERR("Unable to get proxy");
return BLUETOOTH_ERROR_INTERNAL;
}
- result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress",
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
+ result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (result == NULL) {
BT_ERR("Failed to get device ID address");
+
+ ret = BLUETOOTH_ERROR_INTERNAL;
if (error != NULL) {
- BT_ERR("Error occured in Proxy call [%s]\n", error->message);
+ g_dbus_error_strip_remote_error(error);
+ BT_ERR("Error occured in Proxy call [%s]", error->message);
+ if (g_strcmp0(error->message, "Does Not Exist") == 0)
+ ret = BLUETOOTH_ERROR_NOT_PAIRED;
g_error_free(error);
}
g_object_unref(device_proxy);
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- g_variant_get(result , "(s)", &idaddress);
- g_variant_unref(result);
-
- if (idaddress == NULL) {
- BT_ERR("No paired device");
- g_object_unref(device_proxy);
- return BLUETOOTH_ERROR_NOT_PAIRED;
+ return ret;
}
- BT_DBG("ID Address:%s", idaddress);
+ g_variant_get(result , "(&s)", &idaddress);
- if (idaddress)
- _bt_convert_addr_string_to_type(id_address->addr, idaddress);
- else
- ret = BLUETOOTH_ERROR_INTERNAL;
+ DBG_SECURE("ID Address : %s", idaddress);
+ _bt_convert_addr_string_to_type(id_address->addr, idaddress);
+ g_variant_unref(result);
g_object_unref(device_proxy);
return ret;