4.1.2 服务 API
02-服务 API — Comprehensive Rust
1分钟内可阅读完
译文 · 基于 Comprehensive Rust
原文链接: https://google.github.io/comprehensive-rust/android/aidl/example-service/service-bindings.html
4.1.2 服务 API
Binder 会为每个接口定义生成一个 trait。
birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl:
| |
out/soong/.intermediates/…/com_example_birthdayservice.rs:
| |
你的服务需要实现该 trait,客户端则通过该 trait 与服务通信。
- 指出生成的函数签名(尤其是参数与返回类型)如何对应接口定义。
- 作为参数的
String与作为返回类型的String会映射成不同的 Rust 类型。