AAPT2: Allow <key-sets> tags in AndroidManifest.xml
Bug: 62839863
Test: make aapt2_tests
Change-Id: Ic38fadf3b204bf603f6770643735635cd1f1df7e
diff --git a/tools/aapt2/link/ManifestFixer.cpp b/tools/aapt2/link/ManifestFixer.cpp
index 99fd95b..a0ffefa 100644
--- a/tools/aapt2/link/ManifestFixer.cpp
+++ b/tools/aapt2/link/ManifestFixer.cpp
@@ -309,6 +309,9 @@
manifest_action["meta-data"] = meta_data_action;
manifest_action["uses-split"].Action(RequiredNameIsJavaPackage);
+ manifest_action["key-sets"]["key-set"]["public-key"];
+ manifest_action["key-sets"]["upgrade-key-set"];
+
// Application actions.
xml::XmlNodeAction& application_action = manifest_action["application"];
application_action.Action(OptionalNameIsJavaClassName);
diff --git a/tools/aapt2/link/ManifestFixer_test.cpp b/tools/aapt2/link/ManifestFixer_test.cpp
index 064d365..80edb35 100644
--- a/tools/aapt2/link/ManifestFixer_test.cpp
+++ b/tools/aapt2/link/ManifestFixer_test.cpp
@@ -18,7 +18,8 @@
#include "test/Test.h"
-using android::StringPiece;
+using ::android::StringPiece;
+using ::testing::NotNull;
namespace aapt {
@@ -420,4 +421,22 @@
EXPECT_EQ(nullptr, Verify(input));
}
+TEST_F(ManifestFixerTest, SupportKeySets) {
+ std::string input = R"(
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android">
+ <key-sets>
+ <key-set android:name="old-set">
+ <public-key android:name="old-key" android:value="some+old+key" />
+ </key-set>
+ <key-set android:name="new-set">
+ <public-key android:name="new-key" android:value="some+new+key" />
+ </key-set>
+ <upgrade-key-set android:name="old-set" />
+ <upgrade-key-set android:name="new-set" />
+ </key-sets>
+ </manifest>)";
+ EXPECT_THAT(Verify(input), NotNull());
+}
+
} // namespace aapt
diff --git a/tools/aapt2/readme.md b/tools/aapt2/readme.md
index 9b2e0a4..139d8d9 100644
--- a/tools/aapt2/readme.md
+++ b/tools/aapt2/readme.md
@@ -5,6 +5,8 @@
- Fixed issue where enum values were interpreted as integers and range checked. (bug 62358540)
- Fixed issue where ints and floats with trailing whitespace would not be parsed. (bug 62902869)
- Fixed issue where `--custom-package` was not honored when writing Manifest.java. (bug 62826426)
+- Add `<key-sets>` and its nested tags to the allowed set of XML tags in AndroidManifest.xml.
+ (bug 62839863)
## Version 2.17
### `aapt2 ...`