AAPT2: treat manifest validation errors as warnings when asked
Bug: 65670329
Test: updated
Change-Id: Ic554cc20134fce66aa9ddf8d16ddffe0131c50e9
diff --git a/tools/aapt2/xml/XmlActionExecutor.cpp b/tools/aapt2/xml/XmlActionExecutor.cpp
index 602a902..cb844f0 100644
--- a/tools/aapt2/xml/XmlActionExecutor.cpp
+++ b/tools/aapt2/xml/XmlActionExecutor.cpp
@@ -66,7 +66,7 @@
continue;
}
- if (policy == XmlActionExecutorPolicy::kWhitelist) {
+ if (policy != XmlActionExecutorPolicy::kNone) {
DiagMessage error_msg(child_el->line_number);
error_msg << "unexpected element ";
PrintElementToDiagMessage(child_el, &error_msg);
@@ -74,8 +74,14 @@
for (const StringPiece& element : *bread_crumb) {
error_msg << "<" << element << ">";
}
- diag->Error(error_msg);
- error = true;
+ if (policy == XmlActionExecutorPolicy::kWhitelistWarning) {
+ // Treat the error only as a warning.
+ diag->Warn(error_msg);
+ } else {
+ // Policy is XmlActionExecutorPolicy::kWhitelist, we should fail.
+ diag->Error(error_msg);
+ error = true;
+ }
}
}
}