HID: Update condition for checking LE HID handle validity

1) Pair and connect with BR/EDR HID devices and LE devices
   such that the total number of connected paired devices
   becomes 7. It is not required that connection to all devices be
   maintained, they can be disconnected as well afterwards.
2) Pair and connect with a new LE device. Connection fails
3) Retry connecting to same LE device. Connection does not go through
4) Turn BT off

Observed Result:
1) LE device cannot be connected in step 2
2) Tombstone in BT while switching off BT with below signature

backtrace:
    #00 pc 0000000000092438  /system/lib64/libc.so (ifree+88)
    #01 pc 000000000009298c  /system/lib64/libc.so (je_free+120)
    #02 pc 00000000001b266c  /system/lib64/hw/bluetooth.default.so (_Z18osi_free_and_resetPPv+84)
    #03 pc 0000000000062f84  /system/lib64/hw/bluetooth.default.so
    (_Z17bta_hh_sm_executeP14tBTA_HH_DEV_CBtP12tBTA_HH_DATA+880)
    #04 pc 0000000000063120  /system/lib64/hw/bluetooth.default.so (_Z16bta_hh_hdl_eventP6BT_HDR+296)
    #05 pc 000000000007bbc4  /system/lib64/hw/bluetooth.default.so (_Z13bta_sys_eventP6BT_HDR+60)
    #06 pc 00000000001b4d88  /system/lib64/hw/bluetooth.default.so (_ZL22internal_dequeue_readyPv+80)
    #07 pc 00000000001b96f4  /system/lib64/hw/bluetooth.default.so (_ZL11run_reactorP9reactor_ti+312)
    #08 pc 00000000001b9590  /system/lib64/hw/bluetooth.default.so (_Z13reactor_startP9reactor_t+80)
    #09 pc 00000000001baf24  /system/lib64/hw/bluetooth.default.so (_ZL10run_threadPv+256)
    #10 pc 0000000000067bc4  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
    #11 pc 000000000001f264  /system/lib64/libc.so (__start_thread+68)

Root Cause:
Wrong conditional check in macro BTA_HH_IS_LE_DEV_HDL_VALID which ignores the condition that max
14 HID devices can be connected and all of them can be LE as well.

Fix:
Update the condition in macro BTA_HH_IS_LE_DEV_HDL_VALID to compare with BTA_HH_MAX_DEVICE instead of
BTA_HH_LE_MAX_KNOWN

Test: Not yet performed, only code and log analysis

Fixes: 71842479
Change-Id: I2b56b6f109787608e25c340150be313f0f5397be
1 file changed
tree: 69cbcf1ab10b483332dec4a73c0608fe701701e0
  1. audio_a2dp_hw/
  2. binder/
  3. bta/
  4. btcore/
  5. btif/
  6. build/
  7. conf/
  8. device/
  9. doc/
  10. embdrv/
  11. hci/
  12. include/
  13. internal_include/
  14. main/
  15. osi/
  16. service/
  17. stack/
  18. test/
  19. tools/
  20. types/
  21. udrv/
  22. utils/
  23. vendor_libs/
  24. vnd/
  25. .clang-format
  26. .gitignore
  27. .gn
  28. Android.bp
  29. Android.mk
  30. BUILD.gn
  31. CleanSpec.mk
  32. EventLogTags.logtags
  33. MODULE_LICENSE_APACHE2
  34. NOTICE
  35. OWNERS
  36. PREUPLOAD.cfg
  37. README.md
README.md

Fluoride Bluetooth stack

Building and running on AOSP

Just build AOSP - Fluoride is there by default.

Building and running on Linux

Instructions for Ubuntu, tested on 14.04 with Clang 3.5.0 and 16.10 with Clang 3.8.0

Download source

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

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 ../../../external/googletest googletest

Generate your build files

cd ~/fluoride/bt
gn gen out/Default

Build

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.

Run

cd ~/fluoride/bt/out/Default
LD_LIBRARY_PATH=./ ./bluetoothtbd -create-ipc-socket=fluoride

Eclipse IDE Support

  1. Follows the Chromium project Eclipse Setup Instructions until “Optional: Building inside Eclipse” section (don't do that section, we will set it up differently)

  2. Generate Eclipse settings:

cd system/bt
gn gen --ide=eclipse out/Default
  1. In Eclipse, do File->Import->C/C++->C/C++ Project Settings, choose the XML location under system/bt/out/Default

  2. 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”

  3. Goto Behaviour tab, change clean command to “-t clean”