Commit Graph

134 Commits

Author SHA1 Message Date
Lukasz Rymanowski
1090705817 android/bluetooth: Make possible to start BlueZ in a single mode
This patch adds possibility to start BlueZ in LE or BR/EDR mode
when having dual mode chip below.
2014-04-24 10:32:47 +02:00
Lukasz Rymanowski
8e363b81db android/bluetooth: Do not enable BT LE by default 2014-04-24 10:32:47 +02:00
Lukasz Rymanowski
369fd7286d android/bluetooth: Add supported lmp settings to adapter struct 2014-04-24 10:32:47 +02:00
Lukasz Rymanowski
5563af9e27 android/bluetooth: Expose API to set advertising
With this patch android GAP expose start/stop advertising API
2014-04-16 11:45:31 +02:00
Szymon Janc
c6438f2a1b android/bluetooth: Remove debug log from create_device_from_info
create_device_from_info always calls create_device which already prints
created device address.
2014-04-14 10:15:25 +02:00
Szymon Janc
6757bbdf2f android/bluetooth: Send device properties in single notification
This reduces number of IPC calls while enabling Bluetooth.
2014-04-14 10:15:25 +02:00
Szymon Janc
dfa9b2dfb7 android/bluetooth: Send adapter properties in single notification
This reduces number of IPC calls while enabling Bluetooth.
2014-04-14 10:15:25 +02:00
Szymon Janc
02225cd8fb android/bluetooth: Fix passing NULL pointer to memcpy
It is possible to have property with empty value (ie. bonded devices)
so check len before calling memcpy.
2014-04-14 10:15:25 +02:00
Lukasz Rymanowski
4a1da92a17 android/gatt: Fix for scan non discoverable devices
With this patch Android framework will not be notified with
non-discoverable LE devices.
2014-04-11 16:04:44 +02:00
Szymon Janc
92e869f47a android/bluetooth: Refactor handling on new devices
This fix sending new device found events for non-discoverable devices
as well as passing wrong data to gatt_device_found_cb.
2014-04-02 16:31:09 +02:00
Lukasz Rymanowski
74a6dc0087 android/gatt: Fix regression introduced by b278efa5
Seems that GattService onScanResult is only looking into remote uuids in
adverisement data. No device object is created in the Android framework,
Therefore we need to send regular device found for BLE devices as well.
Otherwise the Android GATT application will not be aware of remote device
properties like name etc.
2014-03-30 23:46:26 +02:00
Szymon Janc
b278efa539 android/bluetooth: Send new device events only when needed 2014-03-27 15:37:14 +01:00
Szymon Janc
288f8f9218 android/bluetooth: Send friendly name property when sending name 2014-03-27 15:37:14 +01:00
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