Commit Graph

166 Commits

Author SHA1 Message Date
Szymon Janc
f3ad56bdf5 android/bluetooth: Register SDP record for MPS
This was affecting TC_AG_SRC_HFAV_ACT_SD_BV_01_I and
TC_SDP_CTH_SD_BV_01_I PTS qualification tests.
2014-05-26 11:07:28 +02:00
Jakub Tyszkowski
f43d74eb83 android: Fix sending uninitialised data
This fixes the following:

==25759== Syscall param socketcall.sendmsg(msg.msg_iov[i]) points to
uninitialised byte(s)
==25759==    at 0x521C570: __sendmsg_nocancel (syscall-template.S:82)
==25759==    by 0x41688F: ipc_send (ipc.c:366)
==25759==    by 0x40ECF8: send_ssp_request (bluetooth.c:1028)
==25759==    by 0x4110A6: user_confirm_request_callback
(bluetooth.c:1055)
==25759==    by 0x4094FE: queue_foreach (queue.c:186)
==25759==    by 0x409FCF: can_read_data (mgmt.c:287)
==25759==    by 0x408E4C: read_callback (io-glib.c:168)
==25759==    by 0x4E79D12: g_main_context_dispatch (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==25759==    by 0x4E7A05F: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==25759==    by 0x4E7A459: g_main_loop_run (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==25759==    by 0x40454D: main (main.c:538)
==25759==  Address 0x7ff00085d is on thread 1's stack
==25759==  Uninitialised value was created by a stack allocation
==25759==    at 0x40EC77: send_ssp_request (bluetooth.c:1018)
2014-05-26 10:45:56 +02:00
Lukasz Rymanowski
067c255878 android/bluetooth: Store sign counter needed for aes-cmac sign
If CSRK is valid between sessions we should remember sign counter.
Therefor store it.
2014-05-26 10:28:16 +02:00
Lukasz Rymanowski
4c1d913ddc android/bluetooth: Read CSRK from the storage on startup 2014-05-26 10:28:16 +02:00
Lukasz Rymanowski
bfcc673c98 android/bluetooth: Store CSRK
CSRK is generated while paring and should be used for sign att packets
when LE devices uses write signed command.
2014-05-26 10:28:16 +02:00
Lukasz Rymanowski
f976567382 android/bluetooth: Add support to read CSRK from the kernel 2014-05-26 10:28:16 +02:00
Lukasz Rymanowski
55fa5f1e94 android/bluetooth: Expose API to update sign counter
This is needed so GATT can notify GAP that write sign has been done and
sign counter shall be increased as per spec.
2014-05-26 10:28:16 +02:00
Lukasz Rymanowski
2003db3897 android/bluetooth: Expose API to get CSRK for device
GATT will take CSRK key and sign counter each time it needs it to sign
att package or to verify att package
2014-05-26 10:28:16 +02:00
Lukasz Rymanowski
85e82427f0 android/bluetooth: Add bonded information to found device callback
If device is bonded then discoverable flag is not set. This cause that
gatt application will not get scan callback with advertising bonded
device.
2014-05-22 12:45:50 +02:00
Szymon Janc
889c3c03ad android/bluetooth: Simplify check if device type changed
This makes code easier to follow. Also LE address type is not lost
if dual mode device connected over BR/EDR.
2014-05-19 10:17:25 +02:00
Szymon Janc
00d7691055 android/bluetooth: Track if paired device is bonded
This is a preparation for correctly handling no bond pairing.

Currently paired but not bonded devices are left on list of bonded
devices in Framework until BT is restarted on device. This is due to
Android Framework is not allowing stack to unpair device by its own
(setting bond state bonded->no_bond is ignored).
2014-05-19 10:17:25 +02:00
Szymon Janc
b9d6d37fd5 android/bluetooth: Fix unpairing dual mode device
If device is paired on LE and BR/EDR it should be unpaired on both
bearers.
2014-05-19 10:17:25 +02:00
Szymon Janc
033024822b android/bluetooth: Fix pairing of dual mode devices
It is possible that dual mode device is paired both for LE and BR/EDR
link. This patch add tracking of this.

Due to HAL API contraints second pairing will result in following bond
state changed events:
bonded -> bonding (success) -> bonded (success/failed)
2014-05-19 10:17:25 +02:00
Szymon Janc
8911e43cb0 android/bluetooth: Track device last connected bearer
This allows to correctly choose address type when pairing dual mode
devices.
2014-05-19 10:17:25 +02:00
Andrzej Kaczmarek
c3364dee4a android/bluetooth: Add support to read connection RSSI 2014-05-19 10:10:33 +02:00
Szymon Janc
db36dfe7c9 android/bluetooth: Fix minor codestyle issues 2014-05-16 13:22:43 +02:00
Grzegorz Kolodziejczyk
c12323a594 android/bluetooth: Add function for checking device bond state
This will be used by GATT HAL.
2014-05-14 15:24:00 +02:00
Szymon Janc
905d6e8935 android/bluetooth: Make sure proper controller mode is set on start
BR/EDR and LE features can be toggled before daemon is started and
we should not assume their state.
2014-05-13 18:20:09 +02:00
Szymon Janc
aee00a5289 android/bluetooth: Always create device object in create bond
If device is not known (ie. OOB pairing) create new device object
so it can be later used in pairing events.
2014-05-09 11:40:51 +02:00
Szymon Janc
36a0e1fb63 android/bluetooth: Pass device to send_ssp_request
This allows to fill event with all required data.
2014-05-09 11:40:51 +02:00
Szymon Janc
8bd50962fc android/bluetooth: Pass device to set_device_bond_state
This is in preparation for always having device object present when
handling events.
2014-05-09 11:40:51 +02:00
Szymon Janc
be0e4f04cb android/bluetooth: Rename get_adapter_discovering_type function
Rename it to get_supported_discovery_type which better describes
function purpose.
2014-05-06 14:32:52 +02:00
Szymon Janc
f7b799f5c0 android/bluetooth: Fix sending discovery state changed events
Those events should be send only if discovery was started/stoped from
bluetooth HAL.
2014-05-06 14:32:52 +02:00
Szymon Janc
5e7dfbd7d7 android/bluetooth: Avoid starting/stopping discovery with no type 2014-05-06 14:32:52 +02:00
Szymon Janc
a79f778498 android/bluetooth: Refactor mgmt_discovering_event
This make funtion simpler and fix bogus discovery restart (which
should only happen for LE scanning triggered by GATT HAL).
2014-05-06 14:32:51 +02:00
Szymon Janc
d1f4727b77 android/bluetooth: Fix bt_le_discovery_stop
This fix invalid use of adapter.exp_discovery_type and not clearing
callback.
2014-05-06 14:32:51 +02:00
Szymon Janc
5437569d89 android/bluetooth: Fix bt_le_discovery_start
This fix wrong use of adapter.exp_discovery_type and setting callback
even if failed to start discovery.
2014-05-06 14:32:51 +02:00
Szymon Janc
f355d70d2f android/bluetooth: Refactor handle_cancel_discovery_cmd
This makes function flow easier to follow. Also fix usage of
adapter.exp_discovery_type which should be used only when stopping
currently running discovery session to restart it with new type.
2014-05-06 14:32:51 +02:00
Szymon Janc
658aa0968d android/bluetooth: Refactor handle_start_discovery_cmd
This makes function flow easier to follow. Also fix usage of
adapter.exp_discovery_type which should be used only when stopping
currently running discovery session to restart it with new type.
2014-05-06 14:32:51 +02:00
Lukasz Rymanowski
705762aee4 android/bluetooth: Add function for getting device Android name
This will be used by GATT HAL
2014-04-30 17:30:01 +02:00
Szymon Janc
7a2d604673 android: Make multi-line comments style consistent
Use common style for multi-line comments consistent with rest of
codebase.
2014-04-29 13:31:00 +02:00
Szymon Janc
0009f141a7 android/bluetooth: Add function for getting device Android type
This will be used by GATT HAL.
2014-04-28 14:11:54 +02:00
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