AIDL Interfaces

You declare the API of your service using an AIDL interface:

birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl:

  1. package com.example.birthdayservice;
  2. /** Birthday service interface. */
  3. interface IBirthdayService {
  4. /** Generate a Happy Birthday message. */
  5. String wishHappyBirthday(String name, int years);
  6. }

birthday_service/aidl/Android.bp:

  1. aidl_interface {
  2. name: "com.example.birthdayservice",
  3. srcs: ["com/example/birthdayservice/*.aidl"],
  4. unstable: true,
  5. backend: {
  6. rust: { // Rust is not enabled by default
  7. enabled: true,
  8. },
  9. },
  10. }
  • Note that the directory structure under the aidl/ directory needs to match the package name used in the AIDL file, i.e. the package is com.example.birthdayservice and the file is at aidl/com/example/IBirthdayService.aidl.