From: Johan Hedberg Date: Wed, 14 Nov 2012 13:58:08 +0000 (+0200) Subject: core: Add automatic SDP record generation for external profiles X-Git-Tag: android-x86-4.4-r3~12152 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d5fa5628bf9922d0f68cebf53bc38100787a960a;p=android-x86%2Fexternal-bluetooth-bluez.git core: Add automatic SDP record generation for external profiles --- diff --git a/src/profile.c b/src/profile.c index daadea62a..5c25cd85a 100644 --- a/src/profile.c +++ b/src/profile.c @@ -65,6 +65,48 @@ #define MAS_DEFAULT_CHANNEL 16 #define MNS_DEFAULT_CHANNEL 17 +#define HFP_HF_RECORD \ + " \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + " + struct ext_profile { struct btd_profile p; @@ -73,7 +115,9 @@ struct ext_profile { char *uuid; char *path; char *role; + char *record; + char *(*get_record)(struct ext_profile *ext); char **remote_uuids; @@ -88,6 +132,9 @@ struct ext_profile { uint16_t psm; uint8_t chan; + uint16_t version; + uint16_t features; + GSList *servers; GSList *conns; @@ -990,6 +1037,12 @@ static int ext_disconnect_dev(struct btd_device *dev, return 0; } +static char *get_hfp_hf_record(struct ext_profile *ext) +{ + return g_strdup_printf(HFP_HF_RECORD, ext->chan, ext->version, + ext->name, ext->features); +} + static struct default_settings { const char *uuid; int priority; @@ -997,6 +1050,9 @@ static struct default_settings { uint8_t channel; BtIOSecLevel sec_level; bool authorize; + char * (*get_record)(struct ext_profile *ext); + uint16_t version; + uint16_t features; } defaults[] = { { .uuid = SPP_UUID, @@ -1009,11 +1065,14 @@ static struct default_settings { .priority = BTD_PROFILE_PRIORITY_HIGH, .remote_uuid = HFP_AG_UUID, .channel = HFP_HF_DEFAULT_CHANNEL, + .get_record = get_hfp_hf_record, + .version = 0x0105, }, { .uuid = HFP_AG_UUID, .priority = BTD_PROFILE_PRIORITY_HIGH, .remote_uuid = HFP_HS_UUID, .channel = HFP_AG_DEFAULT_CHANNEL, + .version = 0x0105, }, { .uuid = HSP_AG_UUID, .priority = BTD_PROFILE_PRIORITY_HIGH, @@ -1077,6 +1136,15 @@ static void ext_set_defaults(struct ext_profile *ext) if (settings->priority) ext->p.priority = settings->priority; + + if (settings->get_record) + ext->get_record = settings->get_record; + + if (settings->version) + ext->version = settings->version; + + if (settings->features) + ext->features = settings->features; } } @@ -1144,6 +1212,22 @@ static int parse_ext_opt(struct ext_profile *ext, const char *key, g_free(ext->record); ext->record = g_strdup(str); ext->enable_server = true; + } else if (strcasecmp(key, "Version") == 0) { + uint16_t ver; + + if (type != DBUS_TYPE_UINT16) + return -EINVAL; + + dbus_message_iter_get_basic(value, &ver); + ext->version = ver; + } else if (strcasecmp(key, "Features") == 0) { + uint16_t feat; + + if (type != DBUS_TYPE_UINT16) + return -EINVAL; + + dbus_message_iter_get_basic(value, &feat); + ext->features = feat; } return 0; @@ -1183,6 +1267,9 @@ static struct ext_profile *create_ext(const char *owner, const char *path, if (!ext->name) ext->name = g_strdup_printf("%s%s/%s", owner, path, uuid); + if (!ext->record && ext->get_record) + ext->record = ext->get_record(ext); + p = &ext->p; p->name = ext->name;