Android 12.0新增自定义HIDL问题记录

代码

流程和代码可以参考这位大佬的

https://blog.csdn.net/learnframework/article/details/134621556

主要记录发现的问题以及解决方式。

1.首先最外层的bp不要使用update-makefiles.sh 去生成 ,基本上interface下面的文件夹都会被影响,可能会导致编译问题。

bp使用ir目录下面的直接改一下就行了。这里我也贴一下

java 复制代码
hidl_interface {
    name: "android.hardware.hidltest@1.0",
    root: "android.hardware",
    srcs: [
        "ITest.hal",
    ],
    interfaces: [
        "android.hidl.base@1.0",
    ],
    gen_java: true,
}

2.然后编译时候的第一个报错

No more HIDL interfaces can be added to Android. Please use AIDL

修改 system/tools/hidl/build/hidl_interface.go:498

allAospHidlInterfaces末尾新增

"android.hardware.hidltest@1.0": true,

  1. 第二个报错 If this is a new package, add it to the latest framework compatibility matrix.
    往compatibility_matrix.6.xml和compatibility_matrix.current.xml添加hdil配置。
java 复制代码
  <hal format="hidl" optional="true">
        <name>android.hardware.hidltest</name>
        <version>1.0</version>
        <interface>
            <name>ITest</name>
            <instance>default</instance>
        </interface>
    </hal>

现在可以编译通过了,便于修改后直接编译打包。在device/generic/goldfish/vender.mk添加一下。我这里用的target就是模拟器的

lunch sdk_phone_x86_64

java 复制代码
PRODUCT_PACKAGES += \
    android.hardware.audio.service \
    android.hardware.hidltest@1.0-service

最后就是selinux的配置,按照patch来就,由于大佬文章是图片,这里我贴一下新增的文件的内容

system/sepolicy/vendor/hal_hidltest_default.te

java 复制代码
type hidltest, domain;
type hidltest_hwservice,hwservice_manager_type;
type hidltest_exec, exec_type, vendor_file_type, file_type;
hwbinder_use(hidltest);
init_daemon_domain(hidltest)
add_hwservice(hidltest, hidltest_hwservice)

allow hidltest hwservicemanager_prop:file {map read open getattr};
allow hidltest system_file:dir {read open getattr search};

最后结果

相关推荐
xqlily1 天前
Kotlin:现代编程语言的革新者
android·开发语言·kotlin
HelloBan1 天前
如何正确去掉SeekBar的Thumb和按压效果
android
木易 士心1 天前
Android EventBus 源码解析:设计模式、原理与实现
android
ClassOps1 天前
源码阅读 LeakCanary
android
用户2018792831671 天前
为啥现在 Android App 不用手动搞 MultiDex 了?
android
fouryears_234171 天前
如何将Vue 项目转换为 Android App(使用Capacitor)
android·前端·vue.js
消失的旧时光-19431 天前
人脸跟随 ( Channel 实现(缓存5条数据 + 2度过滤 + 平滑移动))
android·java·开发语言·kotlin
小王lj1 天前
画三角形报错bad_Alloc 原因,回调用错
android
xhbh6661 天前
【实战避坑】MySQL自增主键(AUTO_INCREMENT)全解:从锁机制、间隙问题到分库分表替代方案
android·数据库·mysql·mysql自增主键
TimeFine1 天前
Android 通过Dialog实现全屏
android