Add odm and oem policies
This change adds parsing, encoding, and validating of odm and oem
overlayable policies to aapt2, libandroidfw, and idmap2.
Bug: 121033532
Test: aapt2_tests, idmap2_tests
Change-Id: Ifc0d4b6c9f9c37e06b2988abade69dbb277c50c2
diff --git a/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl b/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl
index 4a66715..cd474c0 100644
--- a/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl
+++ b/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl
@@ -25,6 +25,8 @@
const int POLICY_VENDOR_PARTITION = 0x00000004;
const int POLICY_PRODUCT_PARTITION = 0x00000008;
const int POLICY_SIGNATURE = 0x00000010;
+ const int POLICY_ODM_PARTITION = 0x00000020;
+ const int POLICY_OEM_PARTITION = 0x00000040;
@utf8InCpp String getIdmapPath(@utf8InCpp String overlayApkPath, int userId);
boolean removeIdmap(@utf8InCpp String overlayApkPath, int userId);
diff --git a/cmds/idmap2/include/idmap2/Policies.h b/cmds/idmap2/include/idmap2/Policies.h
index 90c698c..87edd35 100644
--- a/cmds/idmap2/include/idmap2/Policies.h
+++ b/cmds/idmap2/include/idmap2/Policies.h
@@ -26,11 +26,13 @@
namespace android::idmap2 {
-constexpr const char* kPolicyPublic = "public";
+constexpr const char* kPolicyOdm = "odm";
+constexpr const char* kPolicyOem = "oem";
constexpr const char* kPolicyProduct = "product";
+constexpr const char* kPolicyPublic = "public";
+constexpr const char* kPolicySignature = "signature";
constexpr const char* kPolicySystem = "system";
constexpr const char* kPolicyVendor = "vendor";
-constexpr const char* kPolicySignature = "signature";
using PolicyFlags = ResTable_overlayable_policy_header::PolicyFlags;
using PolicyBitmask = uint32_t;
diff --git a/cmds/idmap2/libidmap2/Idmap.cpp b/cmds/idmap2/libidmap2/Idmap.cpp
index aec1a6f..4649675 100644
--- a/cmds/idmap2/libidmap2/Idmap.cpp
+++ b/cmds/idmap2/libidmap2/Idmap.cpp
@@ -282,6 +282,7 @@
const utils::OverlayManifestInfo& overlay_info,
const PolicyBitmask& fulfilled_policies, const ResourceId& resid) {
static constexpr const PolicyBitmask sDefaultPolicies =
+ PolicyFlags::POLICY_ODM_PARTITION | PolicyFlags::POLICY_OEM_PARTITION |
PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_VENDOR_PARTITION |
PolicyFlags::POLICY_PRODUCT_PARTITION | PolicyFlags::POLICY_SIGNATURE;
diff --git a/cmds/idmap2/libidmap2/Policies.cpp b/cmds/idmap2/libidmap2/Policies.cpp
index 0a0cecf..495fe61 100644
--- a/cmds/idmap2/libidmap2/Policies.cpp
+++ b/cmds/idmap2/libidmap2/Policies.cpp
@@ -17,8 +17,8 @@
#include "idmap2/Policies.h"
#include <iterator>
-#include <map>
#include <string>
+#include <unordered_map>
#include <vector>
#include "androidfw/ResourceTypes.h"
@@ -27,19 +27,17 @@
namespace android::idmap2 {
-namespace {
-
-const std::map<android::StringPiece, PolicyFlags> kStringToFlag = {
- {kPolicyPublic, PolicyFlags::POLICY_PUBLIC},
- {kPolicyProduct, PolicyFlags::POLICY_PRODUCT_PARTITION},
- {kPolicySystem, PolicyFlags::POLICY_SYSTEM_PARTITION},
- {kPolicyVendor, PolicyFlags::POLICY_VENDOR_PARTITION},
- {kPolicySignature, PolicyFlags::POLICY_SIGNATURE},
-};
-
-} // namespace
-
Result<PolicyBitmask> PoliciesToBitmask(const std::vector<std::string>& policies) {
+ static const std::unordered_map<android::StringPiece, PolicyFlags> kStringToFlag = {
+ {kPolicyOdm, PolicyFlags::POLICY_ODM_PARTITION},
+ {kPolicyOem, PolicyFlags::POLICY_OEM_PARTITION},
+ {kPolicyPublic, PolicyFlags::POLICY_PUBLIC},
+ {kPolicyProduct, PolicyFlags::POLICY_PRODUCT_PARTITION},
+ {kPolicySignature, PolicyFlags::POLICY_SIGNATURE},
+ {kPolicySystem, PolicyFlags::POLICY_SYSTEM_PARTITION},
+ {kPolicyVendor, PolicyFlags::POLICY_VENDOR_PARTITION},
+ };
+
PolicyBitmask bitmask = 0;
for (const std::string& policy : policies) {
const auto iter = kStringToFlag.find(policy);
@@ -55,6 +53,15 @@
std::vector<std::string> BitmaskToPolicies(const PolicyBitmask& bitmask) {
std::vector<std::string> policies;
+
+ if ((bitmask & PolicyFlags::POLICY_ODM_PARTITION) != 0) {
+ policies.emplace_back(kPolicyOdm);
+ }
+
+ if ((bitmask & PolicyFlags::POLICY_OEM_PARTITION) != 0) {
+ policies.emplace_back(kPolicyOem);
+ }
+
if ((bitmask & PolicyFlags::POLICY_PUBLIC) != 0) {
policies.emplace_back(kPolicyPublic);
}
@@ -63,6 +70,10 @@
policies.emplace_back(kPolicyProduct);
}
+ if ((bitmask & PolicyFlags::POLICY_SIGNATURE) != 0) {
+ policies.emplace_back(kPolicySignature);
+ }
+
if ((bitmask & PolicyFlags::POLICY_SYSTEM_PARTITION) != 0) {
policies.emplace_back(kPolicySystem);
}
@@ -71,10 +82,6 @@
policies.emplace_back(kPolicyVendor);
}
- if ((bitmask & PolicyFlags::POLICY_SIGNATURE) != 0) {
- policies.emplace_back(kPolicySignature);
- }
-
return policies;
}
diff --git a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
index 9cdc86c..9348ab7 100644
--- a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
+++ b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
@@ -109,49 +109,55 @@
success = LoadedIdmap::Lookup(header, 0x0002, &entry); // string/c
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0003, &entry); // string/other
+ success = LoadedIdmap::Lookup(header, 0x0003, &entry); // string/policy_odm
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0004, &entry); // string/not_overlayable
+ success = LoadedIdmap::Lookup(header, 0x0004, &entry); // string/policy_oem
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0005, &entry); // string/policy_product
+ success = LoadedIdmap::Lookup(header, 0x0005, &entry); // string/other
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0006, &entry); // string/policy_public
+ success = LoadedIdmap::Lookup(header, 0x0006, &entry); // string/not_overlayable
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0007, &entry); // string/policy_system
+ success = LoadedIdmap::Lookup(header, 0x0007, &entry); // string/policy_product
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0008, &entry); // string/policy_system_vendor
+ success = LoadedIdmap::Lookup(header, 0x0008, &entry); // string/policy_public
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0009, &entry); // string/policy_signature
+ success = LoadedIdmap::Lookup(header, 0x0009, &entry); // string/policy_system
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x000a, &entry); // string/str1
+ success = LoadedIdmap::Lookup(header, 0x000a, &entry); // string/policy_system_vendor
+ ASSERT_FALSE(success);
+
+ success = LoadedIdmap::Lookup(header, 0x000b, &entry); // string/policy_signature
+ ASSERT_FALSE(success);
+
+ success = LoadedIdmap::Lookup(header, 0x000c, &entry); // string/str1
ASSERT_TRUE(success);
ASSERT_EQ(entry, 0x0000);
- success = LoadedIdmap::Lookup(header, 0x000b, &entry); // string/str2
+ success = LoadedIdmap::Lookup(header, 0x000d, &entry); // string/str2
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x000c, &entry); // string/str3
+ success = LoadedIdmap::Lookup(header, 0x000e, &entry); // string/str3
ASSERT_TRUE(success);
ASSERT_EQ(entry, 0x0001);
- success = LoadedIdmap::Lookup(header, 0x000d, &entry); // string/str4
+ success = LoadedIdmap::Lookup(header, 0x000f, &entry); // string/str4
ASSERT_TRUE(success);
ASSERT_EQ(entry, 0x0002);
- success = LoadedIdmap::Lookup(header, 0x000e, &entry); // string/x
+ success = LoadedIdmap::Lookup(header, 0x0010, &entry); // string/x
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x000f, &entry); // string/y
+ success = LoadedIdmap::Lookup(header, 0x0011, &entry); // string/y
ASSERT_FALSE(success);
- success = LoadedIdmap::Lookup(header, 0x0010, &entry); // string/z
+ success = LoadedIdmap::Lookup(header, 0x0012, &entry); // string/z
ASSERT_FALSE(success);
}
diff --git a/cmds/idmap2/tests/Idmap2BinaryTests.cpp b/cmds/idmap2/tests/Idmap2BinaryTests.cpp
index c18744c..8a48f4b 100644
--- a/cmds/idmap2/tests/Idmap2BinaryTests.cpp
+++ b/cmds/idmap2/tests/Idmap2BinaryTests.cpp
@@ -128,9 +128,9 @@
ASSERT_THAT(result, NotNull());
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
ASSERT_NE(result->stdout.find("0x7f010000 -> 0x7f010000 integer/int1"), std::string::npos);
- ASSERT_NE(result->stdout.find("0x7f02000a -> 0x7f020000 string/str1"), std::string::npos);
- ASSERT_NE(result->stdout.find("0x7f02000c -> 0x7f020001 string/str3"), std::string::npos);
- ASSERT_NE(result->stdout.find("0x7f02000d -> 0x7f020002 string/str4"), std::string::npos);
+ ASSERT_NE(result->stdout.find("0x7f02000c -> 0x7f020000 string/str1"), std::string::npos);
+ ASSERT_NE(result->stdout.find("0x7f02000e -> 0x7f020001 string/str3"), std::string::npos);
+ ASSERT_NE(result->stdout.find("0x7f02000f -> 0x7f020002 string/str4"), std::string::npos);
ASSERT_EQ(result->stdout.find("00000210: 007f target package id"), std::string::npos);
// clang-format off
@@ -299,7 +299,7 @@
"lookup",
"--idmap-path", GetIdmapPath(),
"--config", "",
- "--resid", "0x7f02000a"}); // string/str1
+ "--resid", "0x7f02000c"}); // string/str1
// clang-format on
ASSERT_THAT(result, NotNull());
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp
index 90fe9a7..0f47f1e 100644
--- a/cmds/idmap2/tests/IdmapTests.cpp
+++ b/cmds/idmap2/tests/IdmapTests.cpp
@@ -194,7 +194,7 @@
ASSERT_THAT(idmap->GetHeader(), NotNull());
ASSERT_EQ(idmap->GetHeader()->GetMagic(), 0x504d4449U);
ASSERT_EQ(idmap->GetHeader()->GetVersion(), 0x01U);
- ASSERT_EQ(idmap->GetHeader()->GetTargetCrc(), 0xd513ca1b);
+ ASSERT_EQ(idmap->GetHeader()->GetTargetCrc(), 0x76a20829);
ASSERT_EQ(idmap->GetHeader()->GetOverlayCrc(), 0x8635c2ed);
ASSERT_EQ(idmap->GetHeader()->GetTargetPath().to_string(), target_apk_path);
ASSERT_EQ(idmap->GetHeader()->GetOverlayPath(), overlay_apk_path);
@@ -220,7 +220,7 @@
ASSERT_EQ(types[1]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[1]->GetOverlayTypeId(), 0x02U);
ASSERT_EQ(types[1]->GetEntryCount(), 4U);
- ASSERT_EQ(types[1]->GetEntryOffset(), 10U);
+ ASSERT_EQ(types[1]->GetEntryOffset(), 12U);
ASSERT_EQ(types[1]->GetEntry(0), 0x0000U);
ASSERT_EQ(types[1]->GetEntry(1), kNoEntry);
ASSERT_EQ(types[1]->GetEntry(2), 0x0001U);
@@ -251,7 +251,7 @@
ASSERT_EQ(types[0]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
ASSERT_EQ(types[0]->GetEntryCount(), 4U);
- ASSERT_EQ(types[0]->GetEntryOffset(), 6U);
+ ASSERT_EQ(types[0]->GetEntryOffset(), 8U);
ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/policy_public
ASSERT_EQ(types[0]->GetEntry(1), kNoEntry); // string/policy_signature
ASSERT_EQ(types[0]->GetEntry(2), 0x0001U); // string/policy_system
@@ -281,7 +281,7 @@
ASSERT_EQ(types[0]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
ASSERT_EQ(types[0]->GetEntryCount(), 1U);
- ASSERT_EQ(types[0]->GetEntryOffset(), 7U);
+ ASSERT_EQ(types[0]->GetEntryOffset(), 9U);
ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/policy_signature
}
@@ -310,11 +310,11 @@
ASSERT_EQ(types[0]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
ASSERT_EQ(types[0]->GetEntryCount(), 4U);
- ASSERT_EQ(types[0]->GetEntryOffset(), 6U);
- ASSERT_EQ(types[0]->GetEntry(0), 0x0003U); // string/policy_public
+ ASSERT_EQ(types[0]->GetEntryOffset(), 8U);
+ ASSERT_EQ(types[0]->GetEntry(0), 0x0005U); // string/policy_public
ASSERT_EQ(types[0]->GetEntry(1), kNoEntry); // string/policy_signature
- ASSERT_EQ(types[0]->GetEntry(2), 0x0005U); // string/policy_system
- ASSERT_EQ(types[0]->GetEntry(3), 0x0006U); // string/policy_system_vendor
+ ASSERT_EQ(types[0]->GetEntry(2), 0x0007U); // string/policy_system
+ ASSERT_EQ(types[0]->GetEntry(3), 0x0008U); // string/policy_system_vendor
}
// Overlays should ignore all overlayable restrictions if enforcement of overlayable is disabled.
@@ -341,15 +341,17 @@
ASSERT_EQ(types[0]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
- ASSERT_EQ(types[0]->GetEntryCount(), 7U);
+ ASSERT_EQ(types[0]->GetEntryCount(), 9U);
ASSERT_EQ(types[0]->GetEntryOffset(), 3U);
ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/not_overlayable
- ASSERT_EQ(types[0]->GetEntry(1), 0x0001U); // string/other
- ASSERT_EQ(types[0]->GetEntry(2), 0x0002U); // string/policy_product
- ASSERT_EQ(types[0]->GetEntry(3), 0x0003U); // string/policy_signature
- ASSERT_EQ(types[0]->GetEntry(4), 0x0004U); // string/policy_public
- ASSERT_EQ(types[0]->GetEntry(5), 0x0005U); // string/policy_system
- ASSERT_EQ(types[0]->GetEntry(6), 0x0006U); // string/policy_system_vendor
+ ASSERT_EQ(types[0]->GetEntry(1), 0x0001U); // string/policy_odm
+ ASSERT_EQ(types[0]->GetEntry(2), 0x0002U); // string/policy_oem
+ ASSERT_EQ(types[0]->GetEntry(3), 0x0003U); // string/other
+ ASSERT_EQ(types[0]->GetEntry(4), 0x0004U); // string/policy_product
+ ASSERT_EQ(types[0]->GetEntry(5), 0x0005U); // string/policy_public
+ ASSERT_EQ(types[0]->GetEntry(6), 0x0006U); // string/policy_signature
+ ASSERT_EQ(types[0]->GetEntry(7), 0x0007U); // string/policy_system
+ ASSERT_EQ(types[0]->GetEntry(8), 0x0008U); // string/policy_system_vendor
}
// Overlays that do not specify a target <overlayable> can overlay resources defined as overlayable.
@@ -381,7 +383,7 @@
ASSERT_EQ(types[1]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[1]->GetOverlayTypeId(), 0x02U);
ASSERT_EQ(types[1]->GetEntryCount(), 4U);
- ASSERT_EQ(types[1]->GetEntryOffset(), 10U);
+ ASSERT_EQ(types[1]->GetEntryOffset(), 12U);
ASSERT_EQ(types[1]->GetEntry(0), 0x0000U); // string/str1
ASSERT_EQ(types[1]->GetEntry(1), kNoEntry); // string/str2
ASSERT_EQ(types[1]->GetEntry(2), 0x0001U); // string/str3
@@ -412,7 +414,6 @@
ASSERT_EQ(dataBlocks.size(), 1U);
const std::unique_ptr<const IdmapData>& data = dataBlocks[0];
-
ASSERT_EQ(data->GetHeader()->GetTargetPackageId(), 0x7fU);
ASSERT_EQ(data->GetHeader()->GetTypeCount(), 1U);
@@ -421,15 +422,17 @@
ASSERT_EQ(types[0]->GetTargetTypeId(), 0x02U);
ASSERT_EQ(types[0]->GetOverlayTypeId(), 0x01U);
- ASSERT_EQ(types[0]->GetEntryCount(), 7U);
+ ASSERT_EQ(types[0]->GetEntryCount(), 9U);
ASSERT_EQ(types[0]->GetEntryOffset(), 3U);
ASSERT_EQ(types[0]->GetEntry(0), 0x0000U); // string/not_overlayable
- ASSERT_EQ(types[0]->GetEntry(1), 0x0001U); // string/other
- ASSERT_EQ(types[0]->GetEntry(2), 0x0002U); // string/policy_product
- ASSERT_EQ(types[0]->GetEntry(3), 0x0003U); // string/policy_public
- ASSERT_EQ(types[0]->GetEntry(4), 0x0004U); // string/string/policy_signature
- ASSERT_EQ(types[0]->GetEntry(5), 0x0005U); // string/policy_system
- ASSERT_EQ(types[0]->GetEntry(6), 0x0006U); // string/policy_system_vendor
+ ASSERT_EQ(types[0]->GetEntry(1), 0x0001U); // string/policy_odm
+ ASSERT_EQ(types[0]->GetEntry(2), 0x0002U); // string/policy_oem
+ ASSERT_EQ(types[0]->GetEntry(3), 0x0003U); // string/other
+ ASSERT_EQ(types[0]->GetEntry(4), 0x0004U); // string/policy_product
+ ASSERT_EQ(types[0]->GetEntry(5), 0x0005U); // string/policy_public
+ ASSERT_EQ(types[0]->GetEntry(6), 0x0006U); // string/policy_signature
+ ASSERT_EQ(types[0]->GetEntry(7), 0x0007U); // string/policy_system
+ ASSERT_EQ(types[0]->GetEntry(8), 0x0008U); // string/policy_system_vendor
};
CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_SIGNATURE,
@@ -451,6 +454,16 @@
/* enforce_overlayable */ true, &idmap);
ASSERT_THAT(idmap, NotNull());
CheckEntries();
+
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_ODM_PARTITION,
+ /* enforce_overlayable */ true, &idmap);
+ ASSERT_THAT(idmap, NotNull());
+ CheckEntries();
+
+ CreateIdmap(target_apk_path, overlay_apk_path, PolicyFlags::POLICY_OEM_PARTITION,
+ /* enforce_overlayable */ true, &idmap);
+ ASSERT_THAT(idmap, NotNull());
+ CheckEntries();
}
TEST(IdmapTests, FailToCreateIdmapFromApkAssetsIfPathTooLong) {
diff --git a/cmds/idmap2/tests/PoliciesTests.cpp b/cmds/idmap2/tests/PoliciesTests.cpp
index e30da76..eca7404 100644
--- a/cmds/idmap2/tests/PoliciesTests.cpp
+++ b/cmds/idmap2/tests/PoliciesTests.cpp
@@ -38,9 +38,10 @@
ASSERT_TRUE(bitmask3);
ASSERT_EQ(*bitmask3, PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_VENDOR_PARTITION);
- const auto bitmask4 = PoliciesToBitmask({"public", "product", "system", "vendor"});
+ const auto bitmask4 = PoliciesToBitmask({"odm", "oem", "public", "product", "system", "vendor"});
ASSERT_TRUE(bitmask4);
- ASSERT_EQ(*bitmask4, PolicyFlags::POLICY_PUBLIC | PolicyFlags::POLICY_PRODUCT_PARTITION |
+ ASSERT_EQ(*bitmask4, PolicyFlags::POLICY_ODM_PARTITION | PolicyFlags::POLICY_OEM_PARTITION |
+ PolicyFlags::POLICY_PUBLIC | PolicyFlags::POLICY_PRODUCT_PARTITION |
PolicyFlags::POLICY_SYSTEM_PARTITION |
PolicyFlags::POLICY_VENDOR_PARTITION);
@@ -64,4 +65,28 @@
ASSERT_FALSE(bitmask10);
}
+TEST(PoliciesTests, BitmaskToPolicies) {
+ const auto policies1 = BitmaskToPolicies(PolicyFlags::POLICY_PUBLIC);
+ ASSERT_EQ(1, policies1.size());
+ ASSERT_EQ(policies1[0], "public");
+
+ const auto policies2 = BitmaskToPolicies(PolicyFlags::POLICY_SYSTEM_PARTITION |
+ PolicyFlags::POLICY_VENDOR_PARTITION);
+ ASSERT_EQ(2, policies2.size());
+ ASSERT_EQ(policies2[0], "system");
+ ASSERT_EQ(policies2[1], "vendor");
+
+ const auto policies3 = BitmaskToPolicies(
+ PolicyFlags::POLICY_ODM_PARTITION | PolicyFlags::POLICY_OEM_PARTITION |
+ PolicyFlags::POLICY_PUBLIC | PolicyFlags::POLICY_PRODUCT_PARTITION |
+ PolicyFlags::POLICY_SYSTEM_PARTITION | PolicyFlags::POLICY_VENDOR_PARTITION);
+ ASSERT_EQ(2, policies2.size());
+ ASSERT_EQ(policies3[0], "odm");
+ ASSERT_EQ(policies3[1], "oem");
+ ASSERT_EQ(policies3[2], "public");
+ ASSERT_EQ(policies3[3], "product");
+ ASSERT_EQ(policies3[4], "system");
+ ASSERT_EQ(policies3[5], "vendor");
+}
+
} // namespace android::idmap2
diff --git a/cmds/idmap2/tests/RawPrintVisitorTests.cpp b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
index 64518fd..2695176 100644
--- a/cmds/idmap2/tests/RawPrintVisitorTests.cpp
+++ b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
@@ -49,7 +49,7 @@
ASSERT_NE(stream.str().find("00000000: 504d4449 magic\n"), std::string::npos);
ASSERT_NE(stream.str().find("00000004: 00000001 version\n"), std::string::npos);
- ASSERT_NE(stream.str().find("00000008: d513ca1b target crc\n"), std::string::npos);
+ ASSERT_NE(stream.str().find("00000008: 76a20829 target crc\n"), std::string::npos);
ASSERT_NE(stream.str().find("0000000c: 8635c2ed overlay crc\n"), std::string::npos);
ASSERT_NE(stream.str().find("0000021c: 00000000 0x7f010000 -> 0x7f010000 integer/int1\n"),
std::string::npos);
diff --git a/cmds/idmap2/tests/data/system-overlay-invalid/res/values/values.xml b/cmds/idmap2/tests/data/system-overlay-invalid/res/values/values.xml
index 0270400..9ebfae4 100644
--- a/cmds/idmap2/tests/data/system-overlay-invalid/res/values/values.xml
+++ b/cmds/idmap2/tests/data/system-overlay-invalid/res/values/values.xml
@@ -23,6 +23,8 @@
<!-- Requests to overlay a resource that belongs to a policy the overlay does not fulfill. -->
<string name="policy_product">policy_product</string>
<string name="policy_signature">policy_signature</string>
+ <string name="policy_odm">policy_odm</string>
+ <string name="policy_oem">policy_oem</string>
<!-- Requests to overlay a resource that is not declared as overlayable. -->
<string name="not_overlayable">not_overlayable</string>
diff --git a/cmds/idmap2/tests/data/system-overlay-invalid/system-overlay-invalid.apk b/cmds/idmap2/tests/data/system-overlay-invalid/system-overlay-invalid.apk
index 9448939..1456e74 100644
--- a/cmds/idmap2/tests/data/system-overlay-invalid/system-overlay-invalid.apk
+++ b/cmds/idmap2/tests/data/system-overlay-invalid/system-overlay-invalid.apk
Binary files differ
diff --git a/cmds/idmap2/tests/data/target/res/values/overlayable.xml b/cmds/idmap2/tests/data/target/res/values/overlayable.xml
index 0bf83fa..8389f56 100644
--- a/cmds/idmap2/tests/data/target/res/values/overlayable.xml
+++ b/cmds/idmap2/tests/data/target/res/values/overlayable.xml
@@ -33,6 +33,14 @@
<item type="string" name="policy_product" />
</policy>
+ <policy type="odm">
+ <item type="string" name="policy_odm" />
+ </policy>
+
+ <policy type="oem">
+ <item type="string" name="policy_oem" />
+ </policy>
+
<!-- Resources publicly overlayable -->
<policy type="public">
<item type="string" name="policy_public" />
diff --git a/cmds/idmap2/tests/data/target/res/values/values.xml b/cmds/idmap2/tests/data/target/res/values/values.xml
index edd53f4..a892c98 100644
--- a/cmds/idmap2/tests/data/target/res/values/values.xml
+++ b/cmds/idmap2/tests/data/target/res/values/values.xml
@@ -29,11 +29,13 @@
<!-- This resources is not marked as overlayable -->
<string name="not_overlayable">not_overlayable</string>
+ <string name="policy_public">policy_public</string>
+ <string name="policy_odm">policy_odm</string>
+ <string name="policy_oem">policy_oem</string>
+ <string name="policy_product">policy_product</string>
+ <string name="policy_signature">policy_signature</string>
<string name="policy_system">policy_system</string>
<string name="policy_system_vendor">policy_system_vendor</string>
- <string name="policy_product">policy_product</string>
- <string name="policy_public">policy_public</string>
- <string name="policy_signature">policy_signature</string>
- <item type="string" name="other" />
+ <string name="other">other</string>
</resources>
diff --git a/cmds/idmap2/tests/data/target/target-no-overlayable.apk b/cmds/idmap2/tests/data/target/target-no-overlayable.apk
index 908b54a..033305a 100644
--- a/cmds/idmap2/tests/data/target/target-no-overlayable.apk
+++ b/cmds/idmap2/tests/data/target/target-no-overlayable.apk
Binary files differ
diff --git a/cmds/idmap2/tests/data/target/target.apk b/cmds/idmap2/tests/data/target/target.apk
index da3c1ae..9bcd6dc 100644
--- a/cmds/idmap2/tests/data/target/target.apk
+++ b/cmds/idmap2/tests/data/target/target.apk
Binary files differ