本文主要是介绍Android的硬件接口HAL-2 HIDL,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
没写完哈。
不说废话,直接上干活。
1 创建HAL
2 生成桩代码
PACKAGE=vendor.xxx.hardware.logiuvc2@1.0
LOC=vendor/xxx/hardware/xxx2/1.0/default
hidl-gen -o $LOC -Lc++-impl -rvendor.xxx.hardware:vendor/xxx/hardware -randroid.hidl:system/libhidl/transport $PACKAGE
这里有个疑问是包名和路径的关系,回去在自己的板子上再试试吧。
3 增加hash
hidl-gen -Lhash -randroid.hardware.xxx:hardware/interfaces/xxx -randroid.hidl:system/libhidl/transport android.hardware.xxx@1.0 > hardware/interfaces/xxx/current.txt
4 生成Android.bp
source system/tools/hidl/update-makefiles-helper.sh
do_makefiles_update vendor.xxx.hardware:vendor/xxx android.hardware:hardware/interfaces android.hidl:system/libhidl/transport
5 在default中增加service.cpp
6 hw_get_module
7 在default中增加Android.bp
cc_binary {
name: "android.hardware.xxx-service",
defaults: ["hidl_defaults"],
vendor: true,
relative_install_path: "hw",
srcs: [
"service.cpp",
"xxx.cpp"
],
init_rc: ["android.hardware.xxx-service.rc"],
shared_libs: [
"vendor.xxx.hardware.xxx2@1.0",
"libhidlbase",
"libhidltransport",
"liblog",
"libutils",
],
vintf_fragments: ["android.hardware.xxx-service.xml"],
}
8 android.hardware.xxx-service.xml
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.xxx.hardware.xxx2</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>Ilogihid</name>
<instance>default</instance>
</interface>
</hal>
</manifest>
9 android.hardware.xxx-service.rc
service android.hardware.xxx-service /vendor/bin/hw/android.hardware.xxx-service
class hal
user system
group system
10 增加client
11 绕开Android12限制。
12 编译
使用mmm
13 兼容性矩阵
adb push compatibility_matrix.device.xml /system/etc/vintf/compatibility_matrix.device.xml
adb push compatibility_matrix.xml /vendor/etc/vintf/compatibility_matrix.xml
adb push android.hardware.tc_uvc-service.xml /vendor/etc/vintf/manifest/android.hardware.xxx-service.xml
14 使用脚本拷贝
scp scm@192.168.1.1:/LINUX/android/out/target/product/kalama/vendor/bin/hw/android.hardware.tc_uvc-service .
adb push android.hardware.xxx-service /vendor/bin/hw
scp scm@192.168.1.1:/LINUX/android/out/target/product/kalama/system/bin/xxx_test .
adb push xxx_test /vendor/bin
#scp scm@192.168.1.1:/LINUX/android/out/target/product/kalama/vendor/lib/hw/vendor.xxx.hardware.xxx2@1.0-impl.so .
#adb push vendor.hardware.test@1.0-impl.so /vendor/lib/hw
scp scm@192.168.1.1:/LINUX/android/out/target/product/kalama/vendor/lib/vendor.xxx.hardware.xxx2@1.0.so .
adb push vendor.xxx.hardware.xxx2@1.0.so /vendor/lib
scp scm@192.168.1.1:/LINUX/android/out/target/product/kalama/vendor/lib64/vendor.xxx.hardware.xxx2@1.0.so .
adb push vendor.xxx.hardware.xxx2@1.0.so /vendor/lib64
15 关闭tee
adb setenforce 0
16 运行
开两个窗口
。。。
这篇关于Android的硬件接口HAL-2 HIDL的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!