如何获得自定义传感器。imx8.so 以供 Android 使用?
How to get a custom sensors.imx8.so to be used by Android?
我正在将 Android 移植到定制的 iMX8 板。
这项工作的一部分是为此板的硬件(尤其是加速度计)实施 libsensors。
ST提供传感器HAL。此 HAL 正在生成传感器。imx8.so,当构建 Android 时:
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 正在构建传感器。imx8.so,但未使用它或 运行 它的任何部分。 (我添加了很多日志记录来检查。)
如何让 Android 使用传感器。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.
这看起来好像我需要添加传感器。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
我选的是1.0版本,看了之后https://source.android.com/devices/sensors/hal-interface and https://source.android.com/devices/sensors/sensors-hal2
(ST 传感器 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>
我正在将 Android 移植到定制的 iMX8 板。
这项工作的一部分是为此板的硬件(尤其是加速度计)实施 libsensors。
ST提供传感器HAL。此 HAL 正在生成传感器。imx8.so,当构建 Android 时:
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 正在构建传感器。imx8.so,但未使用它或 运行 它的任何部分。 (我添加了很多日志记录来检查。)
如何让 Android 使用传感器。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.
这看起来好像我需要添加传感器。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
我选的是1.0版本,看了之后https://source.android.com/devices/sensors/hal-interface and https://source.android.com/devices/sensors/sensors-hal2
(ST 传感器 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>