AAPT2: Fix overzealous AndroidManifest fully qualified class names
ManifestFixer would go and fully qualify all elements with the attribute
'android:name', which is not correct, especially for cases like
<uses-split android:name="foo" />
Test: make aapt2_tests
Change-Id: I4bea2550d0025179d2d48dca8c64e0cbf4451e99
diff --git a/tools/aapt2/link/ManifestFixer_test.cpp b/tools/aapt2/link/ManifestFixer_test.cpp
index da7f410..40085ea 100644
--- a/tools/aapt2/link/ManifestFixer_test.cpp
+++ b/tools/aapt2/link/ManifestFixer_test.cpp
@@ -240,6 +240,7 @@
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android">
+ <uses-split android:name="feature_a" />
<application android:name=".MainApplication" text="hello">
<activity android:name=".activity.Start" />
<receiver android:name="com.google.android.Receiver" />
@@ -248,35 +249,41 @@
options);
ASSERT_NE(nullptr, doc);
- xml::Element* manifestEl = doc->root.get();
- ASSERT_NE(nullptr, manifestEl);
+ xml::Element* manifest_el = doc->root.get();
+ ASSERT_NE(nullptr, manifest_el);
xml::Attribute* attr = nullptr;
- attr = manifestEl->FindAttribute({}, "package");
+ attr = manifest_el->FindAttribute({}, "package");
ASSERT_NE(nullptr, attr);
EXPECT_EQ(std::string("com.android"), attr->value);
- xml::Element* applicationEl = manifestEl->FindChild({}, "application");
- ASSERT_NE(nullptr, applicationEl);
+ xml::Element* uses_split_el = manifest_el->FindChild({}, "uses-split");
+ ASSERT_NE(nullptr, uses_split_el);
+ attr = uses_split_el->FindAttribute(xml::kSchemaAndroid, "name");
+ ASSERT_NE(nullptr, attr);
+ EXPECT_EQ(std::string("feature_a"), attr->value);
- attr = applicationEl->FindAttribute(xml::kSchemaAndroid, "name");
+ xml::Element* application_el = manifest_el->FindChild({}, "application");
+ ASSERT_NE(nullptr, application_el);
+
+ attr = application_el->FindAttribute(xml::kSchemaAndroid, "name");
ASSERT_NE(nullptr, attr);
EXPECT_EQ(std::string("android.MainApplication"), attr->value);
- attr = applicationEl->FindAttribute({}, "text");
+ attr = application_el->FindAttribute({}, "text");
ASSERT_NE(nullptr, attr);
EXPECT_EQ(std::string("hello"), attr->value);
xml::Element* el;
- el = applicationEl->FindChild({}, "activity");
+ el = application_el->FindChild({}, "activity");
ASSERT_NE(nullptr, el);
attr = el->FindAttribute(xml::kSchemaAndroid, "name");
ASSERT_NE(nullptr, el);
EXPECT_EQ(std::string("android.activity.Start"), attr->value);
- el = applicationEl->FindChild({}, "receiver");
+ el = application_el->FindChild({}, "receiver");
ASSERT_NE(nullptr, el);
attr = el->FindAttribute(xml::kSchemaAndroid, "name");