Bt: Add support for interop conf feature

Snapshot of:
558ee40545537cac75f561c6b35c21ec388218a5
3e76e1c8460e566e37eb2e6fa2116804d967e4e7
5229383750c1278c7bd3d940d59c5c50a18a1053
5752baca5abdfa5f30e803a67827f119fbe03339
4a63a13ebe0b8576a30fe1d5efc1b6d99ebab28f
2a7911429a78d33de0570335fac08ef9469a3621
73c5720caabd944c11906192298c858e2e586885
2c3b5e9ac41b4bbb946387334e7e0b0a4c32c65e
d907b0cf64f1eecdd87b96c09980d89ccf9fc897
a7d8799123a10cfc5a32bc8aafdd938166f912db
dbd88bfc3f8a63c8df24571205413a1170e947e2
319d2310997dd53f835e1729aa513bef6839c32e
7489832bbf0482ac19bd67d9446f8b0323c850d9
deb8aa88ab3df0f11981311beb50281c0cef1f43
050e9ea9d75d5a576aedff7e0a155b5b98a582ae
9a080f23406f101f76956b8226a5956e0e875062
d1a2484905c10821dfb5dfa7bd5579e5ff5f307e
f726e3467f570f8c28d9ea9d5f8c4040445e7791
272d58799f73c044aadc9daf74991e39e7b93bff
c67929e52961254985b93835e0834de2c0be40a8
2e43f9bb24046c88fc443f801d4e8ad5fe048a58
5c48da0d4631157f7cd6541363758c6d83b36691
01922f885641365887b4f1900355ef35cb816d2e
3dfd8a30897ea1c5d4b4548be820a96cbfb79f3d
ae79a1e066e9ae7c7359c5f2a19a6fb0485a2217
a85581f04f0d97d769405d400f4a0aa44f17e3a2
a1234fd3d1063c8cc31da64be1ac373112c4d987
c778c918e8249693d0bc5f483299396a83dc19e3
9419b00e227ec087eb6c79d33a6be3d2e25b32b9
502ddc2b9d115eaf46e113569d0720bb977d058b

Test: atest net_test_device
Bug: 252903680
Ignore-AOSP-First: Prevent merge conflict
Change-Id: I959ee79fe74d0b22a26b3df1633ee88670d396d1
(cherry picked from commit c935977bb382a5c570f5273b7404c3beb6537d89)
17 files changed
tree: d7a697877a280149f46c9e2e5e6fecba7bd33af9
  1. android/
  2. apex/
  3. floss/
  4. framework/
  5. pandora/
  6. service/
  7. system/
  8. tools/
  9. .clang-format
  10. .gitignore
  11. .style.yapf
  12. Android.bp
  13. AndroidTestTemplate.xml
  14. BUILD.gn
  15. build.py
  16. Cargo.toml
  17. CleanSpec.mk
  18. EventLogTags.logtags
  19. METADATA
  20. MODULE_LICENSE_APACHE2
  21. NOTICE
  22. OWNERS
  23. OWNERS_automotive
  24. OWNERS_chromeos
  25. PREUPLOAD.cfg
  26. README.md
  27. rustfmt.toml
  28. TEST_MAPPING
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 a Debian based distribution:

  • Debian Bullseye or newer
  • Ubuntu 20.10 or newer
  • Clang-11 or Clang-12
  • Flex 2.6.x
  • Bison 3.x.x (tested with 3.0.x, 3.2.x and 3.7.x)

You'll want to download some pre-requisite packages as well. If you're currently configured for AOSP development, you should have most required packages. Otherwise, you can use the following apt-get list or use the --run-bootstrap option on build.py (see below) to get a list of packages missing on your system:

sudo apt-get install repo git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev gcc-multilib g++-multilib \
  x11proto-core-dev libx11-dev libncurses5 \
  libgl1-mesa-dev libxml2-utils xsltproc unzip liblz4-tool libssl-dev \
  libc++-dev libevent-dev \
  flatbuffers-compiler libflatbuffers1 openssl \
  libflatbuffers-dev libtinyxml2-dev \
  libglib2.0-dev libevent-dev libnss3-dev libdbus-1-dev \
  libprotobuf-dev ninja-build generate-ninja protobuf-compiler \
  libre2-9 debmake \
  llvm libc++abi-dev \
  libre2-dev libdouble-conversion-dev \
  libgtest-dev libgmock-dev libabsl-dev

You will also need a recent-ish version of Rust and Cargo. Please follow the instructions on Rustup to install a recent version.

Download source

mkdir ~/fluoride
cd ~/fluoride
git clone https://android.googlesource.com/platform/packages/modules/Bluetooth

Using --run-bootstrap on build.py

build.py is the helper script used to build Fluoride for Linux (i.e. Floss). It accepts a --run-bootstrap option that will set up your build staging directory and also make sure you have all required system packages to build (should work on Debian and Ubuntu). You will still need to build some unpackaged dependencies (like libchrome, modp_b64, googletest, etc).

To use it:

./build.py --run-bootstrap

This will install your bootstrapped build environment to ~/.floss. If you want to change this, just pass in --bootstrap-dir to the script.

Build dependencies

The following third-party dependencies are necessary but currently unavailable via a package manager. You may have to build these from source and install them to your local environment.

  • libchrome
  • modp_b64

We provide a script to produce debian packages for those components. Please see the instructions in build/dpkg/README.txt for more details.

cd system/build/dpkg
mkdir -p outdir/{modp_b64,libchrome}

# Build and install modp_b64
pushd modp_b64
./gen-src-pkg.sh $(readlink -f ../outdir/modp_b64)
popd
sudo dpkg -i outdir/modp_b64/*.deb

# Build and install libchrome
pushd libchrome
./gen-src-pkg.sh $(readlink -f ../outdir/libchrome)
popd
sudo dpkg -i outdir/libchrome/*.deb

Rust dependencies

Note: Handled by --run-bootstrap option.

Run the following to install Rust dependencies:

cargo install cxxbridge-cmd

Stage your build environment

Note: Handled by --run-bootstrap option.

For host build, we depend on a few other repositories:

Clone these all somewhere and create your staging environment.

export STAGING_DIR=path/to/your/staging/dir
mkdir ${STAGING_DIR}
mkdir -p ${STAGING_DIR}/external
ln -s $(readlink -f ${PLATFORM2_DIR}/common-mk) ${STAGING_DIR}/common-mk
ln -s $(readlink -f ${PLATFORM2_DIR}/.gn) ${STAGING_DIR}/.gn
ln -s $(readlink -f ${RUST_CRATE_DIR}) ${STAGING_DIR}/external/rust
ln -s $(readlink -f ${PROTO_LOG_DIR}) ${STAGING_DIR}/external/proto_logging

Build

We provide a build script to automate building assuming you've staged your build environment already as above. At this point, make sure you have all the pre-requisites installed (i.e. bootstrap option and other dependencies above) or you will see failures. In addition, you may need to set a --libdir= if your libraries are not stored in /usr/lib by default.

./build.py

This will build all targets to the output directory at --bootstrap-dir (which defaults to ~/.floss). You can also build each stage separately (if you want to iterate on something specific):

  • prepare - Generate the GN rules
  • tools - Generate host tools
  • rust - Build the rust portion of the build
  • main - Build all the C/C++ code
  • test - Build all targets and run the tests
  • clean - Clean the output directory

You can choose to run only a specific stage by passing an arg via --target.

Currently, Rust builds are a separate stage that uses Cargo to build. See gd/rust/README.md for more information. If you are iterating on Rust code and want to add new crates, you may also want to use the --no-vendored-rust option (which will let you use crates.io instead of using a pre-populated vendored crates repo).

Run

By default on Linux, we statically link libbluetooth so you can just run the binary directly. By default, it will try to run on hci0 but you can pass it --hci=N, where N corresponds to /sys/class/bluetooth/hciN.

$OUTPUT_DIR/debug/btadapterd --hci=$HCI INIT_gd_hci=true