Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <fcntl.h> |
| 18 | #include <inttypes.h> |
| 19 | #include <unistd.h> |
| 20 | #include <functional> |
| 21 | #include <unordered_map> |
| 22 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 23 | #define LOG_TAG "AHAL_Config" |
Lorena Torres-Huerta | 0f4d689 | 2022-12-14 20:00:26 +0000 | [diff] [blame] | 24 | #include <aidl/android/media/audio/common/AudioFlag.h> |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 25 | #include <aidl/android/media/audio/common/AudioHalEngineConfig.h> |
Lorena Torres-Huerta | 0f4d689 | 2022-12-14 20:00:26 +0000 | [diff] [blame] | 26 | #include <aidl/android/media/audio/common/AudioProductStrategyType.h> |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 27 | #include <android-base/logging.h> |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 28 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 29 | #include "core-impl/CapEngineConfigXmlConverter.h" |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 30 | #include "core-impl/EngineConfigXmlConverter.h" |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 31 | #include "core-impl/XsdcConversion.h" |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 32 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 33 | using aidl::android::hardware::audio::core::internal::CapEngineConfigXmlConverter; |
| 34 | using aidl::android::hardware::audio::core::internal::convertAudioUsageToAidl; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 35 | using aidl::android::media::audio::common::AudioAttributes; |
| 36 | using aidl::android::media::audio::common::AudioContentType; |
| 37 | using aidl::android::media::audio::common::AudioFlag; |
| 38 | using aidl::android::media::audio::common::AudioHalAttributesGroup; |
| 39 | using aidl::android::media::audio::common::AudioHalCapCriterion; |
| 40 | using aidl::android::media::audio::common::AudioHalCapCriterionType; |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 41 | using aidl::android::media::audio::common::AudioHalCapCriterionV2; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 42 | using aidl::android::media::audio::common::AudioHalEngineConfig; |
| 43 | using aidl::android::media::audio::common::AudioHalProductStrategy; |
| 44 | using aidl::android::media::audio::common::AudioHalVolumeCurve; |
| 45 | using aidl::android::media::audio::common::AudioHalVolumeGroup; |
| 46 | using aidl::android::media::audio::common::AudioProductStrategyType; |
| 47 | using aidl::android::media::audio::common::AudioSource; |
| 48 | using aidl::android::media::audio::common::AudioStreamType; |
| 49 | using aidl::android::media::audio::common::AudioUsage; |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 50 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 51 | using ::android::BAD_VALUE; |
| 52 | using ::android::base::unexpected; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 53 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 54 | namespace eng_xsd = android::audio::policy::engine::configuration; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 55 | |
| 56 | namespace aidl::android::hardware::audio::core::internal { |
| 57 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 58 | /** Default path of audio policy cap engine configuration file. */ |
| 59 | static constexpr char kCapEngineConfigFileName[] = |
| 60 | "/parameter-framework/Settings/Policy/PolicyConfigurableDomains.xml"; |
| 61 | |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 62 | void EngineConfigXmlConverter::initProductStrategyMap() { |
| 63 | #define STRATEGY_ENTRY(name) {"STRATEGY_" #name, static_cast<int>(AudioProductStrategyType::name)} |
| 64 | |
| 65 | mProductStrategyMap = {STRATEGY_ENTRY(MEDIA), |
| 66 | STRATEGY_ENTRY(PHONE), |
| 67 | STRATEGY_ENTRY(SONIFICATION), |
| 68 | STRATEGY_ENTRY(SONIFICATION_RESPECTFUL), |
| 69 | STRATEGY_ENTRY(DTMF), |
| 70 | STRATEGY_ENTRY(ENFORCED_AUDIBLE), |
| 71 | STRATEGY_ENTRY(TRANSMITTED_THROUGH_SPEAKER), |
| 72 | STRATEGY_ENTRY(ACCESSIBILITY)}; |
| 73 | #undef STRATEGY_ENTRY |
| 74 | } |
| 75 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 76 | ConversionResult<int> EngineConfigXmlConverter::convertProductStrategyNameToAidl( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 77 | const std::string& xsdcProductStrategyName) { |
| 78 | const auto [it, success] = mProductStrategyMap.insert( |
| 79 | std::make_pair(xsdcProductStrategyName, mNextVendorStrategy)); |
| 80 | if (success) { |
| 81 | mNextVendorStrategy++; |
| 82 | } |
| 83 | return it->second; |
| 84 | } |
| 85 | |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 86 | ConversionResult<int> EngineConfigXmlConverter::convertProductStrategyIdToAidl(int xsdcId) { |
| 87 | if (xsdcId < AudioHalProductStrategy::VENDOR_STRATEGY_ID_START) { |
| 88 | return unexpected(BAD_VALUE); |
| 89 | } |
| 90 | return xsdcId; |
| 91 | } |
| 92 | |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 93 | bool isDefaultAudioAttributes(const AudioAttributes& attributes) { |
| 94 | return ((attributes.contentType == AudioContentType::UNKNOWN) && |
| 95 | (attributes.usage == AudioUsage::UNKNOWN) && |
| 96 | (attributes.source == AudioSource::DEFAULT) && (attributes.flags == 0) && |
| 97 | (attributes.tags.empty())); |
| 98 | } |
| 99 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 100 | ConversionResult<AudioAttributes> EngineConfigXmlConverter::convertAudioAttributesToAidl( |
| 101 | const eng_xsd::AttributesType& xsdcAudioAttributes) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 102 | if (xsdcAudioAttributes.hasAttributesRef()) { |
| 103 | if (mAttributesReferenceMap.empty()) { |
| 104 | mAttributesReferenceMap = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 105 | generateReferenceMap<eng_xsd::AttributesRef, eng_xsd::AttributesRefType>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 106 | getXsdcConfig()->getAttributesRef()); |
| 107 | } |
| 108 | return convertAudioAttributesToAidl( |
| 109 | *(mAttributesReferenceMap.at(xsdcAudioAttributes.getAttributesRef()) |
| 110 | .getFirstAttributes())); |
| 111 | } |
| 112 | AudioAttributes aidlAudioAttributes; |
| 113 | if (xsdcAudioAttributes.hasContentType()) { |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 114 | aidlAudioAttributes.contentType = VALUE_OR_FATAL(convertAudioContentTypeToAidl( |
| 115 | xsdcAudioAttributes.getFirstContentType()->getValue())); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 116 | } |
| 117 | if (xsdcAudioAttributes.hasUsage()) { |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 118 | aidlAudioAttributes.usage = VALUE_OR_FATAL( |
| 119 | convertAudioUsageToAidl(xsdcAudioAttributes.getFirstUsage()->getValue())); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 120 | } |
| 121 | if (xsdcAudioAttributes.hasSource()) { |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 122 | aidlAudioAttributes.source = VALUE_OR_FATAL( |
| 123 | convertAudioSourceToAidl(xsdcAudioAttributes.getFirstSource()->getValue())); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 124 | } |
| 125 | if (xsdcAudioAttributes.hasFlags()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 126 | std::vector<eng_xsd::FlagType> xsdcFlagTypeVec = |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 127 | xsdcAudioAttributes.getFirstFlags()->getValue(); |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 128 | aidlAudioAttributes.flags = VALUE_OR_FATAL(convertAudioFlagsToAidl(xsdcFlagTypeVec)); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 129 | } |
| 130 | if (xsdcAudioAttributes.hasBundle()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 131 | const eng_xsd::BundleType* xsdcBundle = xsdcAudioAttributes.getFirstBundle(); |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 132 | aidlAudioAttributes.tags.reserve(1); |
| 133 | aidlAudioAttributes.tags.push_back(xsdcBundle->getKey() + "_" + xsdcBundle->getValue()); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 134 | } |
| 135 | if (isDefaultAudioAttributes(aidlAudioAttributes)) { |
| 136 | mDefaultProductStrategyId = std::optional<int>{-1}; |
| 137 | } |
| 138 | return aidlAudioAttributes; |
| 139 | } |
| 140 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 141 | ConversionResult<AudioHalAttributesGroup> EngineConfigXmlConverter::convertAttributesGroupToAidl( |
| 142 | const eng_xsd::AttributesGroup& xsdcAttributesGroup) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 143 | AudioHalAttributesGroup aidlAttributesGroup; |
| 144 | static const int kStreamTypeEnumOffset = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 145 | static_cast<int>(eng_xsd::Stream::AUDIO_STREAM_VOICE_CALL) - |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 146 | static_cast<int>(AudioStreamType::VOICE_CALL); |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 147 | aidlAttributesGroup.streamType = xsdcAttributesGroup.hasStreamType() |
| 148 | ? VALUE_OR_FATAL(convertAudioStreamTypeToAidl( |
| 149 | xsdcAttributesGroup.getStreamType())) |
| 150 | : AudioStreamType::INVALID; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 151 | aidlAttributesGroup.volumeGroupName = xsdcAttributesGroup.getVolumeGroup(); |
| 152 | if (xsdcAttributesGroup.hasAttributes_optional()) { |
| 153 | aidlAttributesGroup.attributes = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 154 | VALUE_OR_FATAL((convertCollectionToAidl<eng_xsd::AttributesType, AudioAttributes>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 155 | xsdcAttributesGroup.getAttributes_optional(), |
| 156 | std::bind(&EngineConfigXmlConverter::convertAudioAttributesToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 157 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 158 | } else if (xsdcAttributesGroup.hasContentType_optional() || |
| 159 | xsdcAttributesGroup.hasUsage_optional() || |
| 160 | xsdcAttributesGroup.hasSource_optional() || |
| 161 | xsdcAttributesGroup.hasFlags_optional() || |
| 162 | xsdcAttributesGroup.hasBundle_optional()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 163 | aidlAttributesGroup.attributes.push_back(VALUE_OR_FATAL(convertAudioAttributesToAidl( |
| 164 | eng_xsd::AttributesType(xsdcAttributesGroup.getContentType_optional(), |
| 165 | xsdcAttributesGroup.getUsage_optional(), |
| 166 | xsdcAttributesGroup.getSource_optional(), |
| 167 | xsdcAttributesGroup.getFlags_optional(), |
| 168 | xsdcAttributesGroup.getBundle_optional(), std::nullopt)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 169 | |
| 170 | } else { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 171 | LOG(ERROR) << __func__ << " Review Audio Policy config: no audio attributes provided for " |
| 172 | << aidlAttributesGroup.toString(); |
| 173 | return unexpected(BAD_VALUE); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 174 | } |
| 175 | return aidlAttributesGroup; |
| 176 | } |
| 177 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 178 | ConversionResult<AudioHalProductStrategy> EngineConfigXmlConverter::convertProductStrategyToAidl( |
| 179 | const eng_xsd::ProductStrategies::ProductStrategy& xsdcProductStrategy) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 180 | AudioHalProductStrategy aidlProductStrategy; |
| 181 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 182 | aidlProductStrategy.id = |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 183 | VALUE_OR_FATAL(convertProductStrategyIdToAidl(xsdcProductStrategy.getId())); |
| 184 | aidlProductStrategy.name = xsdcProductStrategy.getName(); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 185 | |
| 186 | if (xsdcProductStrategy.hasAttributesGroup()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 187 | aidlProductStrategy.attributesGroups = VALUE_OR_FATAL( |
| 188 | (convertCollectionToAidl<eng_xsd::AttributesGroup, AudioHalAttributesGroup>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 189 | xsdcProductStrategy.getAttributesGroup(), |
| 190 | std::bind(&EngineConfigXmlConverter::convertAttributesGroupToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 191 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 192 | } |
| 193 | if ((mDefaultProductStrategyId != std::nullopt) && (mDefaultProductStrategyId.value() == -1)) { |
| 194 | mDefaultProductStrategyId = aidlProductStrategy.id; |
| 195 | } |
| 196 | return aidlProductStrategy; |
| 197 | } |
| 198 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 199 | ConversionResult<AudioHalVolumeCurve> EngineConfigXmlConverter::convertVolumeCurveToAidl( |
| 200 | const eng_xsd::Volume& xsdcVolumeCurve) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 201 | AudioHalVolumeCurve aidlVolumeCurve; |
| 202 | aidlVolumeCurve.deviceCategory = |
| 203 | static_cast<AudioHalVolumeCurve::DeviceCategory>(xsdcVolumeCurve.getDeviceCategory()); |
| 204 | if (xsdcVolumeCurve.hasRef()) { |
| 205 | if (mVolumesReferenceMap.empty()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 206 | mVolumesReferenceMap = generateReferenceMap<eng_xsd::VolumesType, eng_xsd::VolumeRef>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 207 | getXsdcConfig()->getVolumes()); |
| 208 | } |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 209 | aidlVolumeCurve.curvePoints = VALUE_OR_FATAL( |
| 210 | (convertCollectionToAidl<std::string, AudioHalVolumeCurve::CurvePoint>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 211 | mVolumesReferenceMap.at(xsdcVolumeCurve.getRef()).getPoint(), |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 212 | &convertCurvePointToAidl))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 213 | } else { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 214 | aidlVolumeCurve.curvePoints = VALUE_OR_FATAL( |
| 215 | (convertCollectionToAidl<std::string, AudioHalVolumeCurve::CurvePoint>( |
| 216 | xsdcVolumeCurve.getPoint(), &convertCurvePointToAidl))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 217 | } |
| 218 | return aidlVolumeCurve; |
| 219 | } |
| 220 | |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 221 | ConversionResult<AudioHalVolumeGroup> EngineConfigXmlConverter::convertVolumeGroupToAidl( |
| 222 | const eng_xsd::VolumeGroupsType::VolumeGroup& xsdcVolumeGroup) { |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 223 | AudioHalVolumeGroup aidlVolumeGroup; |
| 224 | aidlVolumeGroup.name = xsdcVolumeGroup.getName(); |
| 225 | aidlVolumeGroup.minIndex = xsdcVolumeGroup.getIndexMin(); |
| 226 | aidlVolumeGroup.maxIndex = xsdcVolumeGroup.getIndexMax(); |
Lorena Torres-Huerta | aa8f76a | 2022-12-12 18:17:10 +0000 | [diff] [blame] | 227 | aidlVolumeGroup.volumeCurves = |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 228 | VALUE_OR_FATAL((convertCollectionToAidl<eng_xsd::Volume, AudioHalVolumeCurve>( |
Lorena Torres-Huerta | aa8f76a | 2022-12-12 18:17:10 +0000 | [diff] [blame] | 229 | xsdcVolumeGroup.getVolume(), |
| 230 | std::bind(&EngineConfigXmlConverter::convertVolumeCurveToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 231 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 232 | return aidlVolumeGroup; |
| 233 | } |
| 234 | |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 235 | AudioHalEngineConfig& EngineConfigXmlConverter::getAidlEngineConfig() { |
| 236 | return mAidlEngineConfig; |
| 237 | } |
| 238 | |
| 239 | void EngineConfigXmlConverter::init() { |
| 240 | initProductStrategyMap(); |
| 241 | if (getXsdcConfig()->hasProductStrategies()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 242 | mAidlEngineConfig.productStrategies = VALUE_OR_FATAL( |
| 243 | (convertWrappedCollectionToAidl<eng_xsd::ProductStrategies, |
| 244 | eng_xsd::ProductStrategies::ProductStrategy, |
| 245 | AudioHalProductStrategy>( |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 246 | getXsdcConfig()->getProductStrategies(), |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 247 | &eng_xsd::ProductStrategies::getProductStrategy, |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 248 | std::bind(&EngineConfigXmlConverter::convertProductStrategyToAidl, this, |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 249 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 250 | if (mDefaultProductStrategyId) { |
| 251 | mAidlEngineConfig.defaultProductStrategyId = mDefaultProductStrategyId.value(); |
| 252 | } |
| 253 | } |
| 254 | if (getXsdcConfig()->hasVolumeGroups()) { |
Lorena Torres-Huerta | 394e252 | 2022-12-20 02:21:41 +0000 | [diff] [blame] | 255 | mAidlEngineConfig.volumeGroups = VALUE_OR_FATAL( |
| 256 | (convertWrappedCollectionToAidl<eng_xsd::VolumeGroupsType, |
| 257 | eng_xsd::VolumeGroupsType::VolumeGroup, |
| 258 | AudioHalVolumeGroup>( |
| 259 | getXsdcConfig()->getVolumeGroups(), |
| 260 | &eng_xsd::VolumeGroupsType::getVolumeGroup, |
| 261 | std::bind(&EngineConfigXmlConverter::convertVolumeGroupToAidl, this, |
| 262 | std::placeholders::_1)))); |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 263 | } |
| 264 | if (getXsdcConfig()->hasCriteria() && getXsdcConfig()->hasCriterion_types()) { |
| 265 | AudioHalEngineConfig::CapSpecificConfig capSpecificConfig; |
François Gaffie | 57ccab7 | 2024-04-17 11:47:51 +0200 | [diff] [blame] | 266 | capSpecificConfig.criteriaV2 = |
| 267 | std::make_optional<>(VALUE_OR_FATAL((convertCapCriteriaCollectionToAidl( |
| 268 | getXsdcConfig()->getCriteria(), getXsdcConfig()->getCriterion_types())))); |
| 269 | internal::CapEngineConfigXmlConverter capEngConfigConverter{ |
| 270 | ::android::audio_find_readable_configuration_file(kCapEngineConfigFileName)}; |
| 271 | if (capEngConfigConverter.getStatus() == ::android::OK) { |
| 272 | capSpecificConfig.domains = std::move(capEngConfigConverter.getAidlCapEngineConfig()); |
| 273 | } |
| 274 | mAidlEngineConfig.capSpecificConfig = capSpecificConfig; |
Lorena Torres-Huerta | bc585bd | 2022-10-23 20:41:35 +0000 | [diff] [blame] | 275 | } |
| 276 | } |
Lorena Torres-Huerta | aa8f76a | 2022-12-12 18:17:10 +0000 | [diff] [blame] | 277 | } // namespace aidl::android::hardware::audio::core::internal |