Add support for --replace-version to aapt2
Implement --replace-version to match aapt1.
Bug: 79755007
Test: aapt2_tests
Change-Id: Iee2bd9a3981c7d4681509f18b735c6e9e6c1a336
Merged-In: Iee2bd9a3981c7d4681509f18b735c6e9e6c1a336
(cherry picked from commit dcd58c420771af75c625242985bd96ba828aca56)
diff --git a/tools/aapt2/link/ManifestFixer.h b/tools/aapt2/link/ManifestFixer.h
index 7d6fad2..98d06fd 100644
--- a/tools/aapt2/link/ManifestFixer.h
+++ b/tools/aapt2/link/ManifestFixer.h
@@ -44,10 +44,12 @@
// <instrumentation>.
Maybe<std::string> rename_instrumentation_target_package;
- // The version name to set if 'android:versionName' is not defined in <manifest>.
+ // The version name to set if 'android:versionName' is not defined in <manifest> or if
+ // replace_version is set.
Maybe<std::string> version_name_default;
- // The version code to set if 'android:versionCode' is not defined in <manifest>.
+ // The version code to set if 'android:versionCode' is not defined in <manifest> or if
+ // replace_version is set.
Maybe<std::string> version_code_default;
// The version of the framework being compiled against to set for 'android:compileSdkVersion' in
@@ -65,6 +67,9 @@
// Whether to inject the android:debuggable="true" flag into the manifest
bool debug_mode = false;
+
+ // Whether to replace the manifest version with the the command line version
+ bool replace_version = false;
};
// Verifies that the manifest is correctly formed and inserts defaults where specified with