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

cc_library_headers {
    name: "libaudioclient_headers",
    vendor_available: true,
    min_sdk_version: "29",
    apex_available: [
        "//apex_available:platform",
        "com.android.media",
    ],
    host_supported: true,

    header_libs: [
        "libaudiofoundation_headers",
    ],
    export_include_dirs: [
        "include",
    ],
    export_header_lib_headers: [
        "libaudiofoundation_headers",
    ],
    static_libs: [
        "audioflinger-aidl-cpp",
        "audiopolicy-aidl-cpp",
        "av-types-aidl-cpp",
        "spatializer-aidl-cpp",
    ],
    export_static_lib_headers: [
        "audioflinger-aidl-cpp",
        "audiopolicy-aidl-cpp",
        "av-types-aidl-cpp",
        "spatializer-aidl-cpp",
    ],
    target: {
        darwin: {
            enabled: false,
        },
    },
}

cc_library {
    name: "libaudiopolicy",
    srcs: [
        "AudioPolicy.cpp",
        "AudioProductStrategy.cpp",
        "AudioVolumeGroup.cpp",
        "PolicyAidlConversion.cpp",
        "VolumeGroupAttributes.cpp",
    ],
    defaults: [
        "latest_android_media_audio_common_types_cpp_export_shared",
    ],
    shared_libs: [
        "audioclient-types-aidl-cpp",
        "audioflinger-aidl-cpp",
        "audiopolicy-aidl-cpp",
        "audiopolicy-types-aidl-cpp",
        "capture_state_listener-aidl-cpp",
        "framework-permission-aidl-cpp",
        "libaudioclient_aidl_conversion",
        "libaudiofoundation",
        "libaudioutils",
        "libbinder",
        "libcutils",
        "liblog",
        "libutils",
    ],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    include_dirs: ["system/media/audio_utils/include"],
    export_include_dirs: ["include"],
    export_shared_lib_headers: [
        "audioclient-types-aidl-cpp",
        "audioflinger-aidl-cpp",
        "audiopolicy-aidl-cpp",
        "audiopolicy-types-aidl-cpp",
        "capture_state_listener-aidl-cpp",
        "libaudioclient_aidl_conversion",
        "libaudiofoundation",
    ],
    header_libs: ["libaudioclient_headers"],
}

cc_library {
    name: "libaudioclient",

    aidl: {
        export_aidl_headers: true,
        local_include_dirs: ["aidl"],
        include_dirs: [
            "frameworks/av/aidl",
        ],
    },

    srcs: [
        // AIDL files for audioclient interfaces
        // The headers for these interfaces will be available to any modules that
        // include libaudioclient, at the path "aidl/package/path/BnFoo.h"
        ":libaudioclient_aidl",

        "AudioEffect.cpp",
        "AudioRecord.cpp",
        "AudioSystem.cpp",
        "AudioTrack.cpp",
        "AudioTrackShared.cpp",
        "IAudioFlinger.cpp",
        "PlayerBase.cpp",
        "RecordingActivityTracker.cpp",
        "ToneGenerator.cpp",
        "TrackPlayerBase.cpp",
    ],
    defaults: [
        "latest_android_media_audio_common_types_cpp_shared",
    ],
    shared_libs: [
        "android.media.audiopolicy-aconfig-cc",
        "audioclient-types-aidl-cpp",
        "audioflinger-aidl-cpp",
        "audiopolicy-aidl-cpp",
        "audiopolicy-types-aidl-cpp",
        "av-types-aidl-cpp",
        "capture_state_listener-aidl-cpp",
        "com.android.media.audioclient-aconfig-cc",
        "framework-permission-aidl-cpp",
        "libaudio_aidl_conversion_common_cpp",
        "libaudioclient_aidl_conversion",
        "libaudiofoundation",
        "libaudiomanager",
        "libaudiopolicy",
        "libaudioutils",
        "libbinder",
        "libcutils",
        "libdl",
        "liblog",
        "libmedia_helper",
        "libmediametrics",
        "libmediautils",
        "libnblog",
        "libprocessgroup",
        "libshmemcompat",
        "libutils",
        "packagemanager_aidl-cpp",
        "spatializer-aidl-cpp",
    ],
    export_shared_lib_headers: [
        "audioflinger-aidl-cpp",
        "audiopolicy-aidl-cpp",
        "framework-permission-aidl-cpp",
        "libbinder",
        "libmediametrics",
        "libmediautils",
        "spatializer-aidl-cpp",
    ],

    include_dirs: [
        "frameworks/av/media/libnbaio/include_mono/",
    ],
    local_include_dirs: [
        "aidl",
        "include/media",
    ],
    header_libs: [
        "libaudioclient_headers",
        "libbase_headers",
        "libmedia_headers",
    ],
    export_header_lib_headers: ["libaudioclient_headers"],
    export_static_lib_headers: [
        "effect-aidl-cpp",
        "shared-file-region-aidl-cpp",
    ],

    static_libs: [
        "effect-aidl-cpp",
        // for memory heap analysis
        "libc_malloc_debug_backtrace",
        "shared-file-region-aidl-cpp",
    ],
    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wthread-safety",
    ],
    sanitize: {
        misc_undefined: [
            "signed-integer-overflow",
            "unsigned-integer-overflow",
        ],
    },
}

cc_library {
    name: "libaudioclient_aidl_conversion",
    srcs: ["AidlConversion.cpp"],
    shared_libs: [
        "audioclient-types-aidl-cpp",
        "av-types-aidl-cpp",
    ],
    static_libs: [
        "libaudio_aidl_conversion_common_cpp",
    ],
    export_include_dirs: ["include"],
    header_libs: [
        "libaudio_aidl_conversion_common_util_cpp",
    ],
    export_header_lib_headers: [
        "libaudio_aidl_conversion_common_util_cpp",
    ],
    export_shared_lib_headers: [
        "audioclient-types-aidl-cpp",
        "av-types-aidl-cpp",
    ],
    defaults: [
        "audio_aidl_conversion_common_default",
        "audio_aidl_conversion_common_default_cpp",
        "latest_android_media_audio_common_types_cpp_export_shared",
    ],
}

// AIDL interface between libaudioclient and framework.jar
filegroup {
    name: "libaudioclient_aidl",
    srcs: [
        "aidl/android/media/AudioHalVersion.aidl",
        "aidl/android/media/IPlayer.aidl",
    ],
    path: "aidl",
}

aidl_interface {
    name: "capture_state_listener-aidl",
    unstable: true,
    local_include_dir: "aidl",
    host_supported: true,
    double_loadable: true,
    vendor_available: true,
    srcs: [
        "aidl/android/media/ICaptureStateListener.aidl",
    ],
}

aidl_interface {
    name: "effect-aidl",
    unstable: true,
    local_include_dir: "aidl",
    host_supported: true,
    double_loadable: true,
    vendor_available: true,
    srcs: [
        "aidl/android/media/EffectConfig.aidl",
        "aidl/android/media/IEffect.aidl",
        "aidl/android/media/IEffectClient.aidl",
    ],
    defaults: [
        "latest_android_media_audio_common_types_import_interface",
    ],
    imports: [
        "shared-file-region-aidl",
    ],
    backend: {
        cpp: {
            min_sdk_version: "29",
            apex_available: [
                "//apex_available:platform",
                "com.android.media",
            ],
        },
        java: {
            sdk_version: "module_current",
        },
    },
}

aidl_interface {
    name: "audioclient-types-aidl",
    unstable: true,
    host_supported: true,
    vendor_available: true,
    double_loadable: true,
    local_include_dir: "aidl",
    srcs: [
        "aidl/android/media/AudioClient.aidl",
        "aidl/android/media/AudioDirectMode.aidl",
        "aidl/android/media/AudioGainSys.aidl",
        "aidl/android/media/AudioHalVersion.aidl",
        "aidl/android/media/AudioHwModule.aidl",
        "aidl/android/media/AudioIoConfigEvent.aidl",
        "aidl/android/media/AudioIoDescriptor.aidl",
        "aidl/android/media/AudioPatchFw.aidl",
        "aidl/android/media/AudioPolicyConfig.aidl",
        "aidl/android/media/AudioPortConfigFw.aidl",
        "aidl/android/media/AudioPortConfigSys.aidl",
        "aidl/android/media/AudioPortDeviceExtSys.aidl",
        "aidl/android/media/AudioPortExtSys.aidl",
        "aidl/android/media/AudioPortFw.aidl",
        "aidl/android/media/AudioPortMixExtSys.aidl",
        "aidl/android/media/AudioPortRole.aidl",
        "aidl/android/media/AudioPortSys.aidl",
        "aidl/android/media/AudioPortType.aidl",
        "aidl/android/media/AudioProfileSys.aidl",
        "aidl/android/media/AudioRoute.aidl",
        "aidl/android/media/AudioTimestampInternal.aidl",
        "aidl/android/media/AudioUniqueIdUse.aidl",
        "aidl/android/media/AudioVibratorInfo.aidl",
        "aidl/android/media/DeviceConnectedState.aidl",
        "aidl/android/media/EffectDescriptor.aidl",
        "aidl/android/media/SurroundSoundConfig.aidl",
        "aidl/android/media/TrackInternalMuteInfo.aidl",
        "aidl/android/media/TrackSecondaryOutputInfo.aidl",
    ],
    defaults: [
        "latest_android_media_audio_common_types_import_interface",
    ],
    imports: [
        "framework-permission-aidl",
    ],
    backend: {
        cpp: {
            min_sdk_version: "29",
            apex_available: [
                "//apex_available:platform",
                "com.android.media",
            ],
        },
        java: {
            sdk_version: "module_current",
        },
    },
}

aidl_interface {
    name: "audiopolicy-types-aidl",
    unstable: true,
    host_supported: true,
    vendor_available: true,
    double_loadable: true,
    local_include_dir: "aidl",
    srcs: [
        "aidl/android/media/AudioAttributesEx.aidl",
        "aidl/android/media/AudioMix.aidl",
        "aidl/android/media/AudioMixCallbackFlag.aidl",
        "aidl/android/media/AudioMixMatchCriterion.aidl",
        "aidl/android/media/AudioMixMatchCriterionValue.aidl",
        "aidl/android/media/AudioMixRouteFlag.aidl",
        "aidl/android/media/AudioMixType.aidl",
        "aidl/android/media/AudioMixUpdate.aidl",
        "aidl/android/media/AudioMixerAttributesInternal.aidl",
        "aidl/android/media/AudioMixerBehavior.aidl",
        "aidl/android/media/AudioOffloadMode.aidl",
        "aidl/android/media/AudioPolicyDeviceState.aidl",
        "aidl/android/media/AudioPolicyForceUse.aidl",
        "aidl/android/media/AudioPolicyForcedConfig.aidl",
        "aidl/android/media/AudioProductStrategy.aidl",
        "aidl/android/media/AudioVolumeGroup.aidl",
        "aidl/android/media/DeviceRole.aidl",
        "aidl/android/media/SoundTriggerSession.aidl",
    ],
    defaults: [
        "latest_android_media_audio_common_types_import_interface",
    ],
    imports: [
        "audioclient-types-aidl",
        "framework-permission-aidl",
    ],
    backend: {
        cpp: {
            min_sdk_version: "29",
            apex_available: [
                "//apex_available:platform",
                "com.android.media",
            ],
        },
        java: {
            sdk_version: "module_current",
        },
    },
}

aidl_interface {
    name: "audioflinger-aidl",
    unstable: true,
    local_include_dir: "aidl",
    host_supported: true,
    vendor_available: true,
    srcs: [
        "aidl/android/media/CreateEffectRequest.aidl",
        "aidl/android/media/CreateEffectResponse.aidl",
        "aidl/android/media/CreateRecordRequest.aidl",
        "aidl/android/media/CreateRecordResponse.aidl",
        "aidl/android/media/CreateTrackRequest.aidl",
        "aidl/android/media/CreateTrackResponse.aidl",
        "aidl/android/media/OpenInputRequest.aidl",
        "aidl/android/media/OpenInputResponse.aidl",
        "aidl/android/media/OpenOutputRequest.aidl",
        "aidl/android/media/OpenOutputResponse.aidl",
        "aidl/android/media/RenderPosition.aidl",

        "aidl/android/media/IAudioFlingerClient.aidl",
        "aidl/android/media/IAudioFlingerService.aidl",
        "aidl/android/media/IAudioRecord.aidl",
        "aidl/android/media/IAudioTrack.aidl",
        "aidl/android/media/IAudioTrackCallback.aidl",

        "aidl/android/media/ISoundDose.aidl",
        "aidl/android/media/ISoundDoseCallback.aidl",
        "aidl/android/media/SoundDoseRecord.aidl",
    ],
    defaults: [
        "latest_android_media_audio_common_types_import_interface",
    ],
    imports: [
        "audioclient-types-aidl",
        "av-types-aidl",
        "effect-aidl",
        "framework-permission-aidl",
        "shared-file-region-aidl",
    ],
    double_loadable: true,
    backend: {
        cpp: {
            min_sdk_version: "29",
            apex_available: [
                "//apex_available:platform",
                "com.android.media",
            ],
        },
        java: {
            sdk_version: "module_current",
        },
    },
}

aidl_interface {
    name: "audiopolicy-aidl",
    unstable: true,
    local_include_dir: "aidl",
    host_supported: true,
    vendor_available: true,
    srcs: [
        "aidl/android/media/GetInputForAttrResponse.aidl",
        "aidl/android/media/GetOutputForAttrResponse.aidl",
        "aidl/android/media/GetSpatializerResponse.aidl",
        "aidl/android/media/IAudioPolicyService.aidl",
        "aidl/android/media/IAudioPolicyServiceClient.aidl",
        "aidl/android/media/RecordClientInfo.aidl",
    ],
    defaults: [
        "latest_android_media_audio_common_types_import_interface",
    ],
    imports: [
        "audio-permission-aidl",
        "audioclient-types-aidl",
        "audiopolicy-types-aidl",
        "capture_state_listener-aidl",
        "framework-permission-aidl",
        "spatializer-aidl",
    ],

    double_loadable: true,
    backend: {
        cpp: {
            min_sdk_version: "29",
            apex_available: [
                "//apex_available:platform",
                "com.android.media",
            ],
        },
        java: {
            sdk_version: "module_current",
        },
    },
}

aidl_interface {
    name: "spatializer-aidl",
    unstable: true,
    local_include_dir: "aidl",
    host_supported: true,
    vendor_available: true,
    srcs: [
        "aidl/android/media/INativeSpatializerCallback.aidl",
        "aidl/android/media/ISpatializer.aidl",
        "aidl/android/media/ISpatializerHeadTrackingCallback.aidl",
    ],
    defaults: [
        "latest_android_media_audio_common_types_import_interface",
    ],
    imports: [
        "audiopolicy-types-aidl",
    ],

    double_loadable: true,
    backend: {
        cpp: {
            min_sdk_version: "29",
            apex_available: [
                "//apex_available:platform",
                "com.android.media",
            ],
        },
        java: {
            sdk_version: "module_current",
        },
    },
}

aidl_interface {
    name: "sounddose-aidl",
    unstable: true,
    local_include_dir: "aidl",
    srcs: [
        "aidl/android/media/ISoundDose.aidl",
        "aidl/android/media/ISoundDoseCallback.aidl",
        "aidl/android/media/SoundDoseRecord.aidl",
    ],

    double_loadable: true,
    backend: {
        java: {
            sdk_version: "module_current",
        },
    },
}
