device: Don't browse SDP if HIDSDPDisable is set
authorArchie Pusaka <apusaka@chromium.org>
Tue, 18 Aug 2020 07:34:09 +0000 (15:34 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:50 +0000 (14:30 +0530)
According to the HID1.1 spec, part 5.3.4.9:
The HIDSDPDisable attribute is a Boolean value, which indicates
whether connection to the SDP channel and Control or Interrupt
channels are mutually exclusive. This feature supports Bluetooth
HID devices that have minimal resources, and multiplex those
resources between servicing the initialization (SDP) and runtime
(Control and Interrupt) channels.

However, Bluez still tries to connect SDP upon HID connection,
regardless of the existence of the HIDSDPDisable attribute.

This patch prevents the connection of SDP after HID has been
established, if the device has HIDSDPDisable attribute.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/input/device.c
src/device.c
src/device.h

index dd57b763bce0ae84a3c73bb6d3be3f01bcd86b35..4740fd932d2f31ebe8443f1b5f47e5ba6c01bf8e 100644 (file)
@@ -1516,6 +1516,9 @@ static struct input_device *input_device_new(struct btd_service *service)
        /* Initialize device properties */
        extract_hid_props(idev, rec);
 
+       if (idev->disable_sdp)
+               device_set_refresh_discovery(device, false);
+
        return idev;
 }
 
index f5fce16e51ed43c65bad23aa56805752247f93aa..fc1cff52f09289993945378bc7983b5df91c61a4 100644 (file)
@@ -238,6 +238,7 @@ struct btd_device {
        bool            le;
        bool            pending_paired;         /* "Paired" waiting for SDP */
        bool            svc_refreshed;
+       bool            refresh_discovery;
 
        /* Manage whether this device can wake the system from suspend.
         * - wake_support: Requires a profile that supports wake (i.e. HID)
@@ -2295,7 +2296,7 @@ done:
                } else {
 #endif
                /* Start passive SDP discovery to update known services */
-               if (dev->bredr && !dev->svc_refreshed)
+               if (dev->bredr && !dev->svc_refreshed && dev->refresh_discovery)
                        device_browse_sdp(dev, NULL);
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
                }
@@ -3209,6 +3210,11 @@ done:
                browse_request_free(req);
 }
 
+void device_set_refresh_discovery(struct btd_device *dev, bool refresh)
+{
+       dev->refresh_discovery = refresh;
+}
+
 static void device_set_svc_refreshed(struct btd_device *device, bool value)
 {
        if (device->svc_refreshed == value)
@@ -5944,6 +5950,8 @@ static struct btd_device *device_new(struct btd_adapter *adapter,
        device->db_id = gatt_db_register(device->db, gatt_service_added,
                                        gatt_service_removed, device, NULL);
 
+       device->refresh_discovery = true;
+
        return btd_device_ref(device);
 }
 
index 5927da856cb4285d07f80893385a0357d5113d73..71c4981fc993dfb45833ed33b5d151dc0fbca8a8 100644 (file)
@@ -183,6 +183,7 @@ void device_set_wake_override(struct btd_device *device, bool wake_override);
 void device_set_wake_allowed(struct btd_device *device, bool wake_allowed,
                             guint32 id);
 void device_set_wake_allowed_complete(struct btd_device *device);
+void device_set_refresh_discovery(struct btd_device *dev, bool refresh);
 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal,
                                        void *user_data);