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

代码

流程和代码可以参考这位大佬的
https://blog.youkuaiyun.com/learnframework/article/details/134621556

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

1.首先最外层的bp不要使用update-makefiles.sh 去生成 ,基本上interface下面的文件夹都会被影响,可能会导致编译问题。
bp使用ir目录下面的直接改一下就行了。这里我也贴一下


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配置。

在这里插入图片描述

  <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

PRODUCT_PACKAGES += \
    android.hardware.audio.service \
    android.hardware.hidltest@1.0-service

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

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};

最后结果
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值