Sdp record preparation part is copied to android/health.c from
profiles/health/hdp_utils.c. Memory leak is noticed while testing. Memory
summay is from android daemon, but code snippet is same. It is already fixed
in android/health.c while submitting android related patches.
==12515== 286 (16 direct, 270 indirect) bytes in 1 blocks are definitely lost in loss record 158 of 165
==12515== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12515== by 0x44AC45: sdp_list_append (sdp.c:1743)
==12515== by 0x4398F9: register_features (health.c:381)
==12515== by 0x4091CC: queue_foreach (queue.c:219)
==12515== by 0x43A31F: bt_health_mdep_cfg_data (health.c:398)
==12515== by 0x418B50: cmd_watch_cb (ipc.c:144)
==12515== by 0x4E7FCE4: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
==12515== by 0x4E80047: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
==12515== by 0x4E80309: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
==12515== by 0x4044F2: main (main.c:538)
Fixes clang warning:
...
CC profiles/health/bluetoothd-hdp.o
profiles/health/hdp.c:1778:13: warning: Access to field 'message'
results in a dereference of a null pointer (loaded from variable 'gerr')
"%s", gerr->message);
^~~~~~~~~~~~~
...
There were bt_io_get() failure code paths in two places that would
access "src" and "dst" when they are uninitialized. This would happen
e.g. if the HID device disconnects before we've authorized the
connection. To fix this we now save the remote address in a more
complete confirm context and use the source address already available in
the server context.
EHOSTDOWN error is now overwritten by EIO and once it's passed to
device_profile_connected it triggers connection of another profiles
while it should actually stop connecting them.
By changing repeat mode to 'group' which does not have a direct
translation to MPRIS LoopStatus will cause the following crash:
_dbus_abort () from /usr/lib/libdbus-1.so.3
_dbus_warn_check_failed () from /usr/lib/libdbus-1.so.3
dbus_message_iter_append_basic () from /usr/lib/libdbus-1.so.3
set_repeat_setting (key=0x80d6a87 "Repeat", value=0x80d8079 "group", user_data=0x984ab40) at profiles/audio/media.c:1050
Accourding to uHID documentation when diconnecting the kernel will take
care of cleaning up any device created:
"If you close() the fd, the device is automatically unregistered and
destroyed internally."
As per A2DP spec, both Vendor ID (4.7.2.1) and Codec ID (4.7.2.2) are
defined as 32-bit and 16-bit values respectively rather that array of
bytes. Also changing to uint types will make using these values in code
much easier.
Since the introdution of btd_profile there is a dedicated callback for
disconnecting profiles which should never be mixed with
device_add_disconnect_watch since they serve the same purpose.
Fix following with GCC version 4.8.2 (Debian 4.8.2-21):
CC profiles/input/bluetoothd-hog.o
profiles/input/hog.c: In function ‘report_value_cb’:
profiles/input/hog.c:149:8: error: format ‘%lu’ expects argument of
type ‘long unsigned int’, but argument 3 has type ‘unsigned int’
[-Werror=format=]
status, sizeof(ev));
^
Fix following with GCC version 4.8.2 (Debian 4.8.2-21):
CC profiles/input/bluetoothd-device.o
profiles/input/device.c: In function ‘uhid_send_feature_answer’:
profiles/input/device.c:232:8: error: format ‘%lu’ expects argument
of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’
[-Werror=format=]
len, sizeof(ev));
^
profiles/input/device.c: In function ‘uhid_send_input_report’:
profiles/input/device.c:274:8: error: format ‘%lu’ expects argument of
type ‘long unsigned int’, but argument 3 has type ‘unsigned int’
[-Werror=format=]
len, sizeof(ev));
^
When navigating on VFS ChangeFolder should only accept folders that are
one level away for the current one as it does use ChangePath which can
only navigate one level up/down in the virtual filesystem.
Enable HID protocol handling in userspace when UserspaceHID=true in input.conf.
Benefits of userspace HID:
1. Persistent HID/input pipeline
For a Bluetooth HID device, the corresponding kernel HID/input devices are
created only once when the Bluetooth HID device is used the first time.
The HID/input pipeline is not destroyed and recreated every time when
the Bluetooth HID device disconnects and reconnects.
2. HID vs HoG parity
Enables HID and HoG devices to operate the same way in BlueZ stack, using
uHID kernel module (/dev/uhid) to pass HID report data between bluetoothd
and kernel HID subsystem.
3. Debugging
It is easier to debug HID protocol in userspace than in HIDP kernel module.
Since complete descriptor discovery is now performed inside gatt code,
there's no need to store end handle for characteristics and thus we can
remove disc_desc_cb_data.
Now that we can split report map into items it's convenient to have it
printed with items structure preserved which makes it more useful for
debugging.
Up to 5 bytes are printed for each item which is enough for short items
and for long items continuation mark ('...') is printed if necessary.
This is because as for now there are no long item tags defined except
for some vendor defined thus we can safely "ignore" them and avoid
overly complicated code.
Report ID item in Report Descriptor is now detected by simply looking
for applicable item prefixes anywhere in data and does not take items
structure into consideration. This could lead to false-positive
detections in case value we look for is just part of item data, not an
actual item prefix.
As defined in Device Class Definition for HID (6.2.2.7), Report ID is
a short item with prefix 100001nn (binary) thus we do not need to do
complete parsing of Report Descriptor but only need to check items
prefixes in order to find Report ID items reliably.
This patch checks Report Descriptor item by item looking for item
prefix which matches Report ID, as defined in spec above.
Those properties are set before the initial scope has been set so
checking for scope will always cause them to be invalidated, instead
check if any folder exists which indicates that MediaFolder interface
will be created shortly.
IdleTimeout is an optional config item in input.conf. Don't complain
if it is not defined. Instead, do the opposite and show its value in
debug logs only when it is defined.
Properties are defined by GATT specification. This patch moves and
renames the defines related to Characteristic properties bits from
attrib/att.h to attrib/gatt.h