package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "hardware_interfaces_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["hardware_interfaces_license"],
}

cc_library_static {
    name: "libcasexampleimpl",
    vendor_available: true,

    srcs: [
        "CasImpl.cpp",
        "DescramblerImpl.cpp",
        "MediaCasService.cpp",
        "SharedLibrary.cpp",
        "TypeConvert.cpp",
    ],

    shared_libs: [
        "android.hardware.cas-V1-ndk",
        "libbase",
        "libbinder_ndk",
        "liblog",
        "libutils",
        "libcutils",
        "libvndksupport",
    ],
    static_libs: [
        "libaidlcommonsupport",
    ],
    header_libs: [
        "libstagefright_foundation_headers",
        "media_plugin_headers",
    ],
}

cc_defaults {
    name: "cas_service_example_defaults",
    vendor: true,
    relative_install_path: "hw",

    srcs: ["service.cpp"],

    stl: "c++_static",
    static_libs: [
        "android.hardware.cas-V1-ndk",
        "android.hardware.common-V2-ndk",
        "libaidlcommonsupport",
        "libbase",
        "libcasexampleimpl",
        "libcutils",
        "libutils",
    ],
    shared_libs: [
        "libbinder_ndk",
        "liblog",
    ],
    header_libs: ["media_plugin_headers"],
}

cc_binary {
    name: "android.hardware.cas-service.example",
    defaults: ["cas_service_example_defaults"],
    // Installed in APEX
    installable: false,
}

// TODO(b/297467514) Convert to VAPEX
cc_binary {
    name: "android.hardware.cas-service.example-lazy",
    defaults: ["cas_service_example_defaults"],
    init_rc: ["cas-default-lazy.rc"],
    vintf_fragments: ["android.hardware.cas-service.xml"],
    cflags: ["-DLAZY_SERVICE"],
    overrides: ["com.android.hardware.cas"],
}

cc_fuzz {
    name: "android.hardware.cas-service_fuzzer",
    // TODO(b/307611931): avoid fuzzing on vendor until hermiticity issue is fixed
    // vendor: true,

    defaults: ["service_fuzzer_defaults"],
    srcs: ["fuzzer.cpp"],

    shared_libs: [
        "android.hardware.cas-V1-ndk",
        "libcutils",
        "liblog",
        "libvndksupport",
    ],
    static_libs: [
        "libaidlcommonsupport",
        "libcasexampleimpl",
    ],
    header_libs: ["media_plugin_headers"],
    fuzz_config: {
        componentid: 1344,
    },
}

apex {
    name: "com.android.hardware.cas",
    manifest: "manifest.json",
    file_contexts: "file_contexts",
    key: "com.android.hardware.key",
    certificate: ":com.android.hardware.certificate",
    updatable: false,
    vendor: true,

    binaries: [
        "android.hardware.cas-service.example",
    ],
    prebuilts: [
        "cas-default.rc",
        "android.hardware.cas-service.xml",
    ],
}

prebuilt_etc {
    name: "cas-default.rc",
    src: "cas-default.rc",
    installable: false,
}

prebuilt_etc {
    name: "android.hardware.cas-service.xml",
    src: "android.hardware.cas-service.xml",
    sub_dir: "vintf",
    installable: false,
}
