/*
 * Copyright (C) 2019 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.
 */

// Import this namespace in order to use AOSP Phone configuration example

soong_namespace {
    imports: [
        "frameworks/av/services/audiopolicy/config",
        "frameworks/av/services/audiopolicy/engineconfigurable/config/example/phone",
    ],
}

//
// Generate Audio Policy Parameter Framework Product Strategies Structure file from template
//
package {
    default_team: "trendy_team_android_media_audio_framework",
    // 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"],
}

prebuilt_etc {
    name: "ProductStrategies.xml",
    vendor: true,
    src: ":buildstrategiesstructure_gen",
    sub_dir: "parameter-framework/Structure/Policy",
    required: ["libpolicy-subsystem"],
}

genrule {
    name: "buildstrategiesstructure_gen",
    defaults: ["buildstrategiesstructurerule"],
    srcs: [
        ":audio_policy_engine_configuration_files",
    ],
}

//
// Generate Audio Policy Parameter Framework Configurable Domains
//
prebuilt_etc {
    name: "parameter-framework.policy",
    enabled: false, // TODO: This module depends on domaingeneratorpolicyrule_gen, which fails to build
    filename_from_src: true,
    vendor: true,
    src: ":domaingeneratorpolicyrule_gen",
    sub_dir: "parameter-framework/Settings/Policy",
    required: [
        "PolicyClass.xml",
        "PolicySubsystem-CommonTypes.xml",
        "PolicySubsystem.xml",
        "ProductStrategies.xml",
    ],
}

genrule {
    name: "domaingeneratorpolicyrule_gen",
    enabled: false, // TODO: This module fails to build
    defaults: ["domaingeneratorpolicyrule"],
    srcs: [
        ":audio_policy_engine_criterion_types",
        ":audio_policy_pfw_structure_files",
        ":audio_policy_pfw_toplevel",
        ":edd_files",
    ],
}

filegroup {
    name: "edd_files",
    srcs: [
        ":device_for_input_source.pfw",
        ":volumes.pfw",
        "Settings/device_for_product_strategy_accessibility.pfw",
        "Settings/device_for_product_strategy_dtmf.pfw",
        "Settings/device_for_product_strategy_enforced_audible.pfw",
        "Settings/device_for_product_strategy_media.pfw",
        "Settings/device_for_product_strategy_patch.pfw",
        "Settings/device_for_product_strategy_phone.pfw",
        "Settings/device_for_product_strategy_rerouting.pfw",
        "Settings/device_for_product_strategy_sonification.pfw",
        "Settings/device_for_product_strategy_sonification_respectful.pfw",
        "Settings/device_for_product_strategy_transmitted_through_speaker.pfw",
    ],
}

// This is for Settings generation, must use socket port, so userdebug version is required
filegroup {
    name: "audio_policy_pfw_toplevel",
    srcs: [":ParameterFrameworkConfigurationPolicy.userdebug.xml"],
}

filegroup {
    name: "audio_policy_pfw_structure_files",
    srcs: [
        ":PolicyClass",
        ":PolicySubsystem",
        ":buildcommontypesstructure_gen",
        ":buildstrategiesstructure_gen",
    ],
}
