Skip to content

Commit

Permalink
audiopolicy: Avoid logspam about engine config parsing error
Browse files Browse the repository at this point in the history
Skip calling into libxml2 parsing when the engine config
file does not exist (this is allowed). This removes a misleading
error message from libxml2 in the syslog.

Bug: 181269159
Test: adb shell logcat | grep libxml2
      during phone boot
Change-Id: I9159a458ce68146271c3b22ea452194c4cabc79f
  • Loading branch information
Mikhail Naganov authored and NurKeinNeid committed Jun 27, 2021
1 parent b90ff00 commit 400de4b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion services/audiopolicy/engine/common/src/EngineBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#define LOG_TAG "APM::AudioPolicyEngine/Base"
//#define LOG_NDEBUG 0

#include <sys/stat.h>

#include "EngineBase.h"
#include "EngineDefaultConfig.h"
#include <TypeConverter.h>
Expand Down Expand Up @@ -147,8 +149,13 @@ engineConfig::ParsingResult EngineBase::loadAudioPolicyEngineConfig()
});
return iter != end(volumeGroups);
};
auto fileExists = [](const char* path) {
struct stat fileStat;
return stat(path, &fileStat) == 0 && S_ISREG(fileStat.st_mode);
};

auto result = engineConfig::parse();
auto result = fileExists(engineConfig::DEFAULT_PATH) ?
engineConfig::parse(engineConfig::DEFAULT_PATH) : engineConfig::ParsingResult{};
if (result.parsedConfig == nullptr) {
ALOGW("%s: No configuration found, using default matching phone experience.", __FUNCTION__);
engineConfig::Config config = gDefaultEngineConfig;
Expand Down

0 comments on commit 400de4b

Please sign in to comment.