commit | 8451ad010e26562d4a4c7d0d135c70c4325ee6b5 | [log] [tgz] |
---|---|---|
author | Emil Lenngren <emil.lenngren@gmail.com> | Mon Dec 19 19:21:19 2016 +0000 |
committer | Andre Eisenbach <eisenbach@google.com> | Fri May 12 22:27:08 2017 +0000 |
tree | ef178e3c90668a195a8619d5f91b878281d84775 | |
parent | d62e522131e8646830f846fdcb292870d7fb9d7b [diff] |
Fix BLE white list issues Since Bluetooth 4.2 and errata ESR08 there may not be more than one connection between two LE device addresses. Also the stack assumes there is at maximum one connection to the same address. This patch makes sure there are no connected devices in the white list when a connection attempt is started. Since some (even 4.2) controllers don't handle this correctly, currently this method is used regardless of controller in this patch. When the maximum L2CAP connections were reached and a new connection was established to a device using auto connect, the stack hung and would no longer create new connections until Bluetooth was restarted, since the state change to BLE_CONN_IDLE was forgotten. This patch resets the state correctly, and also never initiates a connection unless there is space to avoid connect-disconnect loop. There were also bugs in the background_connections hash map; memory was not freed when an element was erased and an incorrect hash function which used the pointer to a bd addr instead of the bd addr itself which basically meant that elements were never removed. This patch removes the dynamic memory allocation and uses a correct hash function. There was a bug that might lead to that the white list was filled beyond its maximum, due to the counter was updated on the HCI command complete event, which might run too late. Now the space is instead calculated based on what commands have been sent to the controller. The address type of the address added to the white list must also be tracked, otherwise it might be updated due to a BLE scan, and later the wrong address is removed from the white list. This patch fixes this. (Preferably 49-bit bd addrs should be used as identifier through the whole stack but we're not there yet.) There was a queue of size 10 with pending white list operations. That queue got full if there was initially 10 devices in the white list, then the 10 devices were removed and immediately after 10 other devices were added. This patch removes the queue altogether by instead syncing against the background_connections hash map. Bug: https://code.google.com/p/android/issues/detail?id=219910 Test: stress-testing with a bunch of BLE devices and inspecting HCI log Change-Id: I78de654ffbea5f4962a189caf984f7f2934e8fbe
Just build AOSP - Fluoride is there by default.
Instructions for Ubuntu, tested on 14.04 with Clang 3.5.0 and 16.10 with Clang 3.8.0
mkdir ~/fluoride cd ~/fluoride git clone https://android.googlesource.com/platform/system/bt
Install dependencies (require sudo access):
cd ~/fluoride/bt build/install_deps.sh
Then fetch third party dependencies:
cd ~/fluoride/bt mkdir third_party cd third_party git clone https://github.com/google/googletest.git git clone https://android.googlesource.com/platform/external/aac git clone https://android.googlesource.com/platform/external/libchrome git clone https://android.googlesource.com/platform/external/libldac git clone https://android.googlesource.com/platform/external/modp_b64 git clone https://android.googlesource.com/platform/external/tinyxml2 git clone https://android.googlesource.com/platform/hardware/libhardware
And third party dependencies of third party dependencies:
cd fluoride/bt/third_party/libchrome/base/third_party mkdir valgrind cd valgrind curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/valgrind.h?format=TEXT | base64 -d > valgrind.h curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/memcheck.h?format=TEXT | base64 -d > memcheck.h
NOTE: If system/bt is checked out under AOSP, then create symbolic links instead of downloading sources
cd system/bt mkdir third_party cd third_party ln -s ../../../external/aac aac ln -s ../../../external/libchrome libchrome ln -s ../../../external/libldac libldac ln -s ../../../external/modp_b64 modp_b64 ln -s ../../../external/tinyxml2 tinyxml2 ln -s ../../../hardware/libhardware libhardware ln -s ../../../external/googletest googletest
cd ~/fluoride/bt gn gen out/Default
cd ~/fluoride/bt ninja -C out/Default all
This will build all targets (the shared library, executables, tests, etc) and put them in out/Default. To build an individual target, replace "all" with the target of your choice, e.g. ninja -C out/Default net_test_osi
.
cd ~/fluoride/bt/out/Default LD_LIBRARY_PATH=./ ./bluetoothtbd -create-ipc-socket=fluoride
Follows the Chromium project Eclipse Setup Instructions until "Optional: Building inside Eclipse" section (don't do that section, we will set it up differently)
Generate Eclipse settings:
cd system/bt gn gen --ide=eclipse out/Default
In Eclipse, do File->Import->C/C++->C/C++ Project Settings, choose the XML location under system/bt/out/Default
Right click on the project. Go to Preferences->C/C++ Build->Builder Settings. Uncheck "Use default build command", but instead using "ninja -C out/Default"
Goto Behaviour tab, change clean command to "-t clean"