android 新增native binder service 方式(二)

news/2025/2/26 17:26:35

接上篇文章,实现binder service 的第二种方式,这种在系统里面比较常见

先看下整体目录结构,整体差别不大。

一 android.bp 编译aidl 文件

aidl_interface {
    name: "libserviceaidl",
    srcs: [
        "aidl/com/test/IService.aidl",
        "aidl/com/test/IServiceCallback.aidl",
    ],
    include_dirs: ["aidl"],
    local_include_dir: "aidl",
    backend: {
        cpp: {
            enabled: true,
        },
    },
    versions: [
        "1",
    ],
}

make libserviceaidl 

会报一系列错误,按照报错处理就可以了。

报错处理:

FAILED: out/soong/.intermediates/vendor/qcom/proprietary/testserver/libserviceaidl/libserviceaidl-api/checkapi_current.timestamp
echo "API dump for the current version of AIDL interface libserviceaidl does not exist." && echo Run "m libserviceaidl-update-api", or add "unstable: true" to the build rule for the interface if it does not need to be versioned && false
API dump for the current version of AIDL interface libserviceaidl does not exist.
Run m libserviceaidl-update-api, or add unstable: true to the build rule for the interface if it does not need to be versioned

执行 m libserviceaidl-update-api

[100% 352/352] //vendor/qcom/proprietary/testserver/libserviceaidl:libserviceaidl-api Making AIDL API of libserviceaidl as version current
FAILED: out/soong/.intermediates/vendor/qcom/proprietary/testserver/libserviceaidl/libserviceaidl-api/updateapi_current.timestamp
echo "module libserviceaidl-api missing dependencies: vendor/qcom/proprietary/testserver/libserviceaidl/aidl_api/libserviceaidl/1" && false
module libserviceaidl-api missing dependencies: vendor/qcom/proprietary/testserver/libserviceaidl/aidl_api/libserviceaidl/1
17:33:18 ninja failed with: exit status 1

按照提示 libserviceaidl/aidl_api/libserviceaidl/1,新建各级目录,缺少加啥,然后把aidl 文件放进去

###############################################################################
# ERROR: Backward incompatible change detected on AIDL API                    #
###############################################################################
Above AIDL file(s) has changed in a backward-incompatible way, e.g. removing
a method from an interface or a field from a parcelable. If a device is shipped
with this change by ignoring this message, it has a high risk of breaking later
when a module using the interface is updated, e.g., Maineline modules.
17:41:40 ninja failed with: exit status 1
 

把current 生成的文件放到 version 1的目录,覆盖掉,保持一致就可以了。

编译成功会生成ystem/lib/libserviceaidl-V1-cpp.so  ,push 到system/lib/下

二,编译Native service 和 client

cc_binary {
    name: "testservverfirst",
    srcs: ["servertest.cpp",
           ],
    shared_libs: [
        "liblog",
        "libcutils",
        "libutils",
        "libbinder",
        "libserviceaidl-cpp", 
    ],

    init_rc: ["testservver.rc"],
}


cc_binary {
    name: "clienttest",
        srcs: ["clienttest.cpp", 
          ],

    shared_libs: [
        "liblog",
        "libcutils",
        "libutils",
        "libbinder",
        "libserviceaidl-cpp", 
    ],
}

调用方式和前面文章一致,添加selinux 权限也一样。
 


http://www.niftyadmin.cn/n/5868984.html

相关文章

Imagination通过最新的D系列GPU IP将效率提升至新高度

Imagination DXTP GPU IP在加速移动设备和其他电力受限设备上的图形和计算工作负载时,能够延长电池续航时间。 英国伦敦 – 2025年2月25日 – 今日,Imagination Technologies(“Imagination”)宣布推出其最新的GPU IP——Imagina…

EIDE搭配cursor编译GD32的项目 需要的一些c_cpp_properties设置 json文件

B站大神的一个视频。有些需要设置的joson文件,这里整理下。 原视频可以看这里。 【VSCodeEIDE开发STM32,支持标准库、HAL库、LL库,可以在VSCode里进行调试,编译以及下载,代码编辑更舒适,环境搭建超简单。…

《操作系统 - 清华大学》8 -4:进程管理:进程控制结构

深度剖析进程控制块:操作系统进程管理的核心关键 在操作系统的复杂体系中,进程控制块(PCB)是实现高效进程管理的关键所在。接下来,将从多个维度深入剖析进程控制块,帮助更好地理解其在操作系统中的重要作用…

软件安全测评报告内容和作用简析,如何获取权威安全测评报告?

软件安全测评报告是对软件系统进行安全性评估后形成的一份详细文档。它通过对软件系统的设计、实现及运行环境等多个方面进行系统性分析,以识别潜在的安全风险和漏洞。该报告不仅包含漏洞的详细信息和修复建议,也是对软件开发者和管理者的重要决策支持工…

LLM全栈框架完整分类清单(预训练+微调+工具链)

一、预训练框架 1. 大规模分布式训练框架 框架名称核心能力GitHub地址Megatron-LM3D并行训练、FlashAttention支持、Transformer架构优化(NVIDIA生态)NVIDIA/Megatron-LMDeepSpeedZeRO优化系列、3D并行、RLHF全流程支持(微软生态&#xff09…

C++ 多态小练习

编写一个如下场景: 有一个英雄Hero类,私有成员,攻击,防御,速度,生命值,以及所有的set get 方法 编写一个 武器 Weapon 类,拥有私有成员攻击力,以及set get 方法 编写一个…

【linux配置】 修改内核网络参数

命令解释 echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore 这个命令的具体含义是: echo 1:将值1写入文件。 /proc/sys/net/ipv4/conf/all/arp_ignore:将值1写入 /proc/sys/net/ipv4/conf/all/arp_ignore 文件,从而修改内核参…

【前端】【面试】【树】JavaScript 树形结构与列表结构的灵活转换:`listToTree` 与 `treeToList` 函数详解

JavaScript 树形结构与列表结构的灵活转换:listToTree 与 treeToList 函数详解 在前端开发的数据处理工作中,树形结构和列表结构是两种常见的数据形式。树形结构能够清晰展示数据间的层级关系,适合用于菜单、组织架构等场景;而列…