Verifying and Debugging

To verify and debug the Bluetooth stack, use the tools provided in AOSP and the Bluetooth Special Interest Group's (SIG) tests.

Testing and verifying

To test the Bluetooth stack, AOSP provides a mix of unit tests, CTS tests, and tools for the Bluetooth Profile Tuning Suite.

Unit tests in AOSP

AOSP includes functional and unit tests for the default Bluetooth stack. These tests are located in system/bt/test. To run the AOSP tests, do the following:

  1. Stop the Android runtime:
    adb shell stop
  2. From the test directory, run the shell executable file and include options if you want to run a specific test or test suite:
  3. When the tests finish, re-enable the Android runtime:
    adb shell start

The list of test names can be found in the file system/bt/test/

Android Comms Test Suite

The Android Comms Test Suite (ACTS) performs automated testing of connectivity stacks, such as Wi-Fi, Bluetooth, and cellular services. The testing tool requires adb and python, and it can be found in tools/test/connectivity/acts.

The ACTS tests for Bluetooth and Bluetooth Low Energy are found in tools/test/connectivity/acts/tests/google/bt and tools/test/connectivity/acts/tests/google/ble respectively.

Profile Tuning Suite

The Bluetooth SIG provides the Bluetooth Profile Tuning Suite (PTS), a testing tool for protocol and profile interoperability. For more information, see the Bluetooth Profile Tuning Suite site.

AOSP provides additional tools to complement the Bluetooth PTS. These tools are located in tools/test/connectivity/acts/tests/google/bt/pts.

CTS Tests

The Compatibility Test Suite (CTS) includes tests for the Bluetooth stack. These are located in cts/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth.

Debugging options

AOSP provides different methods of debugging a device's Bluetooth stack, including logs and bug reports. These methods may not work for issues that cannot be reproduced or for audio issues, which can be affected by multiple parts of the platform and device.

Debugging with bug reports

To check the Bluetooth service status using dumpsys, use the following command:

adb shell dumpsys bluetooth_manager

By default, all log messages are trace level 2. To find out more about the logging levels and change the logging levels for different profiles, look in system/bt/conf/bt_stack.conf.

To extract snoop logs from the bug report, use the btsnooz script.

  1. Get
  2. Extract the text version of the bug report.
  3. Run on the text version of the bug report: BUG_REPORT.txt > BTSNOOP.log

Debugging with logs

In Android 4.4 and later, you can manually collect BTSnoop logs, which resemble the snoop format in RFC 1761. These logs capture the Host Controller Interface (HCI) packets. For most Android devices, the logs are stored in data/misc/bluetooth/logs.

For privacy reasons, always-on, "in-memory" BTSnoop only logs non-personal information and events. To log all data, the user needs to enable Bluetooth HCI snoop by doing the following:

  1. Enable Developer options on the device.
  2. In the Developer options menu, activate the Enable Bluetooth HCI snoop log toggle.
  3. Restart Bluetooth for logging to take effect.