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

Commit 270a786b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "audio: capEngine: Allow built-in strategies to omit the 'id' attribute" into main

parents 523ddd1a 2b8754ee
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ static constexpr const char *gLegacyForcePrefix = "AUDIO_POLICY_FORCE_";
static constexpr const char *gLegacyStreamPrefix = "AUDIO_STREAM_";
static constexpr const char *gLegacySourcePrefix = "AUDIO_SOURCE_";
static constexpr const char *gPolicyParamPrefix = "/Policy/policy/";
static constexpr const char *gVendorStrategyPrefix = "vx_";

namespace {

@@ -367,6 +368,21 @@ ConversionResult<CapConfiguration> aidl2legacy_AudioHalCapConfiguration_CapConfi
    return legacy;
}

ConversionResult<std::string> aidl2legacy_AudioHalProductStrategyId_StrategyParamName(
        int id) {
    std::string strategyName;
    if (id < media::audio::common::AudioHalProductStrategy::VENDOR_STRATEGY_ID_START) {
        strategyName = legacy_strategy_to_string(static_cast<legacy_strategy>(id));
        if (strategyName.empty()) {
            ALOGE("%s Invalid legacy strategy id %d", __func__, id);
            return unexpected(BAD_VALUE);
        }
    } else {
        strategyName = gVendorStrategyPrefix + std::to_string(id);
    }
    return strategyName;
}

ConversionResult<ConfigurableElementValue> aidl2legacy_ParameterSetting_ConfigurableElementValue(
        const AudioHalCapParameter& aidl) {
    ConfigurableElementValue legacy;
@@ -388,14 +404,18 @@ ConversionResult<ConfigurableElementValue> aidl2legacy_ParameterSetting_Configur
                deviceLiteral = "stub";
            }
            legacy.configurableElement.path = std::string(gPolicyParamPrefix)
                    + "product_strategies/vx_" + std::to_string(strategyDevice.id)
                    + "product_strategies/"
                    + VALUE_OR_RETURN(aidl2legacy_AudioHalProductStrategyId_StrategyParamName(
                            strategyDevice.id))
                    + "/selected_output_devices/mask/" + deviceLiteral;
            break;
        }
        case AudioHalCapParameter::strategyDeviceAddress: {
            auto strategyAddress = aidl.get<AudioHalCapParameter::strategyDeviceAddress>();
            legacy.configurableElement.path = std::string(gPolicyParamPrefix)
                    + "product_strategies/vx_" + std::to_string(strategyAddress.id)
                    + "product_strategies/"
                    + VALUE_OR_RETURN(aidl2legacy_AudioHalProductStrategyId_StrategyParamName(
                            strategyAddress.id))
                    + "/device_address";
            literalValue = strategyAddress.deviceAddress.get<AudioDeviceAddress::id>();
            break;
+9 −0
Original line number Diff line number Diff line
@@ -19,6 +19,15 @@
  <!-- This structure is expected to be in the system partition and provisionned a maximum
       allowed strategies to be used by vendor. -->
  <ComponentType Name="ProductStrategies" Description="">
    <Component Name="STRATEGY_PHONE" Type="ProductStrategy" Mapping="Name:STRATEGY_PHONE"/>
    <Component Name="STRATEGY_SONIFICATION" Type="ProductStrategy" Mapping="Name:STRATEGY_SONIFICATION"/>
    <Component Name="STRATEGY_ENFORCED_AUDIBLE" Type="ProductStrategy" Mapping="Name:STRATEGY_ENFORCED_AUDIBLE"/>
    <Component Name="STRATEGY_ACCESSIBILITY" Type="ProductStrategy" Mapping="Name:STRATEGY_ACCESSIBILITY"/>
    <Component Name="STRATEGY_SONIFICATION_RESPECTFUL" Type="ProductStrategy" Mapping="Name:STRATEGY_SONIFICATION_RESPECTFUL"/>
    <Component Name="STRATEGY_MEDIA" Type="ProductStrategy" Mapping="Name:STRATEGY_MEDIA"/>
    <Component Name="STRATEGY_DTMF" Type="ProductStrategy" Mapping="Name:STRATEGY_DTMF"/>
    <Component Name="STRATEGY_CALL_ASSISTANT" Type="ProductStrategy" Mapping="Name:STRATEGY_CALL_ASSISTANT"/>
    <Component Name="STRATEGY_TRANSMITTED_THROUGH_SPEAKER" Type="ProductStrategy" Mapping="Name:STRATEGY_TRANSMITTED_THROUGH_SPEAKER"/>
    <Component Name="vx_1000" Type="ProductStrategy" Mapping="Identifier:1000,Name:vx_1000"/>
    <Component Name="vx_1001" Type="ProductStrategy" Mapping="Identifier:1001,Name:vx_1001"/>
    <Component Name="vx_1002" Type="ProductStrategy" Mapping="Identifier:1002,Name:vx_1002"/>