AIDL インターフェース

AIDL インターフェースを使用して、サービスの API を宣言します。

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

package com.example.birthdayservice;

/** Birthday service interface. */
interface IBirthdayService {
    /** Generate a Happy Birthday message. */
    String wishHappyBirthday(String name, int years);
}

birthday_service/aidl/Android.bp:

aidl_interface {
    name: "com.example.birthdayservice",
    srcs: ["com/example/birthdayservice/*.aidl"],
    unstable: true,
    backend: {
        rust: { // Rust is not enabled by default
            enabled: true,
        },
    },
}
  • aidl/ ディレクトリ配下のディレクトリ構造は、AIDL ファイルで使用される パッケージ名と一致している必要があることに注意してください。つまり、パッケージは com.example.birthdayservice で、ファイルは aidl/com/example/IBirthdayService.aidl にあります。