1 #define LOG_TAG "aidl.android.hardware.bluetooth.audio.setting"
2 #include "aidl_android_hardware_bluetooth_audio_setting.h"
3 
4 #include <assert.h>
5 #ifndef __BIONIC__
6 #define __assert2(f,n,fun,e) do { fprintf(stderr, "%s:%d: %s: Assertion `%s' failed", (f), (n), (fun), (e)); abort(); } while (false)
7 #endif
8 #define _xsdc_assert(e) do if (!(e)) __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e); while (false)
9 
10 namespace aidl {
11     namespace android {
12         namespace hardware {
13             namespace bluetooth {
14                 namespace audio {
15                     namespace setting {
16                         template <class T>
17                         constexpr void (*xmlDeleter)(T* t);
18                         template <>
19                         constexpr auto xmlDeleter<xmlDoc> = xmlFreeDoc;
20                         template <>
__anonc394a2ff0102(xmlChar *s) 21                         auto xmlDeleter<xmlChar> = [](xmlChar *s) { xmlFree(s); };
22 
23                         template <class T>
make_xmlUnique(T * t)24                         constexpr auto make_xmlUnique(T *t) {
25                             auto deleter = [](T *t) { xmlDeleter<T>(t); };
26                             return std::unique_ptr<T, decltype(deleter)>{t, deleter};
27                         }
28 
getXmlAttribute(const xmlNode * cur,const char * attribute)29                         static std::string getXmlAttribute(const xmlNode *cur, const char *attribute) {
30                             auto xmlValue = make_xmlUnique(xmlGetProp(cur, reinterpret_cast<const xmlChar*>(attribute)));
31                             if (xmlValue == nullptr) {
32                                 return "";
33                             }
34                             std::string value(reinterpret_cast<const char*>(xmlValue.get()));
35                             return value;
36                         }
37 
readLeAudioOffloadSetting(const char * configFile)38                         std::optional<LeAudioOffloadSetting> readLeAudioOffloadSetting(const char* configFile) {
39                             auto doc = make_xmlUnique(xmlParseFile(configFile));
40                             if (doc == nullptr) {
41                                 return std::nullopt;
42                             }
43                             xmlNodePtr _child = xmlDocGetRootElement(doc.get());
44                             if (_child == nullptr) {
45                                 return std::nullopt;
46                             }
47                             if (xmlXIncludeProcess(doc.get()) < 0) {
48                                 return std::nullopt;
49                             }
50 
51                             if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("leAudioOffloadSetting"))) {
52                                 LeAudioOffloadSetting _value = LeAudioOffloadSetting::read(_child);
53                                 return _value;
54                             }
55                             return std::nullopt;
56                         }
57 
parseLeAudioOffloadSetting(const char * xml)58                         std::optional<LeAudioOffloadSetting> parseLeAudioOffloadSetting(const char* xml) {
59                             auto doc = make_xmlUnique(xmlParseDoc(reinterpret_cast<const xmlChar*>(xml)));
60                             if (doc == nullptr) {
61                                 return std::nullopt;
62                             }
63                             xmlNodePtr _child = xmlDocGetRootElement(doc.get());
64                             if (_child == nullptr) {
65                                 return std::nullopt;
66                             }
67                             if (xmlXIncludeProcess(doc.get()) < 0) {
68                                 return std::nullopt;
69                             }
70 
71                             if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("leAudioOffloadSetting"))) {
72                                 LeAudioOffloadSetting _value = LeAudioOffloadSetting::read(_child);
73                                 return _value;
74                             }
75                             return std::nullopt;
76                         }
77 
78 
LeAudioOffloadSetting(std::vector<ScenarioList> scenarioList,std::vector<ConfigurationList> configurationList,std::vector<CodecConfigurationList> codecConfigurationList,std::vector<StrategyConfigurationList> strategyConfigurationList)79                         LeAudioOffloadSetting::LeAudioOffloadSetting(std::vector<ScenarioList> scenarioList, std::vector<ConfigurationList> configurationList, std::vector<CodecConfigurationList> codecConfigurationList, std::vector<StrategyConfigurationList> strategyConfigurationList) : scenarioList_(std::move(scenarioList)), configurationList_(std::move(configurationList)), codecConfigurationList_(std::move(codecConfigurationList)), strategyConfigurationList_(std::move(strategyConfigurationList)) {
80                         }
81 
getScenarioList() const82                         const std::vector<ScenarioList>& LeAudioOffloadSetting::getScenarioList() const {
83                             return scenarioList_;
84                         }
85 
hasScenarioList() const86                         bool LeAudioOffloadSetting::hasScenarioList() const {
87                             return !(scenarioList_.empty());
88                         }
89 
getFirstScenarioList() const90                         const ScenarioList* LeAudioOffloadSetting::getFirstScenarioList() const {
91                             if (scenarioList_.empty()) {
92                                 return nullptr;
93                             }
94                             return &scenarioList_[0];
95                         }
96 
getConfigurationList() const97                         const std::vector<ConfigurationList>& LeAudioOffloadSetting::getConfigurationList() const {
98                             return configurationList_;
99                         }
100 
hasConfigurationList() const101                         bool LeAudioOffloadSetting::hasConfigurationList() const {
102                             return !(configurationList_.empty());
103                         }
104 
getFirstConfigurationList() const105                         const ConfigurationList* LeAudioOffloadSetting::getFirstConfigurationList() const {
106                             if (configurationList_.empty()) {
107                                 return nullptr;
108                             }
109                             return &configurationList_[0];
110                         }
111 
getCodecConfigurationList() const112                         const std::vector<CodecConfigurationList>& LeAudioOffloadSetting::getCodecConfigurationList() const {
113                             return codecConfigurationList_;
114                         }
115 
hasCodecConfigurationList() const116                         bool LeAudioOffloadSetting::hasCodecConfigurationList() const {
117                             return !(codecConfigurationList_.empty());
118                         }
119 
getFirstCodecConfigurationList() const120                         const CodecConfigurationList* LeAudioOffloadSetting::getFirstCodecConfigurationList() const {
121                             if (codecConfigurationList_.empty()) {
122                                 return nullptr;
123                             }
124                             return &codecConfigurationList_[0];
125                         }
126 
getStrategyConfigurationList() const127                         const std::vector<StrategyConfigurationList>& LeAudioOffloadSetting::getStrategyConfigurationList() const {
128                             return strategyConfigurationList_;
129                         }
130 
hasStrategyConfigurationList() const131                         bool LeAudioOffloadSetting::hasStrategyConfigurationList() const {
132                             return !(strategyConfigurationList_.empty());
133                         }
134 
getFirstStrategyConfigurationList() const135                         const StrategyConfigurationList* LeAudioOffloadSetting::getFirstStrategyConfigurationList() const {
136                             if (strategyConfigurationList_.empty()) {
137                                 return nullptr;
138                             }
139                             return &strategyConfigurationList_[0];
140                         }
141 
read(xmlNode * root)142                         LeAudioOffloadSetting LeAudioOffloadSetting::read(xmlNode *root) {
143                             std::string _raw;
144                             std::vector<ScenarioList> scenarioList;
145                             std::vector<ConfigurationList> configurationList;
146                             std::vector<CodecConfigurationList> codecConfigurationList;
147                             std::vector<StrategyConfigurationList> strategyConfigurationList;
148                             for (auto *_child = root->xmlChildrenNode; _child != nullptr; _child = _child->next) {
149                                 if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("scenarioList"))) {
150                                     ScenarioList _value = ScenarioList::read(_child);
151                                     scenarioList.push_back(std::move(_value));
152                                 } else if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("configurationList"))) {
153                                     ConfigurationList _value = ConfigurationList::read(_child);
154                                     configurationList.push_back(std::move(_value));
155                                 } else if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("codecConfigurationList"))) {
156                                     CodecConfigurationList _value = CodecConfigurationList::read(_child);
157                                     codecConfigurationList.push_back(std::move(_value));
158                                 } else if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("strategyConfigurationList"))) {
159                                     StrategyConfigurationList _value = StrategyConfigurationList::read(_child);
160                                     strategyConfigurationList.push_back(std::move(_value));
161                                 }
162                             }
163                             LeAudioOffloadSetting instance(scenarioList, configurationList, codecConfigurationList, strategyConfigurationList);
164                             return instance;
165                         }
166 
ScenarioList(std::vector<Scenario> scenario)167                         ScenarioList::ScenarioList(std::vector<Scenario> scenario) : scenario_(std::move(scenario)) {
168                         }
169 
getScenario() const170                         const std::vector<Scenario>& ScenarioList::getScenario() const {
171                             return scenario_;
172                         }
173 
hasScenario() const174                         bool ScenarioList::hasScenario() const {
175                             return !(scenario_.empty());
176                         }
177 
getFirstScenario() const178                         const Scenario* ScenarioList::getFirstScenario() const {
179                             if (scenario_.empty()) {
180                                 return nullptr;
181                             }
182                             return &scenario_[0];
183                         }
184 
read(xmlNode * root)185                         ScenarioList ScenarioList::read(xmlNode *root) {
186                             std::string _raw;
187                             std::vector<Scenario> scenario;
188                             for (auto *_child = root->xmlChildrenNode; _child != nullptr; _child = _child->next) {
189                                 if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("scenario"))) {
190                                     Scenario _value = Scenario::read(_child);
191                                     scenario.push_back(std::move(_value));
192                                 }
193                             }
194                             ScenarioList instance(scenario);
195                             return instance;
196                         }
197 
ConfigurationList(std::vector<Configuration> configuration)198                         ConfigurationList::ConfigurationList(std::vector<Configuration> configuration) : configuration_(std::move(configuration)) {
199                         }
200 
getConfiguration() const201                         const std::vector<Configuration>& ConfigurationList::getConfiguration() const {
202                             return configuration_;
203                         }
204 
hasConfiguration() const205                         bool ConfigurationList::hasConfiguration() const {
206                             return !(configuration_.empty());
207                         }
208 
getFirstConfiguration() const209                         const Configuration* ConfigurationList::getFirstConfiguration() const {
210                             if (configuration_.empty()) {
211                                 return nullptr;
212                             }
213                             return &configuration_[0];
214                         }
215 
read(xmlNode * root)216                         ConfigurationList ConfigurationList::read(xmlNode *root) {
217                             std::string _raw;
218                             std::vector<Configuration> configuration;
219                             for (auto *_child = root->xmlChildrenNode; _child != nullptr; _child = _child->next) {
220                                 if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("configuration"))) {
221                                     Configuration _value = Configuration::read(_child);
222                                     configuration.push_back(std::move(_value));
223                                 }
224                             }
225                             ConfigurationList instance(configuration);
226                             return instance;
227                         }
228 
CodecConfigurationList(std::vector<CodecConfiguration> codecConfiguration)229                         CodecConfigurationList::CodecConfigurationList(std::vector<CodecConfiguration> codecConfiguration) : codecConfiguration_(std::move(codecConfiguration)) {
230                         }
231 
getCodecConfiguration() const232                         const std::vector<CodecConfiguration>& CodecConfigurationList::getCodecConfiguration() const {
233                             return codecConfiguration_;
234                         }
235 
hasCodecConfiguration() const236                         bool CodecConfigurationList::hasCodecConfiguration() const {
237                             return !(codecConfiguration_.empty());
238                         }
239 
getFirstCodecConfiguration() const240                         const CodecConfiguration* CodecConfigurationList::getFirstCodecConfiguration() const {
241                             if (codecConfiguration_.empty()) {
242                                 return nullptr;
243                             }
244                             return &codecConfiguration_[0];
245                         }
246 
read(xmlNode * root)247                         CodecConfigurationList CodecConfigurationList::read(xmlNode *root) {
248                             std::string _raw;
249                             std::vector<CodecConfiguration> codecConfiguration;
250                             for (auto *_child = root->xmlChildrenNode; _child != nullptr; _child = _child->next) {
251                                 if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("codecConfiguration"))) {
252                                     CodecConfiguration _value = CodecConfiguration::read(_child);
253                                     codecConfiguration.push_back(std::move(_value));
254                                 }
255                             }
256                             CodecConfigurationList instance(codecConfiguration);
257                             return instance;
258                         }
259 
StrategyConfigurationList(std::vector<StrategyConfiguration> strategyConfiguration)260                         StrategyConfigurationList::StrategyConfigurationList(std::vector<StrategyConfiguration> strategyConfiguration) : strategyConfiguration_(std::move(strategyConfiguration)) {
261                         }
262 
getStrategyConfiguration() const263                         const std::vector<StrategyConfiguration>& StrategyConfigurationList::getStrategyConfiguration() const {
264                             return strategyConfiguration_;
265                         }
266 
hasStrategyConfiguration() const267                         bool StrategyConfigurationList::hasStrategyConfiguration() const {
268                             return !(strategyConfiguration_.empty());
269                         }
270 
getFirstStrategyConfiguration() const271                         const StrategyConfiguration* StrategyConfigurationList::getFirstStrategyConfiguration() const {
272                             if (strategyConfiguration_.empty()) {
273                                 return nullptr;
274                             }
275                             return &strategyConfiguration_[0];
276                         }
277 
read(xmlNode * root)278                         StrategyConfigurationList StrategyConfigurationList::read(xmlNode *root) {
279                             std::string _raw;
280                             std::vector<StrategyConfiguration> strategyConfiguration;
281                             for (auto *_child = root->xmlChildrenNode; _child != nullptr; _child = _child->next) {
282                                 if (!xmlStrcmp(_child->name, reinterpret_cast<const xmlChar*>("strategyConfiguration"))) {
283                                     StrategyConfiguration _value = StrategyConfiguration::read(_child);
284                                     strategyConfiguration.push_back(std::move(_value));
285                                 }
286                             }
287                             StrategyConfigurationList instance(strategyConfiguration);
288                             return instance;
289                         }
290 
Scenario(std::optional<std::string> encode,std::optional<std::string> decode,std::optional<std::string> broadcast)291                         Scenario::Scenario(std::optional<std::string> encode, std::optional<std::string> decode, std::optional<std::string> broadcast) : encode_(std::move(encode)), decode_(std::move(decode)), broadcast_(std::move(broadcast)) {
292                         }
293 
getEncode() const294                         const std::string& Scenario::getEncode() const {
295                             _xsdc_assert(hasEncode());
296                             return encode_.value();
297                         }
298 
hasEncode() const299                         bool Scenario::hasEncode() const {
300                             return encode_.has_value();
301                         }
302 
getDecode() const303                         const std::string& Scenario::getDecode() const {
304                             _xsdc_assert(hasDecode());
305                             return decode_.value();
306                         }
307 
hasDecode() const308                         bool Scenario::hasDecode() const {
309                             return decode_.has_value();
310                         }
311 
getBroadcast() const312                         const std::string& Scenario::getBroadcast() const {
313                             _xsdc_assert(hasBroadcast());
314                             return broadcast_.value();
315                         }
316 
hasBroadcast() const317                         bool Scenario::hasBroadcast() const {
318                             return broadcast_.has_value();
319                         }
320 
read(xmlNode * root)321                         Scenario Scenario::read(xmlNode *root) {
322                             std::string _raw;
323                             _raw = getXmlAttribute(root, "encode");
324                             std::optional<std::string> encode = std::nullopt;
325                             if (_raw != "") {
326                                 std::string &_value = _raw;
327                                 encode = _value;
328                             }
329                             _raw = getXmlAttribute(root, "decode");
330                             std::optional<std::string> decode = std::nullopt;
331                             if (_raw != "") {
332                                 std::string &_value = _raw;
333                                 decode = _value;
334                             }
335                             _raw = getXmlAttribute(root, "broadcast");
336                             std::optional<std::string> broadcast = std::nullopt;
337                             if (_raw != "") {
338                                 std::string &_value = _raw;
339                                 broadcast = _value;
340                             }
341                             Scenario instance(encode, decode, broadcast);
342                             return instance;
343                         }
344 
Configuration(std::optional<std::string> name,std::optional<std::string> codecConfiguration,std::optional<std::string> strategyConfiguration)345                         Configuration::Configuration(std::optional<std::string> name, std::optional<std::string> codecConfiguration, std::optional<std::string> strategyConfiguration) : name_(std::move(name)), codecConfiguration_(std::move(codecConfiguration)), strategyConfiguration_(std::move(strategyConfiguration)) {
346                         }
347 
getName() const348                         const std::string& Configuration::getName() const {
349                             _xsdc_assert(hasName());
350                             return name_.value();
351                         }
352 
hasName() const353                         bool Configuration::hasName() const {
354                             return name_.has_value();
355                         }
356 
getCodecConfiguration() const357                         const std::string& Configuration::getCodecConfiguration() const {
358                             _xsdc_assert(hasCodecConfiguration());
359                             return codecConfiguration_.value();
360                         }
361 
hasCodecConfiguration() const362                         bool Configuration::hasCodecConfiguration() const {
363                             return codecConfiguration_.has_value();
364                         }
365 
getStrategyConfiguration() const366                         const std::string& Configuration::getStrategyConfiguration() const {
367                             _xsdc_assert(hasStrategyConfiguration());
368                             return strategyConfiguration_.value();
369                         }
370 
hasStrategyConfiguration() const371                         bool Configuration::hasStrategyConfiguration() const {
372                             return strategyConfiguration_.has_value();
373                         }
374 
read(xmlNode * root)375                         Configuration Configuration::read(xmlNode *root) {
376                             std::string _raw;
377                             _raw = getXmlAttribute(root, "name");
378                             std::optional<std::string> name = std::nullopt;
379                             if (_raw != "") {
380                                 std::string &_value = _raw;
381                                 name = _value;
382                             }
383                             _raw = getXmlAttribute(root, "codecConfiguration");
384                             std::optional<std::string> codecConfiguration = std::nullopt;
385                             if (_raw != "") {
386                                 std::string &_value = _raw;
387                                 codecConfiguration = _value;
388                             }
389                             _raw = getXmlAttribute(root, "strategyConfiguration");
390                             std::optional<std::string> strategyConfiguration = std::nullopt;
391                             if (_raw != "") {
392                                 std::string &_value = _raw;
393                                 strategyConfiguration = _value;
394                             }
395                             Configuration instance(name, codecConfiguration, strategyConfiguration);
396                             return instance;
397                         }
398 
CodecConfiguration(std::optional<std::string> name,std::optional<CodecType> codec,std::optional<unsigned char> pcmBitDepth,std::optional<int> samplingFrequency,std::optional<int> frameDurationUs,std::optional<int> octetsPerCodecFrame,std::optional<unsigned char> codecFrameBlocksPerSdu)399                         CodecConfiguration::CodecConfiguration(std::optional<std::string> name, std::optional<CodecType> codec, std::optional<unsigned char> pcmBitDepth, std::optional<int> samplingFrequency, std::optional<int> frameDurationUs, std::optional<int> octetsPerCodecFrame, std::optional<unsigned char> codecFrameBlocksPerSdu) : name_(std::move(name)), codec_(codec), pcmBitDepth_(pcmBitDepth), samplingFrequency_(samplingFrequency), frameDurationUs_(frameDurationUs), octetsPerCodecFrame_(octetsPerCodecFrame), codecFrameBlocksPerSdu_(codecFrameBlocksPerSdu) {
400                         }
401 
getName() const402                         const std::string& CodecConfiguration::getName() const {
403                             _xsdc_assert(hasName());
404                             return name_.value();
405                         }
406 
hasName() const407                         bool CodecConfiguration::hasName() const {
408                             return name_.has_value();
409                         }
410 
getCodec() const411                         const CodecType& CodecConfiguration::getCodec() const {
412                             _xsdc_assert(hasCodec());
413                             return codec_.value();
414                         }
415 
hasCodec() const416                         bool CodecConfiguration::hasCodec() const {
417                             return codec_.has_value();
418                         }
419 
getPcmBitDepth() const420                         const unsigned char& CodecConfiguration::getPcmBitDepth() const {
421                             _xsdc_assert(hasPcmBitDepth());
422                             return pcmBitDepth_.value();
423                         }
424 
hasPcmBitDepth() const425                         bool CodecConfiguration::hasPcmBitDepth() const {
426                             return pcmBitDepth_.has_value();
427                         }
428 
getSamplingFrequency() const429                         const int& CodecConfiguration::getSamplingFrequency() const {
430                             _xsdc_assert(hasSamplingFrequency());
431                             return samplingFrequency_.value();
432                         }
433 
hasSamplingFrequency() const434                         bool CodecConfiguration::hasSamplingFrequency() const {
435                             return samplingFrequency_.has_value();
436                         }
437 
getFrameDurationUs() const438                         const int& CodecConfiguration::getFrameDurationUs() const {
439                             _xsdc_assert(hasFrameDurationUs());
440                             return frameDurationUs_.value();
441                         }
442 
hasFrameDurationUs() const443                         bool CodecConfiguration::hasFrameDurationUs() const {
444                             return frameDurationUs_.has_value();
445                         }
446 
getOctetsPerCodecFrame() const447                         const int& CodecConfiguration::getOctetsPerCodecFrame() const {
448                             _xsdc_assert(hasOctetsPerCodecFrame());
449                             return octetsPerCodecFrame_.value();
450                         }
451 
hasOctetsPerCodecFrame() const452                         bool CodecConfiguration::hasOctetsPerCodecFrame() const {
453                             return octetsPerCodecFrame_.has_value();
454                         }
455 
getCodecFrameBlocksPerSdu() const456                         const unsigned char& CodecConfiguration::getCodecFrameBlocksPerSdu() const {
457                             _xsdc_assert(hasCodecFrameBlocksPerSdu());
458                             return codecFrameBlocksPerSdu_.value();
459                         }
460 
hasCodecFrameBlocksPerSdu() const461                         bool CodecConfiguration::hasCodecFrameBlocksPerSdu() const {
462                             return codecFrameBlocksPerSdu_.has_value();
463                         }
464 
read(xmlNode * root)465                         CodecConfiguration CodecConfiguration::read(xmlNode *root) {
466                             std::string _raw;
467                             _raw = getXmlAttribute(root, "name");
468                             std::optional<std::string> name = std::nullopt;
469                             if (_raw != "") {
470                                 std::string &_value = _raw;
471                                 name = _value;
472                             }
473                             _raw = getXmlAttribute(root, "codec");
474                             std::optional<CodecType> codec = std::nullopt;
475                             if (_raw != "") {
476                                 CodecType _value = stringToCodecType(_raw);
477                                 codec = _value;
478                             }
479                             _raw = getXmlAttribute(root, "pcmBitDepth");
480                             std::optional<unsigned char> pcmBitDepth = std::nullopt;
481                             if (_raw != "") {
482                                 unsigned char _value = static_cast<unsigned char>(std::stoi(_raw));
483                                 pcmBitDepth = _value;
484                             }
485                             _raw = getXmlAttribute(root, "samplingFrequency");
486                             std::optional<int> samplingFrequency = std::nullopt;
487                             if (_raw != "") {
488                                 int _value = std::stoi(_raw);
489                                 samplingFrequency = _value;
490                             }
491                             _raw = getXmlAttribute(root, "frameDurationUs");
492                             std::optional<int> frameDurationUs = std::nullopt;
493                             if (_raw != "") {
494                                 int _value = std::stoi(_raw);
495                                 frameDurationUs = _value;
496                             }
497                             _raw = getXmlAttribute(root, "octetsPerCodecFrame");
498                             std::optional<int> octetsPerCodecFrame = std::nullopt;
499                             if (_raw != "") {
500                                 int _value = std::stoi(_raw);
501                                 octetsPerCodecFrame = _value;
502                             }
503                             _raw = getXmlAttribute(root, "codecFrameBlocksPerSdu");
504                             std::optional<unsigned char> codecFrameBlocksPerSdu = std::nullopt;
505                             if (_raw != "") {
506                                 unsigned char _value = static_cast<unsigned char>(std::stoi(_raw));
507                                 codecFrameBlocksPerSdu = _value;
508                             }
509                             CodecConfiguration instance(name, codec, pcmBitDepth, samplingFrequency, frameDurationUs, octetsPerCodecFrame, codecFrameBlocksPerSdu);
510                             return instance;
511                         }
512 
StrategyConfiguration(std::optional<std::string> name,std::optional<AudioLocation> audioLocation,std::optional<unsigned char> connectedDevice,std::optional<unsigned char> channelCount,std::optional<int> audioChannelAllocation)513                         StrategyConfiguration::StrategyConfiguration(std::optional<std::string> name, std::optional<AudioLocation> audioLocation, std::optional<unsigned char> connectedDevice, std::optional<unsigned char> channelCount, std::optional<int> audioChannelAllocation) : name_(std::move(name)), audioLocation_(audioLocation), connectedDevice_(connectedDevice), channelCount_(channelCount), audioChannelAllocation_(audioChannelAllocation) {
514                         }
515 
getName() const516                         const std::string& StrategyConfiguration::getName() const {
517                             _xsdc_assert(hasName());
518                             return name_.value();
519                         }
520 
hasName() const521                         bool StrategyConfiguration::hasName() const {
522                             return name_.has_value();
523                         }
524 
getAudioLocation() const525                         const AudioLocation& StrategyConfiguration::getAudioLocation() const {
526                             _xsdc_assert(hasAudioLocation());
527                             return audioLocation_.value();
528                         }
529 
hasAudioLocation() const530                         bool StrategyConfiguration::hasAudioLocation() const {
531                             return audioLocation_.has_value();
532                         }
533 
getConnectedDevice() const534                         const unsigned char& StrategyConfiguration::getConnectedDevice() const {
535                             _xsdc_assert(hasConnectedDevice());
536                             return connectedDevice_.value();
537                         }
538 
hasConnectedDevice() const539                         bool StrategyConfiguration::hasConnectedDevice() const {
540                             return connectedDevice_.has_value();
541                         }
542 
getChannelCount() const543                         const unsigned char& StrategyConfiguration::getChannelCount() const {
544                             _xsdc_assert(hasChannelCount());
545                             return channelCount_.value();
546                         }
547 
hasChannelCount() const548                         bool StrategyConfiguration::hasChannelCount() const {
549                             return channelCount_.has_value();
550                         }
551 
getAudioChannelAllocation() const552                         const int& StrategyConfiguration::getAudioChannelAllocation() const {
553                             _xsdc_assert(hasAudioChannelAllocation());
554                             return audioChannelAllocation_.value();
555                         }
556 
hasAudioChannelAllocation() const557                         bool StrategyConfiguration::hasAudioChannelAllocation() const {
558                             return audioChannelAllocation_.has_value();
559                         }
560 
read(xmlNode * root)561                         StrategyConfiguration StrategyConfiguration::read(xmlNode *root) {
562                             std::string _raw;
563                             _raw = getXmlAttribute(root, "name");
564                             std::optional<std::string> name = std::nullopt;
565                             if (_raw != "") {
566                                 std::string &_value = _raw;
567                                 name = _value;
568                             }
569                             _raw = getXmlAttribute(root, "audioLocation");
570                             std::optional<AudioLocation> audioLocation = std::nullopt;
571                             if (_raw != "") {
572                                 AudioLocation _value = stringToAudioLocation(_raw);
573                                 audioLocation = _value;
574                             }
575                             _raw = getXmlAttribute(root, "connectedDevice");
576                             std::optional<unsigned char> connectedDevice = std::nullopt;
577                             if (_raw != "") {
578                                 unsigned char _value = static_cast<unsigned char>(std::stoi(_raw));
579                                 connectedDevice = _value;
580                             }
581                             _raw = getXmlAttribute(root, "channelCount");
582                             std::optional<unsigned char> channelCount = std::nullopt;
583                             if (_raw != "") {
584                                 unsigned char _value = static_cast<unsigned char>(std::stoi(_raw));
585                                 channelCount = _value;
586                             }
587                             _raw = getXmlAttribute(root, "audioChannelAllocation");
588                             std::optional<int> audioChannelAllocation = std::nullopt;
589                             if (_raw != "") {
590                                 int _value = std::stoi(_raw);
591                                 audioChannelAllocation = _value;
592                             }
593                             StrategyConfiguration instance(name, audioLocation, connectedDevice, channelCount, audioChannelAllocation);
594                             return instance;
595                         }
596                     } // setting
597                 } // audio
598             } // bluetooth
599         } // hardware
600     } // android
601 } // aidl
602