Add enforcement of overlayable targetName
Adds android:targetName to the overlay manifest attributes and
PackageParser reads the name into PackageInfo. Specifying
android:targetName on an overlay allows the overlay to be associated
with a particular set of overlayable resources. The overlay can only
override the values of the resources defined within the target
overlayable element.
Test: idmap2_tests
Bug: 119390855
Bug: 110869880
Change-Id: I1128274af4cae983f61ae15cdfcbface63233ff2
diff --git a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
index 35ec1ff..0e0e25f 100644
--- a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
+++ b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
@@ -111,43 +111,46 @@
success = LoadedIdmap::Lookup(header, 0x0002, &entry); // string/c
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0003, &entry); // string/not_overlayable
+ success = LoadedIdmap::Lookup(header, 0x0003, &entry); // string/other
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0004, &entry); // string/policy_product
+ success = LoadedIdmap::Lookup(header, 0x0004, &entry); // string/not_overlayable
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0005, &entry); // string/policy_public
+ success = LoadedIdmap::Lookup(header, 0x0005, &entry); // string/policy_product
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0006, &entry); // string/policy_system
+ success = LoadedIdmap::Lookup(header, 0x0006, &entry); // string/policy_public
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0007, &entry); // string/policy_system_vendor
+ success = LoadedIdmap::Lookup(header, 0x0007, &entry); // string/policy_system
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0008, &entry); // string/str1
+ success = LoadedIdmap::Lookup(header, 0x0008, &entry); // string/policy_system_vendor
+ ASSERT_FALSE(success);
+
+ success = LoadedIdmap::Lookup(header, 0x0009, &entry); // string/str1
ASSERT_TRUE(success);
ASSERT_EQ(entry, 0x0000);
- success = LoadedIdmap::Lookup(header, 0x0009, &entry); // string/str2
+ success = LoadedIdmap::Lookup(header, 0x000a, &entry); // string/str2
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x000a, &entry); // string/str3
+ success = LoadedIdmap::Lookup(header, 0x000b, &entry); // string/str3
ASSERT_TRUE(success);
ASSERT_EQ(entry, 0x0001);
- success = LoadedIdmap::Lookup(header, 0x000b, &entry); // string/str4
+ success = LoadedIdmap::Lookup(header, 0x000c, &entry); // string/str4
ASSERT_TRUE(success);
ASSERT_EQ(entry, 0x0002);
- success = LoadedIdmap::Lookup(header, 0x000c, &entry); // string/x
+ success = LoadedIdmap::Lookup(header, 0x000d, &entry); // string/x
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x000d, &entry); // string/y
+ success = LoadedIdmap::Lookup(header, 0x000e, &entry); // string/y
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x000e, &entry); // string/z
+ success = LoadedIdmap::Lookup(header, 0x000f, &entry); // string/z
ASSERT_FALSE(success);
}