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

Commit ce32ef78 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "APM: Fix config de-serialization"

parents d5aa6164 946c0035
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -33,6 +33,15 @@

namespace android {

// This class gathers together various bits of AudioPolicyManager
// configuration, which are usually filled out as a result of parsing
// the audio_policy_configuration.xml file.
//
// Note that AudioPolicyConfig doesn't own some of the data,
// it simply proxies access to the fields of AudioPolicyManager
// class. Be careful about the fields that are references,
// e.g. 'mOutputDevices'. This also means that it's impossible
// to implement "deep copying" of this class without re-designing it.
class AudioPolicyConfig
{
public:
@@ -40,14 +49,24 @@ public:
                      DeviceVector &outputDevices,
                      DeviceVector &inputDevices,
                      sp<DeviceDescriptor> &defaultOutputDevice)
        : mEngineLibraryNameSuffix(kDefaultEngineLibraryNameSuffix),
          mHwModules(hwModules),
        : mHwModules(hwModules),
          mOutputDevices(outputDevices),
          mInputDevices(inputDevices),
          mDefaultOutputDevice(defaultOutputDevice),
          mIsSpeakerDrcEnabled(false),
          mIsCallScreenModeSupported(false)
    {}
          mDefaultOutputDevice(defaultOutputDevice) {
        clear();
    }

    void clear() {
        mSource = {};
        mEngineLibraryNameSuffix = kDefaultEngineLibraryNameSuffix;
        mHwModules.clear();
        mOutputDevices.clear();
        mInputDevices.clear();
        mDefaultOutputDevice.clear();
        mIsSpeakerDrcEnabled = false;
        mIsCallScreenModeSupported = false;
        mSurroundFormats.clear();
    }

    const std::string& getSource() const {
        return mSource;
+4 −3
Original line number Diff line number Diff line
@@ -254,9 +254,8 @@ template <class T>
constexpr void (*xmlDeleter)(T* t);
template <>
constexpr auto xmlDeleter<xmlDoc> = xmlFreeDoc;
// http://b/111067277 - Add back constexpr when we switch to C++17.
template <>
auto xmlDeleter<xmlChar> = [](xmlChar *s) { xmlFree(s); };
constexpr auto xmlDeleter<xmlChar> = [](xmlChar *s) { xmlFree(s); };

/** @return a unique_ptr with the correct deleter for the libxml2 object. */
template <class T>
@@ -804,7 +803,9 @@ status_t PolicySerializer::deserialize(const char *configFile, AudioPolicyConfig
status_t deserializeAudioPolicyFile(const char *fileName, AudioPolicyConfig *config)
{
    PolicySerializer serializer;
    return serializer.deserialize(fileName, config);
    status_t status = serializer.deserialize(fileName, config);
    if (status != OK) config->clear();
    return status;
}

} // namespace android
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#include "EngineBase.h"
#include "EngineDefaultConfig.h"
#include "../include/EngineBase.h"
#include <TypeConverter.h>

namespace android {
+7 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
       "name": "audiopolicy_engineconfig_tests"
    }
  ]
}
+2 −0
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ struct ParsingResult {
 */
ParsingResult parse(const char* path = DEFAULT_PATH);
android::status_t parseLegacyVolumes(VolumeGroups &volumeGroups);
// Exposed for testing.
android::status_t parseLegacyVolumeFile(const char* path, VolumeGroups &volumeGroups);

} // namespace engineConfig
} // namespace android
Loading