diff options
Diffstat (limited to 'audio/common')
3 files changed, 11 insertions, 62 deletions
diff --git a/audio/common/all-versions/default/service/android.hardware.audio@2.0-service.rc b/audio/common/all-versions/default/service/android.hardware.audio@2.0-service.rc index 8217b946d..6e91bccb3 100644 --- a/audio/common/all-versions/default/service/android.hardware.audio@2.0-service.rc +++ b/audio/common/all-versions/default/service/android.hardware.audio@2.0-service.rc @@ -2,7 +2,8 @@ service vendor.audio-hal-2-0 /vendor/bin/hw/android.hardware.audio@2.0-service class hal user audioserver # media gid needed for /dev/fm (radio) and for /data/misc/media (tee) - group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct + group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock + capabilities BLOCK_SUSPEND ioprio rt 4 writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks # audioflinger restarts itself when it loses connection with the hal diff --git a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h index 4abd3fa8e..91adfc12c 100644 --- a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h +++ b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h @@ -34,10 +34,6 @@ namespace utility { ::testing::AssertionResult validateXml(const char* xmlFilePathExpr, const char* xsdFilePathExpr, const char* xmlFilePath, const char* xsdFilePath); -std::vector<std::string> findValidXmlFiles(const char* xsdFilePathExpr, - const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath, - std::vector<std::string>* errors = nullptr); - /** Helper gtest ASSERT to test XML validity against an XSD. */ #define ASSERT_VALID_XML(xmlFilePath, xsdFilePath) \ ASSERT_PRED_FORMAT2(::android::hardware::audio::common::test::utility::validateXml, \ @@ -82,9 +78,6 @@ template <bool atLeastOneRequired = true> ::android::hardware::audio::common::test::utility::validateXmlMultipleLocations<true>, \ xmlFileName, xmlFileLocations, xsdFilePath) -::testing::AssertionResult isNonEmptyXpath( - const char* xmlFilePath, const char* xpathQuery, bool* result); - } // namespace utility } // namespace test } // namespace common diff --git a/audio/common/all-versions/test/utility/src/ValidateXml.cpp b/audio/common/all-versions/test/utility/src/ValidateXml.cpp index 126873d6f..1a906d668 100644 --- a/audio/common/all-versions/test/utility/src/ValidateXml.cpp +++ b/audio/common/all-versions/test/utility/src/ValidateXml.cpp @@ -23,8 +23,6 @@ #include <libxml/xmlschemastypes.h> #define LIBXML_XINCLUDE_ENABLED #include <libxml/xinclude.h> -#define LIBXML_XPATH_ENABLED -#include <libxml/xpath.h> #include <memory> #include <string> @@ -49,10 +47,6 @@ template <> constexpr auto xmlDeleter<xmlSchemaParserCtxt> = xmlSchemaFreeParserCtxt; template <> constexpr auto xmlDeleter<xmlSchemaValidCtxt> = xmlSchemaFreeValidCtxt; -template <> -constexpr auto xmlDeleter<xmlXPathContext> = xmlXPathFreeContext; -template <> -constexpr auto xmlDeleter<xmlXPathObject> = xmlXPathFreeObject; /** @return a unique_ptr with the correct deleter for the libxml2 object. */ template <class T> @@ -135,37 +129,27 @@ struct Libxml2Global { return ::testing::AssertionSuccess(); } -std::vector<std::string> findValidXmlFiles( - const char* xsdFilePathExpr, - const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath, - std::vector<std::string>* errors) { +template <bool atLeastOneRequired> +::testing::AssertionResult validateXmlMultipleLocations( + const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr, + const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath) { using namespace std::string_literals; + + std::vector<std::string> errors; std::vector<std::string> foundFiles; + for (const char* location : xmlFileLocations) { std::string xmlFilePath = location + "/"s + xmlFileName; if (access(xmlFilePath.c_str(), F_OK) != 0) { // If the file does not exist ignore this location and fallback on the next one continue; } + foundFiles.push_back(" " + xmlFilePath + '\n'); auto result = validateXml("xmlFilePath", xsdFilePathExpr, xmlFilePath.c_str(), xsdFilePath); if (!result) { - if (errors != nullptr) errors->push_back(result.message()); - } else { - foundFiles.push_back(xmlFilePath); + errors.push_back(result.message()); } } - return foundFiles; -} - -template <bool atLeastOneRequired> -::testing::AssertionResult validateXmlMultipleLocations( - const char* xmlFileNameExpr, const char* xmlFileLocationsExpr, const char* xsdFilePathExpr, - const char* xmlFileName, std::vector<const char*> xmlFileLocations, const char* xsdFilePath) { - using namespace std::string_literals; - - std::vector<std::string> errors; - std::vector<std::string> foundFiles = findValidXmlFiles( - xsdFilePathExpr, xmlFileName, xmlFileLocations, xsdFilePath, &errors); if (atLeastOneRequired && foundFiles.empty()) { errors.push_back("No xml file found in provided locations.\n"); @@ -191,35 +175,6 @@ template ::testing::AssertionResult validateXmlMultipleLocations<false>(const ch std::vector<const char*>, const char*); -::testing::AssertionResult isNonEmptyXpath( - const char* xmlFilePath, const char* xpathQuery, bool* result) { - Libxml2Global libxml2; - - auto context = [&]() { - return std::string() + " In: " + xmlFilePath + "\nLibxml2 errors:\n" + libxml2.getErrors(); - }; - - auto doc = make_xmlUnique(xmlReadFile(xmlFilePath, nullptr, 0)); - if (doc == nullptr) { - return ::testing::AssertionFailure() << "Failed to parse xml\n" << context(); - } - if (xmlXIncludeProcess(doc.get()) == -1) { - return ::testing::AssertionFailure() << "Failed to resolve xincludes in xml\n" << context(); - } - auto xpathCtxt = make_xmlUnique(xmlXPathNewContext(doc.get())); - if (xpathCtxt == nullptr) { - return ::testing::AssertionFailure() << "Failed to create xpath context\n" << context(); - } - auto xpathObj = make_xmlUnique(xmlXPathEvalExpression(BAD_CAST xpathQuery, xpathCtxt.get())); - if (xpathObj == nullptr) { - return ::testing::AssertionFailure() << - "Failed to evaluate xpath: \'" << xpathQuery << "\'\n" << context(); - } - auto nodeSet = xpathObj.get()->nodesetval; - *result = nodeSet ? nodeSet->nodeNr != 0 : false; - return ::testing::AssertionSuccess(); -} - } // namespace utility } // namespace test } // namespace common |