Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07d755f6 authored by François Gaffie's avatar François Gaffie
Browse files

Revert^2 audiopolicy: capengine: allow to disable AIDL Cap engine config



This CL allows to disable AIDL Cap engine configuration.
When disabled, CapEngine relies on legacy vendor XML file.

Bug: 379596346
Test: atest audiorouting_tests
atest audiosystem_tests
atest audiopolicy_tests
(with lunch target aosp_cf_x86_64_only_phone and
 aosp_cf_x86_64_auto migrated on cap engine)

Change-Id: I358324607f1cb3de1630f133eab22b28380ecba2
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@ampere.cars>
parent aaafa175
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -75,6 +75,9 @@ cc_library {
    cflags: [
    cflags: [
        "-Wall",
        "-Wall",
        "-Werror",
        "-Werror",
    ],
        "-DENABLE_CAP_AIDL_HYBRID_MODE",

    ] + select(release_flag("RELEASE_HARDWARE_AUDIO_USE_CAP_AIDL"), {
        true: [],
        default: ["-DDISABLE_CAP_AIDL"],
    }),
}
}
+4 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,10 @@ public:


    // The source used to indicate the configuration from the AIDL HAL.
    // The source used to indicate the configuration from the AIDL HAL.
    static const constexpr char* const kAidlConfigSource = "AIDL HAL";
    static const constexpr char* const kAidlConfigSource = "AIDL HAL";
#ifdef ENABLE_CAP_AIDL_HYBRID_MODE
    // The source used to indicate the configuration from the AIDL HAL but engine still use XML.
    static const constexpr char* const kHybridAidlConfigSource = "AIDL HAL Hybrid CAP";
#endif
    // The source used to indicate the default fallback configuration.
    // The source used to indicate the default fallback configuration.
    static const constexpr char* const kDefaultConfigSource = "AudioPolicyConfig::setDefault";
    static const constexpr char* const kDefaultConfigSource = "AudioPolicyConfig::setDefault";
    // The suffix of the "engine default" implementation shared library name.
    // The suffix of the "engine default" implementation shared library name.
+11 −0
Original line number Original line Diff line number Diff line
@@ -272,6 +272,17 @@ status_t AudioPolicyConfig::loadFromAidl(const media::AudioPolicyConfig& aidl) {
    mSource = kAidlConfigSource;
    mSource = kAidlConfigSource;
    if (aidl.engineConfig.capSpecificConfig.has_value()) {
    if (aidl.engineConfig.capSpecificConfig.has_value()) {
        setEngineLibraryNameSuffix(kCapEngineLibraryNameSuffix);
        setEngineLibraryNameSuffix(kCapEngineLibraryNameSuffix);
#ifdef ENABLE_CAP_AIDL_HYBRID_MODE
        // Using AIDL Audio HAL to get policy configuration and relying on vendor xml configuration
        // file for CAP engine.
#ifndef DISABLE_CAP_AIDL
        if (!aidl.engineConfig.capSpecificConfig.value().domains.has_value()) {
#endif
            mSource = kHybridAidlConfigSource;
#ifndef DISABLE_CAP_AIDL
        }
#endif
#endif
    }
    }
    // No need to augmentData() as AIDL HAL must provide correct mic addresses.
    // No need to augmentData() as AIDL HAL must provide correct mic addresses.
    return NO_ERROR;
    return NO_ERROR;
+17 −7
Original line number Original line Diff line number Diff line
@@ -27,7 +27,11 @@ cc_library_shared {
        "-Wall",
        "-Wall",
        "-Werror",
        "-Werror",
        "-Wextra",
        "-Wextra",
    ],
        "-DENABLE_CAP_AIDL_HYBRID_MODE",
    ] + select(release_flag("RELEASE_HARDWARE_AUDIO_USE_CAP_AIDL"), {
        true: [],
        default: ["-DDISABLE_CAP_AIDL"],
    }),
    local_include_dirs: ["include"],
    local_include_dirs: ["include"],
    header_libs: [
    header_libs: [
        "libaudiopolicycommon",
        "libaudiopolicycommon",
@@ -59,10 +63,16 @@ cc_library_shared {
        "latest_android_media_audio_common_types_cpp_shared",
        "latest_android_media_audio_common_types_cpp_shared",
    ],
    ],
    required: [
    required: [
    ] + select(release_flag("RELEASE_HARDWARE_AUDIO_USE_CAP_AIDL"), {
        true: [
            "CapClass.xml",
            "CapClass.xml",
            "CapProductStrategies.xml",
            "CapProductStrategies.xml",
            "CapSubsystem-CommonTypes.xml",
            "CapSubsystem-CommonTypes.xml",
            "CapSubsystem.xml",
            "CapSubsystem.xml",
            "ParameterFrameworkConfigurationCap.xml",
            "ParameterFrameworkConfigurationCap.xml",
        ],
        ],
        default: [
            // empty, provisionned by the vendor
        ],
    }),
}
}
+46 −5
Original line number Original line Diff line number Diff line
@@ -66,13 +66,20 @@ const InputSourceCollection &Engine::getCollection<audio_source_t>() const
    return mInputSourceCollection;
    return mInputSourceCollection;
}
}


Engine::Engine() : mPolicyParameterMgr(new ParameterManagerWrapper())
{
}

status_t Engine::loadFromHalConfigWithFallback(
status_t Engine::loadFromHalConfigWithFallback(
        const media::audio::common::AudioHalEngineConfig& aidlConfig) {
        const media::audio::common::AudioHalEngineConfig& aidlConfig) {

#ifdef DISABLE_CAP_AIDL
    (void) aidlConfig;
    ALOGE("%s CapEngine Config disabled, falling back on vendor XML for engine", __func__);
    return loadFromXmlConfigWithFallback(engineConfig::DEFAULT_PATH);
#else
#ifdef ENABLE_CAP_AIDL_HYBRID_MODE
    if (!aidlConfig.capSpecificConfig.value().domains.has_value()) {
        ALOGE("%s CapEngine Config missing, falling back on vendor XML for engine", __func__);
        return loadFromXmlConfigWithFallback(engineConfig::DEFAULT_PATH);
    }
#endif
    mPolicyParameterMgr = new ParameterManagerWrapper();
    auto capResult = capEngineConfig::convert(aidlConfig);
    auto capResult = capEngineConfig::convert(aidlConfig);
    if (capResult.parsedConfig == nullptr) {
    if (capResult.parsedConfig == nullptr) {
        ALOGE("%s CapEngine Config invalid", __func__);
        ALOGE("%s CapEngine Config invalid", __func__);
@@ -97,10 +104,12 @@ status_t Engine::loadFromHalConfigWithFallback(
        return NO_INIT;
        return NO_INIT;
    }
    }
    return mPolicyParameterMgr->setConfiguration(capResult);
    return mPolicyParameterMgr->setConfiguration(capResult);
#endif
}
}


status_t Engine::loadFromXmlConfigWithFallback(const std::string& xmlFilePath)
status_t Engine::loadFromXmlConfigWithFallback(const std::string& xmlFilePath)
{
{
    mPolicyParameterMgr = new ParameterManagerWrapper(/* useLegacyVendorFile= */ true);
    status_t status = loadWithFallback(xmlFilePath);
    status_t status = loadWithFallback(xmlFilePath);
    std::string error;
    std::string error;
    if (mPolicyParameterMgr == nullptr || mPolicyParameterMgr->start(error) != NO_ERROR) {
    if (mPolicyParameterMgr == nullptr || mPolicyParameterMgr->start(error) != NO_ERROR) {
@@ -191,6 +200,10 @@ bool Engine::setPropertyForKey(const Property &property, const Key &key)


status_t Engine::setPhoneState(audio_mode_t mode)
status_t Engine::setPhoneState(audio_mode_t mode)
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return NO_INIT;
    }
    status_t status = mPolicyParameterMgr->setPhoneState(mode);
    status_t status = mPolicyParameterMgr->setPhoneState(mode);
    if (status != NO_ERROR) {
    if (status != NO_ERROR) {
        return status;
        return status;
@@ -200,12 +213,20 @@ status_t Engine::setPhoneState(audio_mode_t mode)


audio_mode_t Engine::getPhoneState() const
audio_mode_t Engine::getPhoneState() const
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return AUDIO_MODE_NORMAL;
    }
    return mPolicyParameterMgr->getPhoneState();
    return mPolicyParameterMgr->getPhoneState();
}
}


status_t Engine::setForceUse(audio_policy_force_use_t usage,
status_t Engine::setForceUse(audio_policy_force_use_t usage,
                                      audio_policy_forced_cfg_t config)
                                      audio_policy_forced_cfg_t config)
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return NO_INIT;
    }
    status_t status = mPolicyParameterMgr->setForceUse(usage, config);
    status_t status = mPolicyParameterMgr->setForceUse(usage, config);
    if (status != NO_ERROR) {
    if (status != NO_ERROR) {
        return status;
        return status;
@@ -215,12 +236,20 @@ status_t Engine::setForceUse(audio_policy_force_use_t usage,


audio_policy_forced_cfg_t Engine::getForceUse(audio_policy_force_use_t usage) const
audio_policy_forced_cfg_t Engine::getForceUse(audio_policy_force_use_t usage) const
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return AUDIO_POLICY_FORCE_NONE;
    }
    return mPolicyParameterMgr->getForceUse(usage);
    return mPolicyParameterMgr->getForceUse(usage);
}
}


status_t Engine::setOutputDevicesConnectionState(const DeviceVector &devices,
status_t Engine::setOutputDevicesConnectionState(const DeviceVector &devices,
                                                 audio_policy_dev_state_t state)
                                                 audio_policy_dev_state_t state)
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return NO_INIT;
    }
    for (const auto &device : devices) {
    for (const auto &device : devices) {
        mPolicyParameterMgr->setDeviceConnectionState(device->type(), device->address(), state);
        mPolicyParameterMgr->setDeviceConnectionState(device->type(), device->address(), state);
    }
    }
@@ -236,6 +265,10 @@ status_t Engine::setOutputDevicesConnectionState(const DeviceVector &devices,
status_t Engine::setDeviceConnectionState(const sp<DeviceDescriptor> device,
status_t Engine::setDeviceConnectionState(const sp<DeviceDescriptor> device,
                                          audio_policy_dev_state_t state)
                                          audio_policy_dev_state_t state)
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return NO_INIT;
    }
    mPolicyParameterMgr->setDeviceConnectionState(device->type(), device->address(), state);
    mPolicyParameterMgr->setDeviceConnectionState(device->type(), device->address(), state);
    if (audio_is_output_device(device->type())) {
    if (audio_is_output_device(device->type())) {
        return mPolicyParameterMgr->setAvailableOutputDevices(
        return mPolicyParameterMgr->setAvailableOutputDevices(
@@ -532,6 +565,10 @@ void Engine::setDeviceAddressForProductStrategy(product_strategy_t strategy,


bool Engine::setDeviceTypesForProductStrategy(product_strategy_t strategy, uint64_t devices)
bool Engine::setDeviceTypesForProductStrategy(product_strategy_t strategy, uint64_t devices)
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return false;
    }
    if (getProductStrategies().find(strategy) == getProductStrategies().end()) {
    if (getProductStrategies().find(strategy) == getProductStrategies().end()) {
        ALOGE("%s: set device %" PRId64 " on invalid strategy %d", __FUNCTION__, devices, strategy);
        ALOGE("%s: set device %" PRId64 " on invalid strategy %d", __FUNCTION__, devices, strategy);
        return false;
        return false;
@@ -545,6 +582,10 @@ bool Engine::setDeviceTypesForProductStrategy(product_strategy_t strategy, uint6


bool Engine::setDeviceForInputSource(const audio_source_t &inputSource, uint64_t device)
bool Engine::setDeviceForInputSource(const audio_source_t &inputSource, uint64_t device)
{
{
    if (mPolicyParameterMgr == nullptr) {
        ALOGE("%s: failed, Cap not initialized", __func__);
        return false;
    }
    DeviceTypeSet types = mPolicyParameterMgr->convertDeviceCriterionValueToDeviceTypes(
    DeviceTypeSet types = mPolicyParameterMgr->convertDeviceCriterionValueToDeviceTypes(
                device, false /*isOut*/);
                device, false /*isOut*/);
    ALOG_ASSERT(types.size() <= 1, "one input device expected at most");
    ALOG_ASSERT(types.size() <= 1, "one input device expected at most");
Loading