Commit Graph

97 Commits

Author SHA1 Message Date
Szymon Janc
3c7f2c9430 android/bluetooth: Don't set remote name to empty string
If remote device has name but it is empty (0 bytes) just ignore it and
continue using address as name. This will avoid sending remote device
property notification with empty name.
2014-02-24 20:28:41 +01:00
Szymon Janc
c6d09297cd android/bluetooth: Fix memory leak in store_link_key
If loading key file from file failed free key file. This fix following:

490 (40 direct, 450 indirect) bytes in 1 blocks are definitely lost in
    loss record 122 of 126
   at 0x4028B4C: malloc (vg_replace_malloc.c:291)
   by 0x40A25B2: g_malloc (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x40B8DB1: g_slice_alloc (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x40B92DC: g_slice_alloc0 (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x40946BB: g_key_file_new (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
   by 0x8054A84: new_link_key_callback (bluetooth.c:563)
   by 0x804FB44: notify_handler (mgmt.c:278)
   by 0x804F357: queue_foreach (queue.c:186)
   by 0x804FE6C: can_read_data (mgmt.c:290)
   by 0x804ED12: read_callback (io-glib.c:168)
   by 0x40E0CF4: ??? (in /lib/i386-linux-gnu/libglib-2.0.so.0.3800.2)
   by 0x409CAED: g_main_context_dispatch (in /lib/i386-linux-gnu/
    libglib-2.0.so.0.3800.2)
2014-02-22 21:56:46 +01:00
Lukasz Rymanowski
240eec7fed android: Do not resolve name if we have it in the cache
With this patch, deamon will not ask kernel to resolve name of remote
device during inquiry in case device name is already in the local cache.
Instead Android will be updated with already known device name.
2014-02-21 11:45:12 +01:00
Lukasz Rymanowski
be76f91c20 android: Add resolve_name parameter to confirm_device_name 2014-02-21 11:45:11 +01:00
Lukasz Rymanowski
f4ff283b43 android: Fix for BT Turn off while pairing
This patch fix an issue when Android disables BT during ongoing
paring. In this case mgmt did not accept any commands and BT gets
in some unknown state.
Since Android turns off BT anyway, it is ok to just cancel all
the mgmt requests before send power off command.
2014-02-17 14:42:15 +01:00
Andrei Emeltchenko
29fa9f53d8 android: Fix memory leak: uuid free
Free uuid before exiting.
2014-02-14 11:35:16 +01:00
Andrzej Kaczmarek
eb5e7f97e6 android/bluetooth: Handle 128-bit UUIDs
It's now possible to add record with 128-bit UUID Service Class which
are used for custom applications. To simplify implementation adapter
uuids list stores now full UUID in uuid_t structure instead of uint16_t
short UUID.
2014-02-12 13:50:49 +01:00
Marcel Holtmann
cde69653e0 android: Update copyright and license details 2014-02-11 10:42:56 -08:00
Szymon Janc
49b7522726 android/bluetooth: Send prop change event only if prop was changed 2014-02-05 09:46:33 +01:00
Szymon Janc
13f1bbffef android/bluetooth: Refactor update_found_device function
This function grown too big and was hard to follow. Split it to helpers
for clarity.
2014-02-05 09:46:33 +01:00
Szymon Janc
d334b11100 android/bluetooth: Add threshold to RSSI change
There is no need to report very small RSSI changes.
2014-02-05 09:46:33 +01:00
Szymon Janc
2a07e06b09 android/bluetooth: Fix unbonding device on auth failure
This was causing removal of device info from storage and resulting in
loosing bond after bluetoothd restart.
2014-01-29 17:22:36 +01:00
Anderson Lizardo
334254e4d0 android: Remove useless extra parenthesis 2014-01-27 21:48:02 +01:00
Marcel Holtmann
c1add0ff9f android: Use src/log.h include instead of just log.h 2014-01-26 00:23:15 -08:00
Szymon Janc
3be8272df5 android/bluetooth: Handle device unpaired mgmt event 2014-01-24 20:20:15 +01:00
Szymon Janc
90fb3a75e3 android/bluetooth: Check event length in mgmt_auth_failed_event 2014-01-24 20:20:15 +01:00
Szymon Janc
f5512018e2 android/bluetooth: Fix removing bonded device if connection failed 2014-01-24 20:20:15 +01:00
Szymon Janc
509b120a1a android/bluetooth: Check not paired status in unpair_device_complete
This is needed to make sure framework is updated with proper bond state
of device.
2014-01-24 15:17:24 +01:00
Szymon Janc
b8207d382f android/bluetooth: Rename devices list to cached_devices
This makes it clear what is the purpose of this list.
2014-01-24 15:17:24 +01:00
Szymon Janc
a7fc397087 android/bluetooth: Add support for loading caches devices from storage
Info is now stored for all devices and bond state depends on file.
Based on that devices loaded from storage are put either to cache
or to bonded_devices list.
2014-01-24 15:17:23 +01:00
Szymon Janc
3c12dc59e3 android/bluetooth: Add support for caching remote device info
Cache is limited to DEVICES_CACHE_MAX. Devices are sorted with
timestamp so if cache is full olderst device is removed.
2014-01-24 15:17:23 +01:00
Szymon Janc
579e1af763 android/bluetooth: Use defines for settings and devices files paths 2014-01-24 15:17:23 +01:00
Szymon Janc
429f9eb75b android/bluetooth: Split devices list to devices and bonded_devices
Bonded devices are permament until unbondedn. Non-bonded devices will
be held in (size limited) cache based on timestamp property so split
list to ease separation.
2014-01-24 15:17:23 +01:00
Szymon Janc
326d212791 android/bluetooth: Move option_index declaration to close other static
Don't intermix defines with static variables.
2014-01-21 15:19:43 +01:00
Johan Hedberg
1a9051e9ee Rename glib-helper to uuid-helper 2014-01-21 14:12:47 +02:00
Szymon Janc
cada0c0896 core: Add flags parameter to bt_search_service
This allows to pass custom SDP flags to sdp_connect.
2014-01-20 15:19:25 +02:00
Szymon Janc
1e0e4dfde2 android/bluetooth: Fix sending device prop change event with no props 2014-01-19 20:21:01 +01:00
Szymon Janc
73613fe026 android/bluetooth: Fix discovering new devices
Device found events should be send also for known devices if this is
new discovery session. Otherwise Android will ignore those devices.
2014-01-16 15:46:41 +01:00
Szymon Janc
da6f8e532c android/bluetooth: Fix compare function when finding devices
Elements on list are struct device not bdaddr_t so make comparing
function use proper types. This was working so far only due to
bdaddr_t being first element in struct device.
2014-01-12 20:43:15 +01:00
Szymon Janc
9b174ddfe2 android/bluetooth: Use helper for finding device 2014-01-12 20:43:07 +01:00
Szymon Janc
c31615b82b android/bluetooth: Log error for any non-success code
Returning non-SUCCESS code in command reply is considered error and
that includes DONE status.
2014-01-11 17:15:41 +01:00
Szymon Janc
86905a8968 android/bluetooth: Rename labels from failed to reply
This name match better and avoid confusion when setting status to
SUCCESS and then jumping to failed label.
2014-01-11 17:15:41 +01:00
Szymon Janc
b4dac30570 android/bluetooth: Use HAL_STATUS_SUCCESS instead of _DONE in replies
JNI code in Android is mapping returned code to boolean value. Only
SUCCESS status is mapped to true and that value is returned to Java
code. This could result in faultyly triggering error path in Java
when returning DONE in command reply.
2014-01-11 17:15:41 +01:00
Marcel Holtmann
883486009f android: Use LinkKeyPinLength instead of LinkKeyPINLength 2014-01-11 01:14:28 -08:00
Marcel Holtmann
93d858bcd2 android: Enable secure connections if supported 2014-01-11 01:13:46 -08:00
Szymon Janc
b6df31f1c8 android/bluetooth: Set major and minor class od device
Currently this is hardcoded to Phone/Smartphone.
2014-01-09 10:30:45 +01:00
Szymon Janc
4c0e55c4df android/bluetooth: Set default adapter name on first start
On first start always set name to default name. Adapter name is
updated on start only if current name is different.
2014-01-09 10:30:45 +01:00
Lukasz Rymanowski
7bfd06208a android: Send remote devices properties on enable
If there is any bonded device stored then on bluetooth enable we
should send notification with its properties.
2014-01-08 13:13:49 +01:00
Lukasz Rymanowski
3dee7edf88 android: Move get_remote_device_props up in the file
This patch moves up function get_remote_device_props() and all
functions required by this function.
2014-01-08 13:13:49 +01:00
Lukasz Rymanowski
c8aabab889 android: Add wrapper function for get remote dev properties 2014-01-08 13:13:49 +01:00
Szymon Janc
8a73184567 android/bluetooth: Fix browse_remote_sdp return value
False was converted to HAL_STATUS_SUCCESS resulting in wrong error
code in case of failure in handle_get_remote_services_cmd.
2014-01-03 22:56:50 +01:00
Szymon Janc
784ef1cd31 android/bluetooth: Print command opcode in DUT mode functions
Print command opcode in handle_le_test_mode_cmd and
handle_dut_mode_send_cmd. This is valuable information on what kind
of HCI command the Java layer tries to send.
2013-12-23 16:42:47 +01:00
Szymon Janc
7c3a06b743 android/bluetooth: Print error on unimplemented functions
Functions, callbacks or properties that are not implemented due to
being bogus or not feasible now prints error messages.
2013-12-23 14:41:41 +02:00
Szymon Janc
385c00cedd android/bluetooth: Add support for DUT mode configure command
This allows to enable and disable DUT mode. This is special mode so
adding more info from related kernel commit:

"The Device Under Test (DUT) mode is useful for doing certification
testing and so expose this as debugfs option.

This mode is actually special since you can only enter it. Restoring
normal operation means that a HCI Reset is required. The current mode
value gets tracked as a new device flag and when disabling it, the
correct command to reset the controller is sent."
2013-12-23 14:41:41 +02:00
Szymon Janc
3330781a20 android/bluetooth: Fix error message in stop_discovery 2013-12-23 12:47:31 +01:00
Szymon Janc
8af14a0ec4 android/bluetooth: Add support for timestamp device property
This allows to handle timestamp property request. Also this will be
usefull for devices info cache (clearing old devices).
2013-12-23 11:41:52 +02:00
Szymon Janc
9bc70e63b1 android/bluetooth: Fix memory leaks in load_devices_info
Groups and key file were not free on function return. This fix
following valgrind reports:

34 (16 direct, 18 indirect) bytes in 1 blocks are definitely lost in
loss record 33 of 77
   at 0x4C2A2DB: malloc (in /usr/lib/valgrind/vgpreload_memcheck-
amd64-linux.so)
   by 0x4E81DD0: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so
.0.3800.1)
   by 0x4E74BF1: g_key_file_get_groups (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x40CDFA: read_info_complete (bluetooth.c:1672)
   by 0x40827C: request_complete (mgmt.c:221)
   by 0x4085E9: received_data (mgmt.c:319)
   by 0x4E7C3B5: g_main_context_dispatch (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x4E7C707: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
   by 0x4E7CB09: g_main_loop_run (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x403B15: main (main.c:439)

1,633 (72 direct, 1,561 indirect) bytes in 1 blocks are definitely lost
in loss record 75 of 77
   at 0x4C2A2DB: malloc (in /usr/lib/valgrind/
vgpreload_memcheck-amd64-linux.so)
   by 0x4E81DD0: g_malloc (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x4E9796D: g_slice_alloc (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x4E97EAD: g_slice_alloc0 (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x4E746DA: g_key_file_new (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x40CDD4: read_info_complete (bluetooth.c:1667)
   by 0x40827C: request_complete (mgmt.c:221)
   by 0x4085E9: received_data (mgmt.c:319)
   by 0x4E7C3B5: g_main_context_dispatch (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x4E7C707: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
   by 0x4E7CB09: g_main_loop_run (in /lib/x86_64-linux-gnu/
libglib-2.0.so.0.3800.1)
   by 0x403B15: main (main.c:439)
2013-12-20 15:46:51 +01:00
Johan Hedberg
224b6b8088 android: Add clarifying comment to store_device_info() 2013-12-20 14:12:06 +02:00
Szymon Janc
5022d5ab42 android/bluetooth: Add support for restoring devices from storage
This adds support to restore bonded devices from storage (including
linkkeys).
2013-12-20 14:08:25 +02:00
Szymon Janc
d3174bdc20 android/bluetooth: Add support for storing link keys
When new linkkey event is received store linkkey in devices info file.
Stored info includes linkkey, linkkey type and pin length.
2013-12-20 14:08:06 +02:00