Commit Graph

878 Commits

Author SHA1 Message Date
Andrei Emeltchenko
a47543bd5e bnep: Fix redundant check 2014-06-23 10:50:30 +03:00
Andrei Emeltchenko
0518048263 HDP: Add length check
Fixes static analyzer warnings related to casting possible error code to
unsigned.
2014-06-18 00:05:40 +02:00
Andrei Emeltchenko
5050a95c01 HDP: trivial: Make code more readable 2014-06-18 00:05:40 +02:00
Ravi kumar Veeramally
7eeb611f56 profiles/health/hdp: Fix memory leak in SDP record preparation
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)
2014-06-17 14:27:31 +02:00
Andrei Emeltchenko
fb36e4983c HDP: Set error message on error condition
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);
                                                      ^~~~~~~~~~~~~
...
2014-06-13 15:43:45 +03:00
Andrei Emeltchenko
32b52153ec HDP: trivial: Fix redundant debug print 2014-06-13 15:41:03 +03:00
Johan Hedberg
c5162672e9 input: Fix access to uninitialized data when authorizing connections
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.
2014-06-10 13:27:55 +03:00
Andrzej Kaczmarek
64bb9becff profiles/audio: Fix propagation of EHOSTDOWN error
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.
2014-06-04 22:38:44 +03:00
Luiz Augusto von Dentz
8b62dc6154 audio/media: Check if setting value is already set
If the setting value is already set the is no need to send anything.
2014-06-03 16:26:33 +03:00
Luiz Augusto von Dentz
86a6ea1f83 audio/media: Fix crash while changing repeat mode
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
2014-06-03 16:26:33 +03:00
Luiz Augusto von Dentz
f8f65a0926 input: Do not send UHID_DESTROY
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."
2014-05-30 09:04:39 +03:00
Jakub Tyszkowski
35e77c1c5f gatt: Fix not freeing GError on failure 2014-05-27 22:46:49 +02:00
Andrzej Kaczmarek
62c32efcab audio: Add definitions for aptX 2014-05-27 17:56:36 +03:00
Andrzej Kaczmarek
e0268c9936 audio: Add macros to access MPEG-2,4 AAC codec info
This patch provides helper macros to get, set and init-in-struct both
frequency and bitrate fields in codec info structs for MPEG-2,4 AAC.
2014-05-27 17:56:36 +03:00
Andrzej Kaczmarek
c93915c343 audio: Add definitions for MPEG-2,4 AAC codec
frequency and bitrate bit-fields are splitted into separate bytes since
they span across byte-boundary and cannot be set easily on LE arch
anyway.
2014-05-27 17:56:36 +03:00
Andrzej Kaczmarek
73f5534028 audio: Fix a2dp_vendor_codec_t declaration
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.
2014-05-27 17:56:36 +03:00
Szymon Janc
af2a377075 input: Update uhid_copy.h to version from Linux 3.14 2014-05-25 12:58:52 +03:00
Luiz Augusto von Dentz
330a3ab42d input/hog: Rework uHID code to use bt_uhid 2014-05-23 16:40:29 +03:00
Luiz Augusto von Dentz
1925241046 input/device: Fix warnings when disconnecting
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.
2014-05-23 16:40:29 +03:00
Luiz Augusto von Dentz
e93eeb6cff input/device: Rework uHID code to use bt_uhid 2014-05-23 16:40:29 +03:00
Szymon Janc
9dfcb9f7fc hog: Fix compilation error on 32 bit machine
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));
        ^
2014-05-14 23:14:34 +03:00
Szymon Janc
18a7a7ecb5 input: Fix compilation errors on 32 bit machine
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));
        ^
2014-05-14 23:14:30 +03:00
Petri Gynther
d25cbd3c70 hog: Fix report_value_cb() buffer overflow
Fix buffer overflow that would happen in the case:
hogdev->has_report_id == TRUE && report_size == UHID_DATA_MAX
2014-05-09 22:07:28 +03:00
Petri Gynther
976cecb6b6 hog: Improve report_value_cb() uHID error handling
Use similar uHID error handling and debug messages as uhid_send_input_report()
in profiles/input/device.c.
2014-05-09 22:07:26 +03:00
Petri Gynther
c54e30f307 hog: Fix report_value_cb() signature
Fix report_value_cb() signature to match GAttribNotifyFunc.
2014-05-09 22:07:24 +03:00
Luiz Augusto von Dentz
e97baaca22 audio/player: Fix accepting invalid folders in ChangeFolder
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.
2014-05-09 13:42:32 +03:00
Johan Hedberg
f3f19ccead input: Fix minor coding style issues 2014-05-08 23:14:38 +03:00
Petri Gynther
054bfbcf4a input: Add userspace HID support
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.
2014-05-08 23:08:31 +03:00
Andrzej Kaczmarek
934d4fb99d hog: Remove redundant struct
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.
2014-05-05 10:49:52 +03:00
Andrzej Kaczmarek
b85ba0b438 thermometer: Discover descriptors using gatt_discover_desc 2014-05-05 10:49:47 +03:00
Andrzej Kaczmarek
d83acdf45f cyclingspeed: Discover CCC using gatt_discover_desc 2014-05-05 10:49:41 +03:00
Andrzej Kaczmarek
87d9617b06 heartrate: Discover CCC using gatt_discover_desc 2014-05-05 10:49:24 +03:00
Andrzej Kaczmarek
7e38e7dc94 scan: Discover CCC using gatt_discover_desc 2014-05-05 10:49:17 +03:00
Andrzej Kaczmarek
5b1d5ae2b6 hog: Discover descriptors using gatt_discover_desc 2014-05-05 10:49:10 +03:00
Andrzej Kaczmarek
3d71c376f5 gas: Discover CCC using gatt_discover_desc 2014-05-05 10:49:03 +03:00
Andrzej Kaczmarek
25656fa3c8 hog: Improve report map debugging
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.
2014-04-30 15:51:04 +03:00
Andrzej Kaczmarek
06a71a5cfd hog: Fix checking for Report ID item presence
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.
2014-04-30 15:51:04 +03:00
Luiz Augusto von Dentz
a7a73c508c audio/player: Fix properties Browsable/Searchable
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.
2014-04-23 17:54:58 +03:00
Johan Hedberg
65610e08ab input: Use proper bool type for boolean variable 2014-04-05 09:49:23 +03:00
Petri Gynther
d8f8bdc0a1 input: Refactor HIDP kernel module interaction
Refactor HIDP kernel module interaction to ioctl_xxx routines.
2014-04-05 09:47:16 +03:00
Petri Gynther
ddecba5b5d input: Fix input.conf IdleTimeout handling
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.
2014-04-05 09:47:15 +03:00
Claudio Takahasi
6b09f55b09 Remove unneeded headers include 2014-04-04 21:21:42 +03:00
Claudio Takahasi
d09d075d6c proximity: Remove att_put_u8() usage 2014-03-25 17:24:19 +02:00
Claudio Takahasi
f1956438cc gatt: Move Characteristic properties to attrib/gatt.h
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
2014-03-25 17:24:01 +02:00
Claudio Takahasi
454a30731b Replace att_put_u16() by put_le16() 2014-03-24 22:11:28 +02:00
Claudio Takahasi
91744cb56f Replace att_get_u16() by get_le16() 2014-03-24 22:08:20 +02:00
Claudio Takahasi
8ba454bea9 Replace att_put_u32() by put_le32() 2014-03-24 22:07:48 +02:00
Claudio Takahasi
a60d6832ac Replace att_get_u32() by get_le32() 2014-03-24 22:07:44 +02:00
Claudio Takahasi
99e7a4bd0f Replace bt_put_be64() by put_be64() 2014-03-24 22:03:52 +02:00
Claudio Takahasi
c729b66195 Replace bt_put_be32() by put_be32() 2014-03-24 22:03:09 +02:00