Android Bluetooth Architecture

Muhamed Riyas M
3 min readMar 12, 2019

In this blog, I am going to tell more about the android Bluetooth architecture.

Some Basics

Bluetooth is a wireless technology standard for exchanging data between fixed and mobile devices over short distances using short-wavelength from 2.400 to 2.485 GHz.

Bluetooth is managed by Bluetooth Special Interest Group (SIG) and which has more than 30k member companies. The Bluetooth SIG supervises the development of the specifications, manages the qualification program and protects the trademarks.

Android Bluetooth.

Android supports Bluetooth from Android 2.0 Eclair (API 5) but BLE (Bluetooth Low Energy) support only from Android 4.3 Jelly Bean (API 18). In Android 8.0, the native Bluetooth stack is fully qualified for Bluetooth 5. To use available Bluetooth 5 features, the device needs to have a Bluetooth 5 qualified chipset.

Using the Bluetooth APIs, an Android application can perform the following:

  • Scan for other Bluetooth devices
  • Query the local Bluetooth adapter for paired Bluetooth devices
  • Establish RFCOMM channels
  • Connect to other devices through service discovery
  • Transfer data to and from other devices
  • Manage multiple connections

Android provides a default Bluetooth stack, BlueDroid. Android also used BlueZ, until it switched to its own BlueDroid stack in late 2012

Read more difference at bluedroid vs bluez

Are you bored with history? Then will more talk about the architecture of Android Bluetooth Stack

As mentioned Bluedroid is the Android Bluetooth stack provided by Broadcom and is now opensource in Android. BlueDroid is divided into 2 layers

  1. Bluetooth Embedded System (BTE): Implements the core functionality
  2. Bluetooth Application Layer(BTA): Communicates with android apps
Bluetooth Architecture Android 8.0 or later

Architecture Components

  1. Application framework
    At the application framework level is the app’s code, which utilizes the Android Bluetooth APIs to interact with the Bluetooth hardware. Internally, this code calls the Bluetooth process through the Binder IPC mechanism.
  2. Bluetooth system service
    The Bluetooth system service, located in “packages/apps/Bluetooth”, is packaged as an Android app and implements the Bluetooth service and profiles at the Android framework layer. This app calls into the HAL layer via JNI.
  3. JNI
    The JNI code associated with android.bluetooth is located in “packages/apps/Bluetooth/jni”. The JNI code calls into the HAL layer and receives callbacks from the HAL when certain Bluetooth operations occur, such as when devices are discovered.
  4. HAL
    The Hardware Abstraction Layer(HAL) defines the standard interface that the Android Bluetooth APIs and Bluetooth process call into and that you must implement to have your Bluetooth hardware function correctly. The header files for the Bluetooth HAL is located in the “hardware/libhardware/include/hardware/bluetooth.h” and “hardware/libhardware/include/hardware/bt_*.h” files.
  5. Bluetooth stack
    The default Bluetooth stack is provided for you and is located in “external/bluetooth/bluedroid”. The stack implements the generic Bluetooth HAL as well as customizes it with extensions and configuration changes.
  6. Vendor extensions
    To add custom extensions and an HCI layer for tracing, you can create a libbt-vendor module and specify these components
  7. Vendor implementation (In Android 8.0)
    Vendor devices interact with the Bluetooth stack using the Hardware Interface Design Language (HIDL).
Bluetooth Architecture Android 7.x and earlier

HIDL(Hardware Interface Design Language)
HIDL defines the interface between the Bluetooth stack and the vendor implementation. To generate the Bluetooth HIDL files, pass the Bluetooth interface files into the HIDL generation tool. The interface files are located in “hardware/interfaces/bluetooth”.

Difference Between Architecture Implementation Across Different Android OS

Android 7.x and earlier architecture
A Bluetooth system service communicates with the Bluetooth stack through JNI and with applications through Binder IPC. The system service provides developers with access to various Bluetooth profiles.

Android 8.0 and later architecture

The Android 8.0 Bluetooth stack is a fully qualified Bluetooth stack. The qualification listing is on the Bluetooth SIG website under QDID 97584.

The core Bluetooth stack resides in “system/bt”. Development happens in AOSP, and contributions are welcome.

Hope you enjoyed this blog !!!
Follow me on Medium and let us share the knowledge together!!!

Cheers!!
Riyas.

References :

  1. https://source.android.com/devices/bluetooth
  2. https://en.wikipedia.org/wiki/Bluetooth

--

--

Muhamed Riyas M

Life On Android | Jet Pack | MVVM | MVP | Kotlin | Android Components | Wireless technology | IoT | Firebase | Git |