diff --git a/android/handsfree.c b/android/handsfree.c
index 98d40b3..ee6de10 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
static void sdp_hfp_search_cb(sdp_list_t *recs, int err, gpointer data)
{
struct hf_device *dev = data;
- sdp_list_t *protos, *classes;
+ sdp_list_t *protos;
GError *gerr = NULL;
GIOChannel *io;
- uuid_t uuid;
+ uuid_t class;
int channel;
DBG("");
goto fail;
}
+ sdp_uuid16_create(&class, HANDSFREE_SVCLASS_ID);
+
+ /* Find record with proper service class */
+ for (; recs; recs = recs->next) {
+ sdp_record_t *rec = recs->data;
+
+ if (rec && !sdp_uuid_cmp(&rec->svclass, &class))
+ break;
+ }
+
if (!recs || !recs->data) {
info("handsfree: no HFP SDP records found, trying HSP");
return;
}
- if (sdp_get_service_classes(recs->data, &classes) < 0 || !classes) {
- error("handsfree: unable to get service classes from record");
- goto fail;
- }
-
if (sdp_get_access_protos(recs->data, &protos) < 0) {
error("handsfree: unable to get access protocols from record");
- sdp_list_free(classes, free);
- goto fail;
- }
-
- /* TODO read remote version? */
-
- memcpy(&uuid, classes->data, sizeof(uuid));
- sdp_list_free(classes, free);
-
- if (!sdp_uuid128_to_uuid(&uuid) || uuid.type != SDP_UUID16 ||
- uuid.value.uuid16 != HANDSFREE_SVCLASS_ID) {
- sdp_list_free(protos, NULL);
- error("handsfree: invalid service record or not HFP");
goto fail;
}
goto fail;
}
+ /* TODO read remote version? */
+
io = bt_io_connect(connect_cb, dev, NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
BT_IO_OPT_DEST_BDADDR, &dev->bdaddr,