Commit Graph

121 Commits

Author SHA1 Message Date
Szymon Janc
16f3747a14 android/bluetooth: Send device friendly name before name
This fix not setting friendly name correctly after BT power was
toggled. This is due to props being send in multiple notifications
instead of single one.
2014-03-27 15:37:14 +01:00
Szymon Janc
f3b62cf14e android/bluetooth: Don't send notification when setting device name
It is not needed to send notification when friendly name of remote
device is being set. Java already cache proper value. This was also
triggering exception in Java code (bug).
2014-03-27 15:37:14 +01:00
Szymon Janc
26bef4222d android/bluetooth: Always send known properties in new device event
This fix not updating property if EIR value was same as cached one.
2014-03-24 16:19:20 +01:00
Szymon Janc
3843e1822b android/bluetooth: Fix handling of BREDR, LE and dual mode devices
This includes fix for storage format so that dual mode devices are
handled correctly. Unfortunatelly this change is not backward
compatible so wiping out /data/misc/bluetooth/ is recommended.

Also correct device type is passed to bonding commands. For create_bond
we fallback to BDEDR if device is not known. This can happen eg. with
OOB. For cancel_bond and remove_bond we require device to be known.
For dual mode device currently only BREDR type is used.

Storage change details:
Instead of storing bdaddr type of device as "Type", now two variables
are used. Boolean "BREDR" if device supports BREDR. Address type is
stored in "AddressType" only if device supports LE and is either
LE random or LE public type.
2014-03-24 14:23:44 +01:00
Szymon Janc
919a803bf8 android/bluetooth: Add support for new long term key mgmt event 2014-03-24 14:23:44 +01:00
Szymon Janc
809ca0b645 android/bluetooth: Add support for loading LTKs 2014-03-24 14:23:44 +01:00
Szymon Janc
6890109d4e android/bluetooth: Filter out not discoverable LE devices
Filter out unknown LE devices that do not have Discoverable flag or
Limited Discoverable flag set.
2014-03-24 14:23:44 +01:00
Claudio Takahasi
d1ee63ca3f Replace bt_get_le32() by get_le32() 2014-03-21 10:40:48 +02:00
Szymon Janc
45eb43e85e android: Fix some random code style issues
Fix whitespace problems and not needed empty lines.
2014-03-20 15:36:52 +01:00
Jakub Tyszkowski
43802b5ae1 android/bluetooth: Add GATT notifications on LE discovery
This patch introduce API which GATT can use to start/stop discovery
and register for required events.

This is because GATT needs to get from GAP notifications about
founded devices and also notification when discovery has been stopped.

GATT will need it explicity when GATT client calls scan, and also in
case of connect device, as before le connect is sent we do scan first
to make sure that device is available.

For now on adapter have two variables tracing discovery.
1. cur_discovery_type which show type of ongoing discovery type.
2. exp_discovery_type which shows type of next discovery session.

We need this because of scenarion when GATT is interesting in scan and
in the same time HAL wants to do scanning.
2014-03-17 10:41:46 +01:00
Jakub Tyszkowski
f01f3a2dae android/bluetooth: Move start discovery function up in the file
This is to avoid unneeded code move in further paatches.
2014-03-14 00:09:44 +01:00
Jakub Tyszkowski
80ca53ae3f android/bluetooth: Refactor start/stop discovery
Pass discovery type to discovery stop/start routine so it can be used
also for LE only scan.
2014-03-14 00:09:44 +01:00
Lukasz Rymanowski
2e77a0b2f3 android: Send confirm name request with mgmt_send
This patch improves handling stop disvocery in scenarios when there is a big
inflow of device found events. In such case, number of confirm
name request might block mgmt queses and make stop discovery stack in the queue.

Even we cancel previous confirm name request, there is still possibility that
new incoming device found events produce confirm name request which will
might block stop discovery.
2014-03-13 15:20:51 +01:00
Lukasz Rymanowski
a5ee41a24f android: Cancel all pending confirm name before stop discovery
If user wants to cancel discovery we should remove all the confirm name
requests from mgmt queues.

It is in order to make sure that stop discovery have a free way to
reach kernel.

This improves scenario when there is a big inflow of device found events and
mgmt queues become full of confirm name requests. In such case stop discovery
might stack in the queue.
2014-03-13 15:20:51 +01:00
Lukasz Rymanowski
08228cf45a android: Add tracking for pending confirm name command 2014-03-13 15:20:51 +01:00
Szymon Janc
ed6ba0a7e6 android/bluetooth: Set missing settings before loading linkkeys
This makes sure all settings are set before adapter ready callback is
called. Limit number of notifications send when settings are applied.
2014-03-11 22:50:53 +01:00
Grzegorz Kolodziejczyk
2df2fc9baa android: Enable LE if controller supports it 2014-03-11 22:50:10 +01:00
Lukasz Rymanowski
d19b133b1d android: Enable mgmt debug logs
This patch introduce possibility to enable mgmt interface logs.
In order to enable it is required to set property:
persist.sys.bluetooth.mgmtdbg to 1 or literaly "true".
More info in README
2014-03-10 10:18:35 +01:00
Lukasz Rymanowski
20f9f7967f android: Support LE discovery if adapter supports LE 2014-03-09 14:26:18 +01:00
Lukasz Rymanowski
c58755a354 android: Fix type of discovery on start/stop discovery
Discovering type was confused with adapter settings. With this patch it
is fixed
2014-03-09 14:26:17 +01:00
Szymon Janc
550123d5df android/bluetooth: Remove not used local variable 2014-03-06 11:56:41 +01:00
Szymon Janc
14fc3c5403 android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
Szymon Janc
7d95d027b1 android: Create comon header for IPC
This header contains IPC specific structures and code not related to
BT and audio HAL protocols. This allows to fully decouple IPC from
HAL messages.

This is first step to make HAL part of IPC unit-testable and reusable
between BT HAL and audio HAL.
2014-02-28 15:22:45 +01:00
Szymon Janc
dd1e44fce1 android: Refactor IPC init
This allows to pass socket path and max service ID while initializaing
IPC. This is first step to allow use it both for BT and Audio HALs.
2014-02-28 15:22:45 +01:00
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