本文主要介绍如何使用AOSP中提供的工具测试,调试Wi-Fi 和 Bluetooth。
Bluetooth
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:
Stop the Android runtime: adb shell stop
From the test directory, run the shell executable file and include options if you want to run a specific test or test suite: ./run_unit_tests.sh TEST_GROUP_NAME TEST_NAME OPTIONS
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/run_unit_tests.sh
.
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.
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.
Get btsnooz.py
Extract the text version of the bug report. Run btsnooz.py on the text version of the bug report:
btsnooz.py BUG_REPORT.txt > BTSNOOP.log
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:
To test the Wi-Fi framework, AOSP provides a mix of unit tests, integration tests (ACTS), and CTS tests.
AOSP includes functional and unit tests for the default Wi-Fi framework: both for the Wi-Fi Manager (app-side code) and the Wi-Fi Service.
Wi-Fi Manager tests:
Located in frameworks/base/wifi/tests
Run using the following shell executable (read the file for more execution options):
% ./frameworks/base/wifi/tests/runtest.sh
Wi-Fi Service tests:
Run this manual test to verify that old files in the tombstone directory are being deleted.
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 Wi-FI are found in tools/test/connectivity/acts/tests/google/wifi
, with an example test configuration in the same directory: example_config.json
.
The Compatibility Test Suite (CTS) includes tests for the Wi-Fi framework. These are located in cts/tests/tests/net/src/android/net/wifi
. The Wi-Fi CTS tests require the device-under-test to be associated with an Access Point at the start of the test run.
Android 9 improves Wi-Fi logging to make it easier to debug Wi-Fi issues. In Android 9, driver/firmware ring buffers can always be on. Bug reports may automatically be triggered when a bad state is detected (only in userdebug and eng builds). When the latest Wi-Fi HAL (version 1.2) is used, firmware debug buffers are stored in the HAL instead of the framework to save IPC costs.
For a reference implementation, see the default implementation in the vendor HAL.
You can disable firmware logging by setting the resource, config_wifi_enable_wifi_firmware_debugging
, to false.
The integration test can be found at /tools/test/connectivity/acts/tests/google/wifi/WifiDiagnosticsTest.py
.
Verified firmware dumps are persisted in the appropriate tombstone directory in flash for userdebug builds. Dumpstate collects from this directory when creating a bug report.
frameworks/opt/net/wifi/tests/wifitest
Run using the following shell executable (read the file for more execution options):
% ./frameworks/opt/net/wifi/tests/wifitests/runtest.sh
/lshal-debug/[email protected]__IWifi_default.txt
holds the archived firmware logs.