How to use Bluetooth HIDL?

I'm developping an AOSP app that have to send HCI command to Bluetooth chipset.

I found that i can use this interface :

To use it, i tried to follow this page :

If i understand well, i have to create an file and put

LOCAL_STATIC_JAVA_LIBRARIES +=  [email protected]

But i don't understand how ? I'm still new in AOSP developpement, how can i use this library ?


  • If you are an application developer:

    The IBluetoothHci you found defines the interface of the Bluetooth Hardware Abstraction Layer (HAL). HAL interfaces are not accessible from apps directly but are used by framework services, which provide interfaces that can be used by apps. I recommend checking out the Android SDK:

    If you are a platform developer:

    In case you plan to write a service with more privileges (you build the AOSP yourself and flash the whole device) you are right.IBluetoothHci is the interface to use. You would probably want to switch from using to Android.bp, because files are deprecated. In your code I would expect to see something like this:

    import android.hardware.bluetooth.V1_0.IBluetoothHci;
    // retry to wait until the service starts up if it is in the manifest
    IBluetoothHci bluetooth = IBluetoothHci.getService(true /* retry */); // throws NoSuchElementException if not available

    Hints on how to use a HAL interface can also be found in the respective VTS tests (they are written in C++ though):