summaryrefslogtreecommitdiff
path: root/android/hidhost.c
diff options
context:
space:
mode:
authorAndrzej Kaczmarek <andrzej.kaczmarek@tieto.com>2014-01-22 18:46:37 +0100
committerSzymon Janc <szymon.janc@gmail.com>2014-01-22 23:50:58 +0100
commitc95e067c3e2d143c1ac746182879d6db9dc1ff13 (patch)
tree11b115c83803e33f5f112371d70cac1b3671d142 /android/hidhost.c
parent908733202d8cec8bc58c3e2fddf75601f43b034e (diff)
downloadbluez-c95e067c3e2d143c1ac746182879d6db9dc1ff13.tar.gz
android/hidhost: Fix vid and pid information
For HID device vendor, product and version numbers should be retrieved using Device ID profile which is mandatory for devices implementing HIDP.
Diffstat (limited to 'android/hidhost.c')
-rw-r--r--android/hidhost.c73
1 files changed, 55 insertions, 18 deletions
diff --git a/android/hidhost.c b/android/hidhost.c
index bb55f5e87..c01c56373 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -648,18 +648,6 @@ static void hid_sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
sdp_record_t *rec = list->data;
sdp_data_t *data;
- data = sdp_data_get(rec, SDP_ATTR_VENDOR_ID);
- if (data)
- dev->vendor = data->val.uint16;
-
- data = sdp_data_get(rec, SDP_ATTR_PRODUCT_ID);
- if (data)
- dev->product = data->val.uint16;
-
- data = sdp_data_get(rec, SDP_ATTR_VERSION);
- if (data)
- dev->version = data->val.uint16;
-
data = sdp_data_get(rec, SDP_ATTR_HID_COUNTRY_CODE);
if (data)
dev->country = data->val.uint8;
@@ -722,6 +710,55 @@ fail:
hid_device_free(dev);
}
+static void hid_sdp_did_search_cb(sdp_list_t *recs, int err, gpointer data)
+{
+ struct hid_device *dev = data;
+ sdp_list_t *list;
+ uuid_t uuid;
+
+ DBG("");
+
+ if (err < 0) {
+ error("Unable to get Device ID SDP record: %s", strerror(-err));
+ goto fail;
+ }
+
+ if (!recs || !recs->data) {
+ error("No SDP records found");
+ goto fail;
+ }
+
+ for (list = recs; list; list = list->next) {
+ sdp_record_t *rec = list->data;
+ sdp_data_t *data;
+
+ data = sdp_data_get(rec, SDP_ATTR_VENDOR_ID);
+ if (data)
+ dev->vendor = data->val.uint16;
+
+ data = sdp_data_get(rec, SDP_ATTR_PRODUCT_ID);
+ if (data)
+ dev->product = data->val.uint16;
+
+ data = sdp_data_get(rec, SDP_ATTR_VERSION);
+ if (data)
+ dev->version = data->val.uint16;
+ }
+
+ bt_string2uuid(&uuid, HID_UUID);
+ if (bt_search_service(&adapter_addr, &dev->dst, &uuid,
+ hid_sdp_search_cb, dev, NULL, 0) < 0) {
+ error("failed to search sdp details");
+ goto fail;
+ }
+
+ return;
+
+fail:
+ bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTED);
+ hid_device_free(dev);
+}
+
static void bt_hid_connect(const void *buf, uint16_t len)
{
const struct hal_cmd_hidhost_connect *cmd = buf;
@@ -749,10 +786,10 @@ static void bt_hid_connect(const void *buf, uint16_t len)
ba2str(&dev->dst, addr);
DBG("connecting to %s", addr);
- bt_string2uuid(&uuid, HID_UUID);
+ bt_string2uuid(&uuid, PNP_UUID);
if (bt_search_service(&adapter_addr, &dev->dst, &uuid,
- hid_sdp_search_cb, dev, NULL, 0) < 0) {
- error("Failed to search sdp details");
+ hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
+ error("Failed to search DeviceID SDP details");
hid_device_free(dev);
status = HAL_STATUS_FAILED;
goto failed;
@@ -1242,10 +1279,10 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
dev->ctrl_io = g_io_channel_ref(chan);
dev->uhid_fd = -1;
- bt_string2uuid(&uuid, HID_UUID);
+ bt_string2uuid(&uuid, PNP_UUID);
if (bt_search_service(&src, &dev->dst, &uuid,
- hid_sdp_search_cb, dev, NULL, 0) < 0) {
- error("failed to search sdp details");
+ hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
+ error("failed to search did sdp details");
hid_device_free(dev);
return;
}