android - 如何获取自定义的sensors.imx8.so供Android使用?
问题描述
我正在将 Android 移植到自定义 iMX8 板上。
这项工作的一部分是为该板的硬件实现 libsensors,尤其是加速度计。
ST提供一个传感器HAL。当构建 Android 时,此 HAL 正在生成sensors.imx8.so:
smarc_mx8mq:/ # ls -lA vendor/lib/hw/sensors.imx8.so
-rw-r--r-- 1 root root 122684 2021-09-06 14:50 vendor/lib/hw/sensors.imx8.so
smarc_mx8mq:/ # ls -lA vendor/lib64/hw/sensors.imx8.so
-rw-r--r-- 1 root root 144208 2021-09-06 14:50 vendor/lib64/hw/sensors.imx8.so
Android 根本没有使用这个传感器 HAL:
smarc_mx8mq:/ # lsof | grep libsensor
main 3609 root mem REG 179,5 94928 2271 /system/lib64/libsensor.so
main 3610 root mem REG 179,5 71304 1580 /system/lib/libsensor.so
audioserver 3645 audioserve mem REG 179,5 56984 2272 /system/lib64/libsensorprivacy.so
cameraserver 3655 cameraserv mem REG 179,5 40852 1581 /system/lib/libsensorprivacy.so
system_server 3890 system mem REG 179,5 56600 2274 /system/lib64/libsensorservicehidl.so
...a dozen more lines...
smarc_mx8mq:/ # lsof | grep sensors.imx8
1|smarc_mx8mq:/ #
Android 正在构建sensors.imx8.so,但没有使用它或运行它的任何部分。(我添加了很多日志来检查。)
如何让 Android 使用sensors.imx8.so?
更新:
我在以下行中找到了adb logcat
:
09-03 15:45:27.906 3413 3413 I hwservicemanager: getTransport: Cannot find entry android.hardware.sensors@2.0::ISensors/default in either framework or device manifest.
09-03 15:45:27.910 3413 3413 I hwservicemanager: getTransport: Cannot find entry android.hardware.sensors@1.0::ISensors/default in either framework or device manifest.
这看起来好像我需要将sensors.imx8.so 添加到清单中,但是device/embedian/imx8m/smarc_mx8mq/manifest.xml 看起来像:
<manifest version="1.0" type="device" target-level="4">
<hal format="hidl">
<name>android.hardware.radio</name>
<transport>hwbinder</transport>
<version>1.4</version>
<interface>
<name>IRadio</name>
<instance>slot1</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.graphics.allocator</name>
<transport>hwbinder</transport>
<impl level="generic"></impl>
<version>2.0</version>
<interface>
<name>IAllocator</name>
<instance>default</instance>
</interface>
</hal>
...many more...
这些节没有指定库(路径)名称,所以我看不出添加传感器节会有什么帮助。
更新:
与节:
<hal format="hidl">
<name>android.hardware.sensors</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>ISensors</name>
<instance>default</instance>
</interface>
</hal>
现在的错误是:
09-03 15:52:50.873 3890 3987 I ServiceManagement: getService: Trying again for android.hardware.sensors@1.0::ISensors/default...
09-03 15:52:51.873 3890 3987 W ServiceManagement: Waited one second for android.hardware.sensors@1.0::ISensors/default
09-03 15:52:51.874 3890 3987 I ServiceManagement: getService: Trying again for android.hardware.sensors@1.0::ISensors/default...
09-03 15:52:52.874 3890 3987 W ServiceManagement: Waited one second for android.hardware.sensors@1.0::ISensors/default
09-03 15:52:52.876 3890 3987 I ServiceManagement: getService: Trying again for android.hardware.sensors@1.0::ISensors/default...
09-03 15:52:53.876 3890 3987 W ServiceManagement: Waited one second for android.hardware.sensors@1.0::ISensors/default
在阅读https://source.android.com/devices/sensors/hal-interface和https://source.android.com/devices/sensors/sensors-hal2后,我选择了 1.0 版
(ST Sensors HAL 具有来自 1.0 的 get_sensors_list(),但没有来自 2.0 的 getSensorsList()。)
解决方案
解决方案是添加:
PRODUCT_PACKAGES += android.hardware.sensors@1.0-impl
PRODUCT_PACKAGES += android.hardware.sensors@1.0-service
到 smarc_mx8mq.mk 并将该节更正为:
<hal format="hidl">
<name>android.hardware.sensors</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>ISensors</name>
<instance>default</instance>
</interface>
<fqname>@1.0::ISensors/default</fqname>
</hal>
推荐阅读
- mysql - 使用 Traefik 的多主机 wordpress docker
- php - 用户提交表单选择时的PHP查询
- c# - 显式实例化使用 DI 的 C# 类 - 为什么它不起作用?
- c++ - C++:通过引用 unique_ptr 对象使 unique_ptr 为空
- informatica - 过去 30 天的 Informatica 作业信息
- java - Flutter:构建失败可能是由于插件中的 AndroidX 不兼容。该工具即将尝试使用Jetfier解决不兼容问题
- outlook - 在不同的行中键入时 Outlook 文本消失
- python - 我无法在 rasa 中添加音频剪辑作为聊天机器人的输出
- c++ - 警告 C5240:“nodiscard”:在此句法位置忽略属性
- awk - 关于 sed awk grep 的使用