从 Java 到 C++ 的 Android AIDL

标签 android aidl

我正在深入研究 Android AIDL 功能,并试图弄清楚是否可以通过 AIDL 将 Java 组件与 C/C++ 组件连接起来。从概念上讲,AIDL 是 IPC,可以翻译成 Java 和 C/C++,这意味着我们可以通过共享 AIDL 请求将 Android 应用程序集成到 C/C++ 服务。不幸的是,我找不到任何可以描述这种类型的集成的文档,所以我不确定它是否可行。

请建议是否可以通过 AIDL 将 Java 与 C/C++ 连接起来。 谢谢

最佳答案

我在这里找到了一个网站页面:https://android.googlesource.com/platform/system/tools/aidl/+/brillo-m10-dev/docs/aidl-cpp.md

文档似乎说我们可以生成aidl到C++代码而不是java代码。并通过jni而不是子类调用。

这里有一些内容:

Generating C++ Binder Interfaces with aidl-cpp Background “aidl” refers to several related but distinct concepts: the AIDL interface definition language .aidl files (which contain AIDL) the aidl generator which transforms AIDL into client/server IPC interfaces The aidl generator is a command line tool that generates client and server stubs for Binder interfaces from a specification in a file with the .aidl extension. For Java interfaces, the executable is called aidl while for C++ the binary is called aidl-cpp. In this document, we’ll use AIDL to describe the language of .aidl files and aidl generator to refer to the code generation tool that takes an .aidl file, parses the AIDL, and outputs code. Previously, the aidl generator only generated Java interface/stub/proxy objects. C++ Binder interfaces were handcrafted with various degrees of compatibility with the Java equivalents. The Brillo project added support for generating C++ with the aidl generator. This generated C++ is cross-language compatible (e.g. Java clients are tested to interoperate with native services).

关于从 Java 到 C++ 的 Android AIDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47610872/

相关文章:

android - 用相机拍照后应用程序重启(Titanium android)

android - 包含布局的 Espresso 选择子项

java - 需要 AIDL 教程

Android:AIDL 拒绝从定义 parcelable 的 aidl 文件生成代码

android - 两个应用程序之间的 AIDL 接口(interface)

java - Android - Firebase - 不同类型的用户登录

java - Gradle:在构建文件中将依赖项声明为属性有什么好处?

android - SmsManager 执行了几次

android - aidl:无法打开文件进行读取

android - 检索 AIDL 使用者的 Java 包名称