Service Implementation
We can now implement the AIDL service:
birthday_service/src/lib.rs:
1. use com_example_birthdayservice::aidl::com::example::birthdayservice::IBirthdayService::IBirthdayService;
2. use com_example_birthdayservice::binder;
4. /// The `IBirthdayService` implementation.
5. pub struct BirthdayService;
7. impl binder::Interface for BirthdayService {}
9. impl IBirthdayService for BirthdayService {
10. fn wishHappyBirthday(&self, name: &str, years: i32) -> binder::Result<String> {
11. Ok(format!("Happy Birthday {name}, congratulations with the {years} years!"))
12. }
13. }
birthday_service/Android.bp:
1. rust_library {
2. name: "libbirthdayservice",
3. srcs: ["src/lib.rs"],
4. crate_name: "birthdayservice",
5. rustlibs: [
6. "com.example.birthdayservice-rust",
7. "libbinder_rs",
8. ],
9. }
- Point out the path to the generated
IBirthdayServicetrait, and explain why each of the segments is necessary. - TODO: What does the
binder::Interfacetrait do? Are there methods to override? Where source?
