【问题标题】:How to use Bluetooth HIDL?如何使用蓝牙 HIDL?
【发布时间】:2019-05-21 13:45:16
【问题描述】:

我正在开发一个必须向蓝牙芯片组发送 HCI 命令的 AOSP 应用程序。

我发现我可以使用这个接口:https://source.android.com/reference/hidl/android/hardware/bluetooth/1.0/IBluetoothHci

为了使用它,我尝试关注这个页面:https://source.android.com/devices/architecture/hidl-java/index.html

如果我理解得很好,我必须创建一个 Android.mk 文件并放入

LOCAL_STATIC_JAVA_LIBRARIES +=  android.hardware.bluetooth@1.0

但我不明白怎么做?我还是 AOSP 开发的新手,我该如何使用这个库?

【问题讨论】:

    标签: android bluetooth android-source hci


    【解决方案1】:

    如果您是应用程序开发人员

    您找到的IBluetoothHci 定义了蓝牙硬件抽象层 (HAL) 的接口。 HAL 接口不能直接从应用程序访问,而是由框架服务使用,框架服务提供可供应用程序使用的接口。 我建议查看 Android SDK:https://developer.android.com/guide/topics/connectivity/bluetooth

    如果您是平台开发人员

    如果您打算编写具有更多权限的服务(您自己构建 AOSP 并刷写整个设备),您是对的。IBluetoothHci 是要使用的接口。您可能希望从使用 Android.mk 切换到 Android.bp,因为 Android.mk 文件已被弃用。 在您的代码中,我希望看到如下内容:

    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
    bluetooth.initialize();
    

    关于如何使用 HAL 接口的提示也可以在各自的 VTS 测试中找到(尽管它们是用 C++ 编写的):https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/master/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-05
      • 1970-01-01
      • 2022-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-13
      相关资源
      最近更新 更多