AAPT2: Fix long version code bugs
Refactoring areas in AAPT2 that use android:versionCode to also use
abdroid:versionCodeMajor. Does not add versionCodeMajor command line flag yet.
Bug: 109883459
Test: aapt2_tests
Change-Id: I573fbea37491cf8c5742f9e385c66ee64c4e5166
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index 26770d1..1d508d9 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -908,6 +908,18 @@
app_info.version_code = maybe_code.value();
}
+ if (xml::Attribute* version_code_major_attr =
+ manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCodeMajor")) {
+ Maybe<uint32_t> maybe_code = ResourceUtils::ParseInt(version_code_major_attr->value);
+ if (!maybe_code) {
+ diag->Error(DiagMessage(xml_res->file.source.WithLine(manifest_el->line_number))
+ << "invalid android:versionCodeMajor '"
+ << version_code_major_attr->value << "'");
+ return {};
+ }
+ app_info.version_code_major = maybe_code.value();
+ }
+
if (xml::Attribute* revision_code_attr =
manifest_el->FindAttribute(xml::kSchemaAndroid, "revisionCode")) {
Maybe<uint32_t> maybe_code = ResourceUtils::ParseInt(revision_code_attr->value);