summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyuk Lee <hyuk0512.lee@samsung.com>2016-09-07 14:48:57 +0900
committerHyuk Lee <hyuk0512.lee@samsung.com>2016-09-07 14:48:57 +0900
commit907c83b3d5258c0311978910e5cbd758e3a45d9e (patch)
tree6a1cd051da08c48b2a8bc189e6195ab8b2e73f4e
parent8f10ace112796e0f5dd07a5dddab5534361a91ef (diff)
downloadbluez-907c83b3d5258c0311978910e5cbd758e3a45d9e.tar.gz
bluez-907c83b3d5258c0311978910e5cbd758e3a45d9e.tar.bz2
bluez-907c83b3d5258c0311978910e5cbd758e3a45d9e.zip
Audio : Add the method for setting/getting the restricted connection
Change-Id: I6d47dc5effd0e21629060ca88967b26bd9a69312 Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
-rw-r--r--src/device.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 79637f28..108a5112 100644
--- a/src/device.c
+++ b/src/device.c
@@ -233,6 +233,11 @@ struct trusted_profile_t {
uint32_t map:2;
uint32_t sap:2;
} __packed;
+
+struct restricted_profile_t {
+ uint32_t hfp_hs;
+ uint32_t a2dp;
+};
#endif
struct btd_device {
@@ -306,6 +311,7 @@ struct btd_device {
gboolean trusted;
#ifdef __TIZEN_PATCH__
struct trusted_profile_t trusted_profiles;
+ struct restricted_profile_t restricted_profiles;
#endif
gboolean blocked;
gboolean auto_connect;
@@ -363,6 +369,15 @@ typedef enum {
#define SAP_SHIFT_OFFSET 4
#define PROFILE_SUPPORTED 0x3 /* This corresponds to binary 0b11*/
+
+typedef enum {
+ CONNECTION_RESTRICTED = 0x0, /* 0b00 */
+ CONNECTION_PERMITTED = 0x1, /* 0b01 */
+} bt_profile_restricted_states;
+
+#define HFP_HS_SHIFT_OFFSET 0
+#define A2DP_SHIFT_OFFSET 2
+
#endif
static int device_browse_gatt(struct btd_device *device, DBusMessage *msg);
@@ -568,6 +583,14 @@ static gboolean store_device_info_cb(gpointer user_data)
DBG("Storing TrustedProfiles %d", trusted_profiles);
g_key_file_set_integer(key_file, "General", "TrustedProfiles",
trusted_profiles);
+
+ struct restricted_profile_t restrict_profile = device->restricted_profiles;
+ int restricted_profiles = (restrict_profile.hfp_hs << HFP_HS_SHIFT_OFFSET) |
+ (restrict_profile.a2dp << A2DP_SHIFT_OFFSET);
+ DBG("Storing RestrictedProfiles %d", restricted_profiles);
+ g_key_file_set_integer(key_file, "General", "RestrictedProfiles",
+ restricted_profiles);
+
#endif
g_key_file_set_boolean(key_file, "General", "Blocked",
device->blocked);
@@ -1320,6 +1343,21 @@ static gboolean dev_property_get_trusted_profiles(const GDBusPropertyTable *prop
return TRUE;
}
+
+static gboolean dev_property_get_restricted_profiles(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct btd_device *device = data;
+ uint32_t hfp_hs = device->restricted_profiles.hfp_hs;
+ uint32_t a2dp = device->restricted_profiles.a2dp;
+
+ unsigned int val = (hfp_hs << HFP_HS_SHIFT_OFFSET) |
+ (a2dp << A2DP_SHIFT_OFFSET);
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &val);
+
+ return TRUE;
+}
#endif
static gboolean dev_property_get_blocked(const GDBusPropertyTable *property,
@@ -3475,6 +3513,45 @@ static DBusMessage *set_trusted_profile(DBusConnection *conn,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *set_restricted_profile(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct btd_device *dev = data;
+ dbus_bool_t profile_restricted;
+ const char *pattern;
+ char *uuid;
+ uint32_t hfp_hs = dev->restricted_profiles.hfp_hs;
+ uint32_t a2dp = dev->restricted_profiles.a2dp;
+
+ if (!dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_BOOLEAN, &profile_restricted,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ DBG("Pattern : %s", pattern);
+ uuid = bt_name2string(pattern);
+ DBG("UUID : %s", uuid);
+ DBG("profile Restricted : %d %d", dev->restricted_profiles.hfp_hs,
+ dev->restricted_profiles.a2dp);
+ if (g_strcmp0(uuid, HFP_HS_UUID) == 0) {
+ if (profile_restricted)
+ hfp_hs = CONNECTION_PERMITTED;
+ else
+ hfp_hs = CONNECTION_RESTRICTED;
+ } else if (g_strcmp0(uuid, A2DP_SINK_UUID) == 0) {
+ if (profile_restricted)
+ a2dp = CONNECTION_PERMITTED;
+ else
+ a2dp = CONNECTION_RESTRICTED;
+ } else {
+ return btd_error_invalid_args(msg);
+ }
+
+ btd_device_set_restricted_profiles(dev, hfp_hs, a2dp);
+ return dbus_message_new_method_return(msg);
+}
+
static DBusMessage *is_connected_profile(DBusConnection *conn, DBusMessage *msg,
void *user_data)
{
@@ -3744,6 +3821,9 @@ static const GDBusMethodTable device_methods[] = {
{ GDBUS_METHOD("SetTrustedProfile",
GDBUS_ARGS({ "uuid", "s"}, { "trusted", "b"}), NULL,
set_trusted_profile) },
+ { GDBUS_METHOD("SetRestrictedProfile",
+ GDBUS_ARGS({ "uuid", "s"}, { "restricted", "b"}), NULL,
+ set_restricted_profile) },
#endif
{ }
};
@@ -3785,6 +3865,7 @@ static const GDBusPropertyTable device_properties[] = {
{ "IpspBtInterfaceInfo", "s", dev_property_get_ipsp_conn_bt_iface_name },
{ "AttMtu", "q", dev_property_get_att_mtu },
{ "TrustedProfiles", "u", dev_property_get_trusted_profiles},
+ { "RestrictedProfiles", "u", dev_property_get_restricted_profiles},
#endif
{ "ManufacturerData", "a{qv}", dev_property_get_manufacturer_data,
NULL, dev_property_manufacturer_data_exist,
@@ -4165,6 +4246,14 @@ next:
(PROFILE_SUPPORTED << MAP_SHIFT_OFFSET)) >> MAP_SHIFT_OFFSET);
device->trusted_profiles.sap = ((trusted_profiles &
(PROFILE_SUPPORTED << SAP_SHIFT_OFFSET)) >> SAP_SHIFT_OFFSET);
+
+ /* Load Restricted Profiles*/
+ int restricted_profiles = g_key_file_get_integer(key_file, "General",
+ "RestrictedProfiles", NULL);
+ DBG("Loading RestrictedProfiles %d", restricted_profiles);
+ device->restricted_profiles.hfp_hs = (restricted_profiles >> HFP_HS_SHIFT_OFFSET) & 0x01;
+ device->restricted_profiles.a2dp = (restricted_profiles >> A2DP_SHIFT_OFFSET) & 0x01;
+
#endif
/* Load device blocked */
@@ -7041,6 +7130,26 @@ void btd_device_set_trusted_profiles(struct btd_device *device,
g_dbus_emit_property_changed(dbus_conn, device->path,
DEVICE_INTERFACE, "TrustedProfiles");
}
+
+void btd_device_set_restricted_profiles(struct btd_device *device,
+ uint32_t hfp_hs, uint32_t a2dp)
+{
+ if (!device)
+ return;
+ DBG("RestrictedProfiles Parameters: [HFP %d] [A2DP %d]", hfp_hs, a2dp);
+
+ if (device->restricted_profiles.hfp_hs == hfp_hs &&
+ device->restricted_profiles.a2dp == a2dp)
+ return;
+
+ device->restricted_profiles.hfp_hs = hfp_hs;
+ device->restricted_profiles.a2dp = a2dp;
+
+ store_device_info(device);
+
+ g_dbus_emit_property_changed(dbus_conn, device->path,
+ DEVICE_INTERFACE, "RestrictedProfiles");
+}
#endif
void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type)