AAPT2: Ignore namespaced elements in AndroidManifest.xml
Some third party stores/tools expect manifest elements
under their namespace, and AAPT2 shouldn't fail if these
are present.
Bug: 37943705
Test: make aapt2_tests
Change-Id: I87b7500c7da5e8e79fc2a78b30e8e4334124af3d
diff --git a/tools/aapt2/xml/XmlActionExecutor.h b/tools/aapt2/xml/XmlActionExecutor.h
index 68e3563..1d70045 100644
--- a/tools/aapt2/xml/XmlActionExecutor.h
+++ b/tools/aapt2/xml/XmlActionExecutor.h
@@ -31,17 +31,12 @@
namespace xml {
enum class XmlActionExecutorPolicy {
- /**
- * Actions on run if elements are matched, errors occur only when actions
- * return false.
- */
+ // Actions are run if elements are matched, errors occur only when actions return false.
kNone,
- /**
- * The actions defined must match and run. If an element is found that does
- * not match
- * an action, an error occurs.
- */
+ // The actions defined must match and run. If an element is found that does
+ // not match an action, an error occurs.
+ // Note: namespaced elements are always ignored.
kWhitelist,
};
@@ -52,14 +47,12 @@
*/
class XmlNodeAction {
public:
- using ActionFuncWithDiag =
- std::function<bool(Element*, SourcePathDiagnostics*)>;
+ using ActionFuncWithDiag = std::function<bool(Element*, SourcePathDiagnostics*)>;
using ActionFunc = std::function<bool(Element*)>;
/**
* Find or create a child XmlNodeAction that will be performed for the child
- * element
- * with the name `name`.
+ * element with the name `name`.
*/
XmlNodeAction& operator[](const std::string& name) { return map_[name]; }
@@ -72,8 +65,7 @@
private:
friend class XmlActionExecutor;
- bool Execute(XmlActionExecutorPolicy policy, SourcePathDiagnostics* diag,
- Element* el) const;
+ bool Execute(XmlActionExecutorPolicy policy, SourcePathDiagnostics* diag, Element* el) const;
std::map<std::string, XmlNodeAction> map_;
std::vector<ActionFuncWithDiag> actions_;
@@ -98,8 +90,7 @@
* Execute the defined actions for this XmlResource.
* Returns true if all actions return true, otherwise returns false.
*/
- bool Execute(XmlActionExecutorPolicy policy, IDiagnostics* diag,
- XmlResource* doc) const;
+ bool Execute(XmlActionExecutorPolicy policy, IDiagnostics* diag, XmlResource* doc) const;
private:
std::map<std::string, XmlNodeAction> map_;