我正在开发一个AOSP应用程序,必须将HCI命令发送到蓝牙芯片组。
我发现我可以使用这个接口: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开发中的新手,如何使用这个库?
发布于 2019-07-10 14:36:57
如果您是应用程序开发人员
您找到的IBluetoothHci定义了蓝牙硬件抽象层(HAL)的接口。HAL接口不能直接从应用程序访问,而是由框架服务使用,框架服务提供了可供应用程序使用的接口。我建议查看Android:https://developer.android.com/guide/topics/connectivity/bluetooth
如果您是platform developer
如果您计划编写一个具有更多权限的服务(您自己构建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++编写的):0TargetTest.cpp
https://stackoverflow.com/questions/56239716
复制相似问题