Add --no-compile-sdk-metadata switch to AAPT2
This switch suppresses output of compile SDK-related attributes
in AndroidManifest.xml, including android:compileSdkVersion and
platformBuildVersion.
Fixes: 278115511
Test: ManifestFixer_test
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2ada8ffbe1a62f50fe5e966e8e9ec1f417cea179)
Merged-In: I552e50802a328c2318c9f261e30beadcbca5fd29
Change-Id: I552e50802a328c2318c9f261e30beadcbca5fd29
diff --git a/tools/aapt2/link/ManifestFixer.cpp b/tools/aapt2/link/ManifestFixer.cpp
index 53f0abe..c4f6e70 100644
--- a/tools/aapt2/link/ManifestFixer.cpp
+++ b/tools/aapt2/link/ManifestFixer.cpp
@@ -719,7 +719,7 @@
root->InsertChild(0, std::move(uses_sdk));
}
- if (options_.compile_sdk_version) {
+ if (!options_.no_compile_sdk_metadata && options_.compile_sdk_version) {
xml::Attribute* attr = root->FindOrCreateAttribute(xml::kSchemaAndroid, "compileSdkVersion");
// Make sure we un-compile the value if it was set to something else.
@@ -731,10 +731,9 @@
// Make sure we un-compile the value if it was set to something else.
attr->compiled_value = {};
attr->value = options_.compile_sdk_version.value();
-
}
- if (options_.compile_sdk_version_codename) {
+ if (!options_.no_compile_sdk_metadata && options_.compile_sdk_version_codename) {
xml::Attribute* attr =
root->FindOrCreateAttribute(xml::kSchemaAndroid, "compileSdkVersionCodename");