// Copyright 2020, The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

aidl_interface {
    name: "android.system.keystore2",
    vendor_available: true,
    srcs: ["android/system/keystore2/*.aidl"],
    defaults: ["android.hardware.security.keymint-latest-defaults"],
    stability: "vintf",
    backend: {
        java: {
            platform_apis: true,
        },
        ndk: {
            apps_enabled: false,
            min_sdk_version: "30",
            apex_available: [
                "//apex_available:platform",
                "com.android.wifi",
            ],
        },
        rust: {
            enabled: true,
            apex_available: [
                "//apex_available:platform",
                "com.android.compos",
            ],
        },
    },
    versions_with_info: [
        {
            version: "1",
            imports: ["android.hardware.security.keymint-V1"],
        },
        {
            version: "2",
            imports: ["android.hardware.security.keymint-V3"],
        },
        {
            version: "3",
            imports: ["android.hardware.security.keymint-V3"],
        },
        {
            version: "4",
            imports: ["android.hardware.security.keymint-V3"],
        },
        {
            version: "5",
            imports: ["android.hardware.security.keymint-V4"],
        },

    ],
    frozen: true,

}

aidl_interface_defaults {
    name: "android.system.keystore2-latest-defaults",
    imports: [
        "android.system.keystore2-V5",
    ],
}

// java_defaults that includes the latest Keystore2 AIDL library.
// Modules that depend on Keystore2 directly can include this java_defaults to avoid
// managing dependency versions explicitly.
java_defaults {
    name: "keystore2_use_latest_aidl_java_static",
    static_libs: [
        "android.system.keystore2-V5-java-source",
    ],
}

java_defaults {
    name: "keystore2_use_latest_aidl_java_shared",
    libs: [
        "android.system.keystore2-V5-java-source",
    ],
}

java_defaults {
    name: "keystore2_use_latest_aidl_java",
    libs: [
        "android.system.keystore2-V5-java",
    ],
}

// cc_defaults that includes the latest Keystore2 AIDL library.
// Modules that depend on Keystore directly can include this cc_defaults to avoid
// managing dependency versions explicitly.
cc_defaults {
    name: "keystore2_use_latest_aidl_ndk_static",
    static_libs: [
        "android.system.keystore2-V5-ndk",
    ],
}

cc_defaults {
    name: "keystore2_use_latest_aidl_ndk_shared",
    shared_libs: [
        "android.system.keystore2-V5-ndk",
    ],
}

cc_defaults {
    name: "keystore2_use_latest_aidl_cpp_shared",
    shared_libs: [
        "android.system.keystore2-V5-cpp",
    ],
}

cc_defaults {
    name: "keystore2_use_latest_aidl_cpp_static",
    static_libs: [
        "android.system.keystore2-V5-cpp",
    ],
}

// A rust_defaults that includes the latest Keystore2 AIDL library.
// Modules that depend on Keystore2 directly can include this rust_defaults to avoid
// managing dependency versions explicitly.
rust_defaults {
    name: "keystore2_use_latest_aidl_rust",
    rustlibs: [
        "android.system.keystore2-V5-rust",
    ],
}
