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

Commit 2b8754ee authored by François Gaffie's avatar François Gaffie
Browse files

audio: capEngine: Allow built-in strategies to omit the 'id' attribute



For builtin strategy, the "id" must be set from the name.
These builtin strategies must be provisionned in the structure file.
The parameters associated to these strategies will use their legacy
name (whereas vendor strategies are referred with "vx_<id>").

Bug: 390449625
Test: m

Change-Id: Ie03ca7860fab84f9a384c3723458702ab173c4c4
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@ampere.cars>
parent aaafa175
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 {

@@ -366,6 +367,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;
@@ -387,14 +403,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"/>