Introduction
The Bluetooth stack in Android (historically "Fluoride", recently rewritten in Rust as "Babel" or "Gabeldorsche") resides in the system framework. To communicate with the actual Bluetooth radio chip (the controller), Android uses the Bluetooth Hardware Abstraction Layer (HAL).
Bluetooth HAL Interface
The core Bluetooth HAL (android.hardware.bluetooth) is surprisingly thin. Its primary job is to establish a Host Controller Interface (HCI) connection between the framework's Bluetooth stack (the Host) and the vendor's Bluetooth firmware (the Controller).
Once the HAL initializes the hardware via UART or USB, it simply passes raw HCI packets back and forth.
// Writing an HCI packet from the framework to the vendor HAL
Return<void> sendHciCommand(const hidl_vec<uint8_t>& command);
The heavy lifting of managing pairings, connections, and Bluetooth profiles (like hands-free calling or file transfer) is done entirely in the framework, not the HAL.
HCI Vendor Extensions
While standard HCI commands are defined by the Bluetooth SIG, Android allows vendors to implement custom HCI commands via the IBluetoothHci interface. Vendors use these extensions to implement proprietary power-saving features, custom antenna switching for better range, or firmware logging and diagnostics.
When the framework boots, it queries the HAL for supported vendor extensions and configures the stack accordingly.
A2DP Offload HAL
Normally, to play audio over Bluetooth, the Android CPU reads the music, encodes it into a Bluetooth format like SBC or aptX, wraps it in HCI packets, and sends it to the HAL. This consumes significant CPU power.
To save battery, modern devices use the Audio A2DP Offload HAL. The Android CPU simply sends the raw compressed MP3/AAC file directly to a dedicated DSP on the SoC. The DSP decodes the audio, encodes it to aptX, and sends it directly to the Bluetooth radio, bypassing the main Android CPU entirely. The IBluetoothAudioProvider interface orchestrates this handoff.
Bluetooth Profile HAL
Certain legacy profiles, particularly those related to telephony and low-level hardware integration, require their own specific HALs. For instance, the IBluetoothSimAccess interface allows the Bluetooth controller to directly query the SIM card on the device to provide SIM Access Profile (SAP) functionality to a paired car dashboard.