Accept --overlay-name flag in idmap2
To support allowing for multiple <overlay> tags in one package, idmap2
must be able to generate an idmap for an individual <overlay> tag.
`idmap2 create` now accepts a --overlay-name flag that specifies which
tag to use to generate the idmap. The value of --overlay-name should be
set to the value of the android:name attribute on the <overlay> tag to
use.
If the flag is not present, idmap2 will look for an <overlay> tag with
no value for android:name.
Bug: 162841629
Test: libandroidfw_tests
Test: libidmap2_tests
Change-Id: I02316d0b88773f02c04a5d462be9825016fa496d
diff --git a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
index c3a3e0b..524aabc 100644
--- a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
+++ b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
@@ -33,7 +33,7 @@
namespace android::idmap2 {
TEST(BinaryStreamVisitorTests, CreateBinaryStreamViaBinaryStreamVisitor) {
- std::string raw(reinterpret_cast<const char*>(idmap_raw_data), idmap_raw_data_len);
+ std::string raw(reinterpret_cast<const char*>(idmap_raw_data), kIdmapRawDataLen);
std::istringstream raw_stream(raw);
auto result1 = Idmap::FromBinaryStream(raw_stream);
diff --git a/cmds/idmap2/tests/Idmap2BinaryTests.cpp b/cmds/idmap2/tests/Idmap2BinaryTests.cpp
index e7e9e4c..a55b41b 100644
--- a/cmds/idmap2/tests/Idmap2BinaryTests.cpp
+++ b/cmds/idmap2/tests/Idmap2BinaryTests.cpp
@@ -35,6 +35,7 @@
#include <vector>
#include "R.h"
+#include "TestConstants.h"
#include "TestHelpers.h"
#include "androidfw/PosixUtils.h"
#include "gmock/gmock.h"
@@ -43,6 +44,7 @@
#include "idmap2/Idmap.h"
#include "private/android_filesystem_config.h"
+using ::android::base::StringPrintf;
using ::android::util::ExecuteBinary;
using ::testing::NotNull;
@@ -90,6 +92,7 @@
"create",
"--target-apk-path", GetTargetApkPath(),
"--overlay-apk-path", GetOverlayApkPath(),
+ "--overlay-name", TestConstants::OVERLAY_NAME_DEFAULT,
"--idmap-path", GetIdmapPath()});
// clang-format on
ASSERT_THAT(result, NotNull());
@@ -116,6 +119,7 @@
"create",
"--target-apk-path", GetTargetApkPath(),
"--overlay-apk-path", GetOverlayApkPath(),
+ "--overlay-name", TestConstants::OVERLAY_NAME_DEFAULT,
"--idmap-path", GetIdmapPath()});
// clang-format on
ASSERT_THAT(result, NotNull());
@@ -128,14 +132,23 @@
// clang-format on
ASSERT_THAT(result, NotNull());
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
- ASSERT_NE(result->stdout.find(R::target::integer::literal::int1 + " -> 0x7f010000"),
- std::string::npos);
- ASSERT_NE(result->stdout.find(R::target::string::literal::str1 + " -> 0x7f020000"),
- std::string::npos);
- ASSERT_NE(result->stdout.find(R::target::string::literal::str3 + " -> 0x7f020001"),
- std::string::npos);
- ASSERT_NE(result->stdout.find(R::target::string::literal::str4 + " -> 0x7f020002"),
- std::string::npos);
+
+ ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::integer::int1,
+ R::overlay::integer::int1)),
+ std::string::npos)
+ << result->stdout;
+ ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str1,
+ R::overlay::string::str1)),
+ std::string::npos)
+ << result->stdout;
+ ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str3,
+ R::overlay::string::str3)),
+ std::string::npos)
+ << result->stdout;
+ ASSERT_NE(result->stdout.find(StringPrintf("0x%08x -> 0x%08x", R::target::string::str4,
+ R::overlay::string::str4)),
+ std::string::npos)
+ << result->stdout;
// clang-format off
result = ExecuteBinary({"idmap2",
@@ -167,6 +180,7 @@
"create",
"--target-apk-path", GetTargetApkPath(),
"--overlay-apk-path", GetOverlayApkPath(),
+ "--overlay-name", TestConstants::OVERLAY_NAME_DEFAULT,
"--idmap-path", GetIdmapPath()});
// clang-format on
ASSERT_THAT(result, NotNull());
@@ -177,7 +191,7 @@
"lookup",
"--idmap-path", GetIdmapPath(),
"--config", "",
- "--resid", R::target::string::literal::str1});
+ "--resid", StringPrintf("0x%08x", R::target::string::str1)});
// clang-format on
ASSERT_THAT(result, NotNull());
ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
@@ -229,6 +243,7 @@
"create",
"--target-apk-path", GetTargetApkPath(),
"--overlay-apk-path", GetOverlayApkPath(),
+ "--overlay-name", TestConstants::OVERLAY_NAME_DEFAULT,
"--idmap-path"});
// clang-format on
ASSERT_THAT(result, NotNull());
@@ -240,6 +255,7 @@
"create",
"--target-apk-path", invalid_target_apk_path,
"--overlay-apk-path", GetOverlayApkPath(),
+ "--overlay-name", TestConstants::OVERLAY_NAME_DEFAULT,
"--idmap-path", GetIdmapPath()});
// clang-format on
ASSERT_THAT(result, NotNull());
@@ -251,6 +267,7 @@
"create",
"--target-apk-path", GetTargetApkPath(),
"--overlay-apk-path", GetOverlayApkPath(),
+ "--overlay-name", TestConstants::OVERLAY_NAME_DEFAULT,
"--idmap-path", GetIdmapPath(),
"--policy", "this-does-not-exist"});
// clang-format on
diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp
index 7be1602..c13b049 100644
--- a/cmds/idmap2/tests/IdmapTests.cpp
+++ b/cmds/idmap2/tests/IdmapTests.cpp
@@ -27,6 +27,7 @@
#include "TestHelpers.h"
#include "android-base/macros.h"
#include "androidfw/ApkAssets.h"
+#include "androidfw/ResourceUtils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "idmap2/BinaryStreamVisitor.h"
@@ -60,12 +61,12 @@
}
TEST(IdmapTests, CreateIdmapHeaderFromBinaryStream) {
- std::string raw(reinterpret_cast<const char*>(idmap_raw_data), idmap_raw_data_len);
+ std::string raw(reinterpret_cast<const char*>(idmap_raw_data), kIdmapRawDataLen);
std::istringstream stream(raw);
std::unique_ptr<const IdmapHeader> header = IdmapHeader::FromBinaryStream(stream);
ASSERT_THAT(header, NotNull());
ASSERT_EQ(header->GetMagic(), 0x504d4449U);
- ASSERT_EQ(header->GetVersion(), 0x06U);
+ ASSERT_EQ(header->GetVersion(), 0x07U);
ASSERT_EQ(header->GetTargetCrc(), 0x1234U);
ASSERT_EQ(header->GetOverlayCrc(), 0x5678U);
ASSERT_EQ(header->GetFulfilledPolicies(), 0x11);
@@ -76,9 +77,9 @@
}
TEST(IdmapTests, CreateIdmapDataHeaderFromBinaryStream) {
- const size_t offset = idmap_raw_data_offset;
+ const size_t offset = kIdmapRawDataOffset;
std::string raw(reinterpret_cast<const char*>(idmap_raw_data + offset),
- idmap_raw_data_len - offset);
+ kIdmapRawDataLen - offset);
std::istringstream stream(raw);
std::unique_ptr<const IdmapData::Header> header = IdmapData::Header::FromBinaryStream(stream);
@@ -88,9 +89,9 @@
}
TEST(IdmapTests, CreateIdmapDataFromBinaryStream) {
- const size_t offset = idmap_raw_data_offset;
+ const size_t offset = kIdmapRawDataOffset;
std::string raw(reinterpret_cast<const char*>(idmap_raw_data + offset),
- idmap_raw_data_len - offset);
+ kIdmapRawDataLen - offset);
std::istringstream stream(raw);
std::unique_ptr<const IdmapData> data = IdmapData::FromBinaryStream(stream);
@@ -115,7 +116,7 @@
}
TEST(IdmapTests, CreateIdmapFromBinaryStream) {
- std::string raw(reinterpret_cast<const char*>(idmap_raw_data), idmap_raw_data_len);
+ std::string raw(reinterpret_cast<const char*>(idmap_raw_data), kIdmapRawDataLen);
std::istringstream stream(raw);
auto result = Idmap::FromBinaryStream(stream);
@@ -124,13 +125,14 @@
ASSERT_THAT(idmap->GetHeader(), NotNull());
ASSERT_EQ(idmap->GetHeader()->GetMagic(), 0x504d4449U);
- ASSERT_EQ(idmap->GetHeader()->GetVersion(), 0x06U);
+ ASSERT_EQ(idmap->GetHeader()->GetVersion(), 0x07U);
ASSERT_EQ(idmap->GetHeader()->GetTargetCrc(), 0x1234U);
ASSERT_EQ(idmap->GetHeader()->GetOverlayCrc(), 0x5678U);
- ASSERT_EQ(idmap->GetHeader()->GetFulfilledPolicies(), 0x11);
+ ASSERT_EQ(idmap->GetHeader()->GetFulfilledPolicies(), kIdmapRawDataPolicies);
ASSERT_EQ(idmap->GetHeader()->GetEnforceOverlayable(), true);
- ASSERT_EQ(idmap->GetHeader()->GetTargetPath(), idmap_raw_data_target_path);
- ASSERT_EQ(idmap->GetHeader()->GetOverlayPath(), idmap_raw_data_overlay_path);
+ ASSERT_EQ(idmap->GetHeader()->GetTargetPath(), kIdmapRawTargetPath);
+ ASSERT_EQ(idmap->GetHeader()->GetOverlayPath(), kIdmapRawOverlayPath);
+ ASSERT_EQ(idmap->GetHeader()->GetOverlayName(), kIdmapRawOverlayName);
const std::vector<std::unique_ptr<const IdmapData>>& dataBlocks = idmap->GetData();
ASSERT_EQ(dataBlocks.size(), 1U);
@@ -175,48 +177,23 @@
std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
ASSERT_THAT(overlay_apk, NotNull());
- auto idmap_result = Idmap::FromApkAssets(*target_apk, *overlay_apk, PolicyFlags::PUBLIC,
- /* enforce_overlayable */ true);
+ auto idmap_result = Idmap::FromApkAssets(
+ *target_apk, *overlay_apk, TestConstants::OVERLAY_NAME_ALL_POLICIES, PolicyFlags::PUBLIC,
+ /* enforce_overlayable */ true);
ASSERT_TRUE(idmap_result) << idmap_result.GetErrorMessage();
auto& idmap = *idmap_result;
ASSERT_THAT(idmap, NotNull());
ASSERT_THAT(idmap->GetHeader(), NotNull());
ASSERT_EQ(idmap->GetHeader()->GetMagic(), 0x504d4449U);
- ASSERT_EQ(idmap->GetHeader()->GetVersion(), 0x06U);
+ ASSERT_EQ(idmap->GetHeader()->GetVersion(), 0x07U);
ASSERT_EQ(idmap->GetHeader()->GetTargetCrc(), android::idmap2::TestConstants::TARGET_CRC);
ASSERT_EQ(idmap->GetHeader()->GetOverlayCrc(), android::idmap2::TestConstants::OVERLAY_CRC);
ASSERT_EQ(idmap->GetHeader()->GetFulfilledPolicies(), PolicyFlags::PUBLIC);
ASSERT_EQ(idmap->GetHeader()->GetEnforceOverlayable(), true);
ASSERT_EQ(idmap->GetHeader()->GetTargetPath(), target_apk_path);
ASSERT_EQ(idmap->GetHeader()->GetOverlayPath(), overlay_apk_path);
-}
-
-Result<std::unique_ptr<const IdmapData>> TestIdmapDataFromApkAssets(
- const android::StringPiece& local_target_apk_path,
- const android::StringPiece& local_overlay_apk_path, const OverlayManifestInfo& overlay_info,
- const PolicyBitmask& fulfilled_policies, bool enforce_overlayable) {
- const std::string target_apk_path(GetTestDataPath() + local_target_apk_path.data());
- std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
- if (!target_apk) {
- return Error(R"(Failed to load target apk "%s")", target_apk_path.data());
- }
-
- const std::string overlay_apk_path(GetTestDataPath() + local_overlay_apk_path.data());
- std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
- if (!overlay_apk) {
- return Error(R"(Failed to load overlay apk "%s")", overlay_apk_path.data());
- }
-
- LogInfo log_info;
- auto mapping = ResourceMapping::FromApkAssets(*target_apk, *overlay_apk, overlay_info,
- fulfilled_policies, enforce_overlayable, log_info);
-
- if (!mapping) {
- return mapping.GetError();
- }
-
- return IdmapData::FromResourceMapping(*mapping);
+ ASSERT_EQ(idmap->GetHeader()->GetOverlayName(), TestConstants::OVERLAY_NAME_ALL_POLICIES);
}
TEST(IdmapTests, CreateIdmapDataFromApkAssets) {
@@ -229,7 +206,8 @@
std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
ASSERT_THAT(overlay_apk, NotNull());
- auto idmap_result = Idmap::FromApkAssets(*target_apk, *overlay_apk, PolicyFlags::PUBLIC,
+ auto idmap_result = Idmap::FromApkAssets(*target_apk, *overlay_apk,
+ TestConstants::OVERLAY_NAME_DEFAULT, PolicyFlags::PUBLIC,
/* enforce_overlayable */ true);
ASSERT_TRUE(idmap_result) << idmap_result.GetErrorMessage();
auto& idmap = *idmap_result;
@@ -259,6 +237,29 @@
ASSERT_OVERLAY_ENTRY(overlay_entries[3], R::overlay::string::str4, R::target::string::str4);
}
+TEST(IdmapTests, FailCreateIdmapInvalidName) {
+ std::string target_apk_path = GetTestDataPath() + "/target/target.apk";
+ std::string overlay_apk_path = GetTestDataPath() + "/overlay/overlay.apk";
+
+ std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
+ ASSERT_THAT(target_apk, NotNull());
+
+ std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
+ ASSERT_THAT(overlay_apk, NotNull());
+
+ {
+ auto idmap_result = Idmap::FromApkAssets(*target_apk, *overlay_apk, "", PolicyFlags::PUBLIC,
+ /* enforce_overlayable */ true);
+ ASSERT_FALSE(idmap_result);
+ }
+ {
+ auto idmap_result =
+ Idmap::FromApkAssets(*target_apk, *overlay_apk, "unknown", PolicyFlags::PUBLIC,
+ /* enforce_overlayable */ true);
+ ASSERT_FALSE(idmap_result);
+ }
+}
+
TEST(IdmapTests, CreateIdmapDataFromApkAssetsSharedLibOverlay) {
std::string target_apk_path = GetTestDataPath() + "/target/target.apk";
std::string overlay_apk_path = GetTestDataPath() + "/overlay/overlay-shared.apk";
@@ -269,7 +270,8 @@
std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
ASSERT_THAT(overlay_apk, NotNull());
- auto idmap_result = Idmap::FromApkAssets(*target_apk, *overlay_apk, PolicyFlags::PUBLIC,
+ auto idmap_result = Idmap::FromApkAssets(*target_apk, *overlay_apk,
+ TestConstants::OVERLAY_NAME_DEFAULT, PolicyFlags::PUBLIC,
/* enforce_overlayable */ true);
ASSERT_TRUE(idmap_result) << idmap_result.GetErrorMessage();
auto& idmap = *idmap_result;
@@ -284,34 +286,67 @@
const auto& target_entries = data->GetTargetEntries();
ASSERT_EQ(target_entries.size(), 4U);
ASSERT_TARGET_ENTRY(target_entries[0], R::target::integer::int1,
- R::overlay_shared::integer::int1);
- ASSERT_TARGET_ENTRY(target_entries[1], R::target::string::str1, R::overlay_shared::string::str1);
- ASSERT_TARGET_ENTRY(target_entries[2], R::target::string::str3, R::overlay_shared::string::str3);
- ASSERT_TARGET_ENTRY(target_entries[3], R::target::string::str4, R::overlay_shared::string::str4);
+ fix_package_id(R::overlay::integer::int1, 0));
+ ASSERT_TARGET_ENTRY(target_entries[1], R::target::string::str1,
+ fix_package_id(R::overlay::string::str1, 0));
+ ASSERT_TARGET_ENTRY(target_entries[2], R::target::string::str3,
+ fix_package_id(R::overlay::string::str3, 0));
+ ASSERT_TARGET_ENTRY(target_entries[3], R::target::string::str4,
+ fix_package_id(R::overlay::string::str4, 0));
const auto& target_inline_entries = data->GetTargetInlineEntries();
ASSERT_EQ(target_inline_entries.size(), 0U);
const auto& overlay_entries = data->GetOverlayEntries();
ASSERT_EQ(target_entries.size(), 4U);
- ASSERT_OVERLAY_ENTRY(overlay_entries[0], R::overlay_shared::integer::int1,
+ ASSERT_OVERLAY_ENTRY(overlay_entries[0], fix_package_id(R::overlay::integer::int1, 0),
R::target::integer::int1);
- ASSERT_OVERLAY_ENTRY(overlay_entries[1], R::overlay_shared::string::str1,
+ ASSERT_OVERLAY_ENTRY(overlay_entries[1], fix_package_id(R::overlay::string::str1, 0),
R::target::string::str1);
- ASSERT_OVERLAY_ENTRY(overlay_entries[2], R::overlay_shared::string::str3,
+ ASSERT_OVERLAY_ENTRY(overlay_entries[2], fix_package_id(R::overlay::string::str3, 0),
R::target::string::str3);
- ASSERT_OVERLAY_ENTRY(overlay_entries[3], R::overlay_shared::string::str4,
+ ASSERT_OVERLAY_ENTRY(overlay_entries[3], fix_package_id(R::overlay::string::str4, 0),
R::target::string::str4);
}
+Result<std::unique_ptr<const IdmapData>> TestIdmapDataFromApkAssets(
+ const std::string& local_target_apk_path, const std::string& local_overlay_apk_path,
+ const std::string& overlay_name, const PolicyBitmask& fulfilled_policies,
+ bool enforce_overlayable) {
+ auto overlay_info =
+ utils::ExtractOverlayManifestInfo(GetTestDataPath() + local_overlay_apk_path, overlay_name);
+ if (!overlay_info) {
+ return overlay_info.GetError();
+ }
+
+ const std::string target_apk_path(GetTestDataPath() + local_target_apk_path);
+ std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
+ if (!target_apk) {
+ return Error(R"(Failed to load target apk "%s")", target_apk_path.data());
+ }
+
+ const std::string overlay_apk_path(GetTestDataPath() + local_overlay_apk_path);
+ std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
+ if (!overlay_apk) {
+ return Error(R"(Failed to load overlay apk "%s")", overlay_apk_path.data());
+ }
+
+ LogInfo log_info;
+ auto mapping = ResourceMapping::FromApkAssets(*target_apk, *overlay_apk, *overlay_info,
+ fulfilled_policies, enforce_overlayable, log_info);
+ if (!mapping) {
+ return mapping.GetError();
+ }
+
+ return IdmapData::FromResourceMapping(*mapping);
+}
+
TEST(IdmapTests, CreateIdmapDataDoNotRewriteNonOverlayResourceId) {
- OverlayManifestInfo info{};
- info.target_package = "test.target";
- info.target_name = "TestResources";
- info.resource_mapping = 0x7f030001; // xml/overlays_different_packages
- auto idmap_data = TestIdmapDataFromApkAssets("/target/target.apk", "/overlay/overlay.apk", info,
- PolicyFlags::PUBLIC,
- /* enforce_overlayable */ false);
+ auto idmap_data =
+ TestIdmapDataFromApkAssets("/target/target.apk", "/overlay/overlay.apk", "DifferentPackages",
+
+ PolicyFlags::PUBLIC,
+ /* enforce_overlayable */ false);
ASSERT_TRUE(idmap_data) << idmap_data.GetErrorMessage();
auto& data = *idmap_data;
@@ -331,12 +366,8 @@
}
TEST(IdmapTests, CreateIdmapDataInlineResources) {
- OverlayManifestInfo info{};
- info.target_package = "test.target";
- info.target_name = "TestResources";
- info.resource_mapping = 0x7f030002; // xml/overlays_inline
- auto idmap_data = TestIdmapDataFromApkAssets("/target/target.apk", "/overlay/overlay.apk", info,
- PolicyFlags::PUBLIC,
+ auto idmap_data = TestIdmapDataFromApkAssets("/target/target.apk", "/overlay/overlay.apk",
+ "Inline", PolicyFlags::PUBLIC,
/* enforce_overlayable */ false);
ASSERT_TRUE(idmap_data) << idmap_data.GetErrorMessage();
@@ -345,7 +376,7 @@
const auto& target_entries = data->GetTargetEntries();
ASSERT_EQ(target_entries.size(), 0U);
- constexpr size_t overlay_string_pool_size = 8U;
+ constexpr size_t overlay_string_pool_size = 10U;
const auto& target_inline_entries = data->GetTargetInlineEntries();
ASSERT_EQ(target_inline_entries.size(), 2U);
ASSERT_TARGET_INLINE_ENTRY(target_inline_entries[0], R::target::integer::int1,
@@ -361,13 +392,14 @@
TEST(IdmapTests, IdmapHeaderIsUpToDate) {
fclose(stderr); // silence expected warnings from libandroidfw
- const std::string target_apk_path = idmap_raw_data_target_path;
- const std::string overlay_apk_path = idmap_raw_data_overlay_path;
- const PolicyBitmask policies = idmap_raw_data_policies;
- const uint32_t target_crc = idmap_raw_data_target_crc;
- const uint32_t overlay_crc = idmap_raw_data_overlay_crc;
+ const std::string target_apk_path = kIdmapRawTargetPath;
+ const std::string overlay_apk_path = kIdmapRawOverlayPath;
+ const std::string overlay_name = kIdmapRawOverlayName;
+ const PolicyBitmask policies = kIdmapRawDataPolicies;
+ const uint32_t target_crc = kIdmapRawDataTargetCrc;
+ const uint32_t overlay_crc = kIdmapRawOverlayCrc;
- std::string raw(reinterpret_cast<const char*>(idmap_raw_data), idmap_raw_data_len);
+ std::string raw(reinterpret_cast<const char*>(idmap_raw_data), kIdmapRawDataLen);
std::istringstream raw_stream(raw);
auto result = Idmap::FromBinaryStream(raw_stream);
@@ -380,8 +412,9 @@
std::unique_ptr<const IdmapHeader> header = IdmapHeader::FromBinaryStream(stream);
ASSERT_THAT(header, NotNull());
- ASSERT_TRUE(header->IsUpToDate(target_apk_path, overlay_apk_path, idmap_raw_data_target_crc,
- overlay_crc, policies, /* enforce_overlayable */ true));
+ ASSERT_TRUE(header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ kIdmapRawDataTargetCrc, overlay_crc, policies,
+ /* enforce_overlayable */ true));
// magic: bytes (0x0, 0x03)
std::string bad_magic_string(stream.str());
@@ -394,8 +427,9 @@
IdmapHeader::FromBinaryStream(bad_magic_stream);
ASSERT_THAT(bad_magic_header, NotNull());
ASSERT_NE(header->GetMagic(), bad_magic_header->GetMagic());
- ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies, /* enforce_overlayable */ true));
+ ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
+ /* enforce_overlayable */ true));
// version: bytes (0x4, 0x07)
std::string bad_version_string(stream.str());
@@ -408,8 +442,9 @@
IdmapHeader::FromBinaryStream(bad_version_stream);
ASSERT_THAT(bad_version_header, NotNull());
ASSERT_NE(header->GetVersion(), bad_version_header->GetVersion());
- ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies, /* enforce_overlayable */ true));
+ ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
+ /* enforce_overlayable */ true));
// target crc: bytes (0x8, 0xb)
std::string bad_target_crc_string(stream.str());
@@ -422,8 +457,9 @@
IdmapHeader::FromBinaryStream(bad_target_crc_stream);
ASSERT_THAT(bad_target_crc_header, NotNull());
ASSERT_NE(header->GetTargetCrc(), bad_target_crc_header->GetTargetCrc());
- ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies, /* enforce_overlayable */ true));
+ ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
+ /* enforce_overlayable */ true));
// overlay crc: bytes (0xc, 0xf)
std::string bad_overlay_crc_string(stream.str());
@@ -436,8 +472,9 @@
IdmapHeader::FromBinaryStream(bad_overlay_crc_stream);
ASSERT_THAT(bad_overlay_crc_header, NotNull());
ASSERT_NE(header->GetOverlayCrc(), bad_overlay_crc_header->GetOverlayCrc());
- ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies, /* enforce_overlayable */ true));
+ ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
+ /* enforce_overlayable */ true));
// fulfilled policy: bytes (0x10, 0x13)
std::string bad_policy_string(stream.str());
@@ -450,8 +487,8 @@
IdmapHeader::FromBinaryStream(bad_policy_stream);
ASSERT_THAT(bad_policy_header, NotNull());
ASSERT_NE(header->GetFulfilledPolicies(), bad_policy_header->GetFulfilledPolicies());
- ASSERT_FALSE(bad_policy_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies,
+ ASSERT_FALSE(bad_policy_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
/* enforce_overlayable */ true));
// enforce overlayable: bytes (0x14)
@@ -462,8 +499,8 @@
IdmapHeader::FromBinaryStream(bad_enforce_stream);
ASSERT_THAT(bad_enforce_header, NotNull());
ASSERT_NE(header->GetEnforceOverlayable(), bad_enforce_header->GetEnforceOverlayable());
- ASSERT_FALSE(bad_enforce_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies,
+ ASSERT_FALSE(bad_enforce_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
/* enforce_overlayable */ true));
// target path: bytes (0x1c, 0x27)
@@ -474,8 +511,9 @@
IdmapHeader::FromBinaryStream(bad_target_path_stream);
ASSERT_THAT(bad_target_path_header, NotNull());
ASSERT_NE(header->GetTargetPath(), bad_target_path_header->GetTargetPath());
- ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies, /* enforce_overlayable */ true));
+ ASSERT_FALSE(bad_magic_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
+ /* enforce_overlayable */ true));
// overlay path: bytes (0x2c, 0x37)
std::string bad_overlay_path_string(stream.str());
@@ -485,9 +523,23 @@
IdmapHeader::FromBinaryStream(bad_overlay_path_stream);
ASSERT_THAT(bad_overlay_path_header, NotNull());
ASSERT_NE(header->GetOverlayPath(), bad_overlay_path_header->GetOverlayPath());
- ASSERT_FALSE(bad_overlay_path_header->IsUpToDate(target_apk_path, overlay_apk_path, target_crc,
- overlay_crc, policies,
+ ASSERT_FALSE(bad_overlay_path_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
/* enforce_overlayable */ true));
+
+ // overlay path: bytes (0x3c, 0x47)
+ std::string bad_overlay_name_string(stream.str());
+ bad_overlay_name_string[0x3c] = '\0';
+ std::stringstream bad_overlay_name_stream(bad_overlay_name_string);
+ std::unique_ptr<const IdmapHeader> bad_overlay_name_header =
+ IdmapHeader::FromBinaryStream(bad_overlay_name_stream);
+ ASSERT_THAT(bad_overlay_name_header, NotNull());
+ ASSERT_NE(header->GetOverlayName(), bad_overlay_name_header->GetOverlayName());
+ ASSERT_FALSE(bad_overlay_name_header->IsUpToDate(target_apk_path, overlay_apk_path, overlay_name,
+ target_crc, overlay_crc, policies,
+ /* enforce_overlayable */ true));
+
+ // overlay name: bytes (0x2c, 0x37)
}
class TestVisitor : public Visitor {
@@ -516,7 +568,7 @@
};
TEST(IdmapTests, TestVisitor) {
- std::string raw(reinterpret_cast<const char*>(idmap_raw_data), idmap_raw_data_len);
+ std::string raw(reinterpret_cast<const char*>(idmap_raw_data), kIdmapRawDataLen);
std::istringstream stream(raw);
const auto idmap = Idmap::FromBinaryStream(stream);
diff --git a/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp b/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp
index d30fbfc..87ce0f1 100644
--- a/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp
+++ b/cmds/idmap2/tests/PrettyPrintVisitorTests.cpp
@@ -15,22 +15,21 @@
*/
#include <memory>
-#include <sstream>
#include <string>
#include "R.h"
+#include "TestConstants.h"
#include "TestHelpers.h"
#include "androidfw/ApkAssets.h"
-#include "androidfw/Idmap.h"
#include "androidfw/ResourceTypes.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "idmap2/Idmap.h"
#include "idmap2/PrettyPrintVisitor.h"
-using ::testing::NotNull;
-
using android::ApkAssets;
+using android::base::StringPrintf;
+using ::testing::NotNull;
using PolicyBitmask = android::ResTable_overlayable_policy_header::PolicyBitmask;
using PolicyFlags = android::ResTable_overlayable_policy_header::PolicyFlags;
@@ -46,7 +45,8 @@
std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
ASSERT_THAT(overlay_apk, NotNull());
- const auto idmap = Idmap::FromApkAssets(*target_apk, *overlay_apk, PolicyFlags::PUBLIC,
+ const auto idmap = Idmap::FromApkAssets(*target_apk, *overlay_apk,
+ TestConstants::OVERLAY_NAME_DEFAULT, PolicyFlags::PUBLIC,
/* enforce_overlayable */ true);
ASSERT_TRUE(idmap);
@@ -56,15 +56,15 @@
ASSERT_NE(stream.str().find("target apk path : "), std::string::npos);
ASSERT_NE(stream.str().find("overlay apk path : "), std::string::npos);
- ASSERT_NE(stream.str().find(R::target::integer::literal::int1 +
- " -> 0x7f010000 (integer/int1 -> integer/int1)\n"),
+ ASSERT_NE(stream.str().find(StringPrintf("0x%08x -> 0x%08x (integer/int1 -> integer/int1)\n",
+ R::target::integer::int1, R::overlay::integer::int1)),
std::string::npos);
}
TEST(PrettyPrintVisitorTests, CreatePrettyPrintVisitorWithoutAccessToApks) {
fclose(stderr); // silence expected warnings from libandroidfw
- std::string raw(reinterpret_cast<const char*>(idmap_raw_data), idmap_raw_data_len);
+ std::string raw(reinterpret_cast<const char*>(idmap_raw_data), kIdmapRawDataLen);
std::istringstream raw_stream(raw);
const auto idmap = Idmap::FromBinaryStream(raw_stream);
diff --git a/cmds/idmap2/tests/R.h b/cmds/idmap2/tests/R.h
index 854b57f..ac9b058 100644
--- a/cmds/idmap2/tests/R.h
+++ b/cmds/idmap2/tests/R.h
@@ -23,22 +23,11 @@
namespace android::idmap2 {
-static std::string hexify(ResourceId id) {
- std::stringstream stream;
- stream << std::hex << static_cast<uint32_t>(id);
- return stream.str();
-}
-
// clang-format off
namespace R::target {
namespace integer { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId int1 = 0x7f010000;
-
- namespace literal { // NOLINT(runtime/indentation_namespace)
- inline const std::string int1 = hexify(R::target::integer::int1);
- }
}
-
namespace string { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId not_overlayable = 0x7f020003;
constexpr ResourceId other = 0x7f020004;
@@ -54,56 +43,31 @@
constexpr ResourceId str1 = 0x7f02000e;
constexpr ResourceId str3 = 0x7f020010;
constexpr ResourceId str4 = 0x7f020011;
-
- namespace literal { // NOLINT(runtime/indentation_namespace)
- inline const std::string str1 = hexify(R::target::string::str1);
- inline const std::string str3 = hexify(R::target::string::str3);
- inline const std::string str4 = hexify(R::target::string::str4);
- }
} // namespace string
} // namespace R::target
namespace R::overlay {
namespace integer { // NOLINT(runtime/indentation_namespace)
constexpr ResourceId int1 = 0x7f010000;
+ constexpr ResourceId not_in_target = 0x7f010001;
}
namespace string { // NOLINT(runtime/indentation_namespace)
- constexpr ResourceId str1 = 0x7f020000;
- constexpr ResourceId str3 = 0x7f020001;
- constexpr ResourceId str4 = 0x7f020002;
+ constexpr ResourceId not_overlayable = 0x7f020000;
+ constexpr ResourceId other = 0x7f020001;
+ constexpr ResourceId policy_actor = 0x7f020002;
+ constexpr ResourceId policy_config_signature = 0x7f020003;
+ constexpr ResourceId policy_odm = 0x7f020004;
+ constexpr ResourceId policy_oem = 0x7f020005;
+ constexpr ResourceId policy_product = 0x7f020006;
+ constexpr ResourceId policy_public = 0x7f020007;
+ constexpr ResourceId policy_signature = 0x7f020008;
+ constexpr ResourceId policy_system = 0x7f020009;
+ constexpr ResourceId policy_system_vendor = 0x7f02000a;
+ constexpr ResourceId str1 = 0x7f02000b;
+ constexpr ResourceId str3 = 0x7f02000c;
+ constexpr ResourceId str4 = 0x7f02000d;
}
}
-
-namespace R::overlay_shared {
- namespace integer { // NOLINT(runtime/indentation_namespace)
- constexpr ResourceId int1 = 0x00010000;
- }
- namespace string { // NOLINT(runtime/indentation_namespace)
- constexpr ResourceId str1 = 0x00020000;
- constexpr ResourceId str3 = 0x00020001;
- constexpr ResourceId str4 = 0x00020002;
- }
-}
-
-namespace R::system_overlay::string {
- constexpr ResourceId policy_public = 0x7f010000;
- constexpr ResourceId policy_system = 0x7f010001;
- constexpr ResourceId policy_system_vendor = 0x7f010002;
-}
-
-namespace R::system_overlay_invalid::string {
- constexpr ResourceId not_overlayable = 0x7f010000;
- constexpr ResourceId other = 0x7f010001;
- constexpr ResourceId policy_actor = 0x7f010002;
- constexpr ResourceId policy_config_signature = 0x7f010003;
- constexpr ResourceId policy_odm = 0x7f010004;
- constexpr ResourceId policy_oem = 0x7f010005;
- constexpr ResourceId policy_product = 0x7f010006;
- constexpr ResourceId policy_public = 0x7f010007;
- constexpr ResourceId policy_signature = 0x7f010008;
- constexpr ResourceId policy_system = 0x7f010009;
- constexpr ResourceId policy_system_vendor = 0x7f01000a;
-} // namespace R::system_overlay_invalid::string
// clang-format on
} // namespace android::idmap2
diff --git a/cmds/idmap2/tests/RawPrintVisitorTests.cpp b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
index b7ea22a..88f85ef 100644
--- a/cmds/idmap2/tests/RawPrintVisitorTests.cpp
+++ b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
@@ -56,8 +56,9 @@
std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
ASSERT_THAT(overlay_apk, NotNull());
- const auto idmap = Idmap::FromApkAssets(*target_apk, *overlay_apk, PolicyFlags::PUBLIC,
- /* enforce_overlayable */ true);
+ const auto idmap =
+ Idmap::FromApkAssets(*target_apk, *overlay_apk, TestConstants::OVERLAY_NAME_DEFAULT,
+ PolicyFlags::PUBLIC, /* enforce_overlayable */ true);
ASSERT_TRUE(idmap);
std::stringstream stream;
@@ -65,7 +66,7 @@
(*idmap)->accept(&visitor);
ASSERT_CONTAINS_REGEX(ADDRESS "504d4449 magic\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "00000006 version\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "00000007 version\n", stream.str());
ASSERT_CONTAINS_REGEX(
StringPrintf(ADDRESS "%s target crc\n", android::idmap2::TestConstants::TARGET_CRC_STRING),
stream.str());
@@ -76,22 +77,34 @@
ASSERT_CONTAINS_REGEX(ADDRESS "00000001 enforce overlayable\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS " 7f target package id\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS " 7f overlay package id\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "00000004 target entry count\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "00000004 overlay entry count\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "00000004 overlay entry count\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "00000008 string pool index offset\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 target id: integer/int1\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 overlay id: integer/int1\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 overlay id: integer/int1\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 target id: integer/int1\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "000000b4 string pool size\n", stream.str());
- ASSERT_CONTAINS_REGEX("000001bc: ........ string pool\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "00000004 target entry count", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "00000000 target inline entry count", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "00000004 overlay entry count", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "0000000a string pool index offset", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 target id: integer/int1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 overlay id: integer/int1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000e target id: string/str1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000b overlay id: string/str1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f020010 target id: string/str3", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000c overlay id: string/str3", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f020011 target id: string/str4", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000d overlay id: string/str4", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 overlay id: integer/int1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f010000 target id: integer/int1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000b overlay id: string/str1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000e target id: string/str1", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000c overlay id: string/str3", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f020010 target id: string/str3", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f02000d overlay id: string/str4", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "7f020011 target id: string/str4", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "000000b4 string pool size", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "........ string pool", stream.str());
}
TEST(RawPrintVisitorTests, CreateRawPrintVisitorWithoutAccessToApks) {
fclose(stderr); // silence expected warnings from libandroidfw
- std::string raw(reinterpret_cast<const char*>(idmap_raw_data), idmap_raw_data_len);
+ std::string raw(reinterpret_cast<const char*>(idmap_raw_data), kIdmapRawDataLen);
std::istringstream raw_stream(raw);
const auto idmap = Idmap::FromBinaryStream(raw_stream);
@@ -102,11 +115,17 @@
(*idmap)->accept(&visitor);
ASSERT_CONTAINS_REGEX(ADDRESS "504d4449 magic\n", stream.str());
- ASSERT_CONTAINS_REGEX(ADDRESS "00000006 version\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "00000007 version\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS "00001234 target crc\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS "00005678 overlay crc\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS "00000011 fulfilled policies: public|signature\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS "00000001 enforce overlayable\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "0000000b target path size\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "........ target path: targetX.apk\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "0000000c overlay path size\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "........ overlay path: overlayX.apk\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "0000000b overlay name size\n", stream.str());
+ ASSERT_CONTAINS_REGEX(ADDRESS "........ overlay name: OverlayName\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS " 7f target package id\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS " 7f overlay package id\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS "00000003 target entry count\n", stream.str());
@@ -121,7 +140,7 @@
ASSERT_CONTAINS_REGEX(ADDRESS "7f020000 overlay id\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS "7f030002 target id\n", stream.str());
ASSERT_CONTAINS_REGEX(ADDRESS "00000004 string pool size\n", stream.str());
- ASSERT_CONTAINS_REGEX("00000098: ........ string pool\n", stream.str());
+ ASSERT_CONTAINS_REGEX("000000a8: ........ string pool\n", stream.str());
}
} // namespace android::idmap2
diff --git a/cmds/idmap2/tests/ResourceMappingTests.cpp b/cmds/idmap2/tests/ResourceMappingTests.cpp
index 185e929..0362529 100644
--- a/cmds/idmap2/tests/ResourceMappingTests.cpp
+++ b/cmds/idmap2/tests/ResourceMappingTests.cpp
@@ -17,12 +17,10 @@
#include <cstdio> // fclose
#include <fstream>
#include <memory>
-#include <sstream>
#include <string>
-#include <utility>
-#include <vector>
#include "R.h"
+#include "TestConstants.h"
#include "TestHelpers.h"
#include "androidfw/ResourceTypes.h"
#include "gmock/gmock.h"
@@ -43,38 +41,32 @@
ASSERT_TRUE(result) << result.GetErrorMessage(); \
} while (0)
-Result<ResourceMapping> TestGetResourceMapping(const android::StringPiece& local_target_apk_path,
- const android::StringPiece& local_overlay_apk_path,
- const OverlayManifestInfo& overlay_info,
+Result<ResourceMapping> TestGetResourceMapping(const std::string& local_target_apk_path,
+ const std::string& local_overlay_apk_path,
+ const std::string& overlay_name,
const PolicyBitmask& fulfilled_policies,
bool enforce_overlayable) {
- const std::string target_apk_path(GetTestDataPath() + local_target_apk_path.data());
+ auto overlay_info =
+ ExtractOverlayManifestInfo(GetTestDataPath() + local_overlay_apk_path, overlay_name);
+ if (!overlay_info) {
+ return overlay_info.GetError();
+ }
+
+ const std::string target_apk_path(GetTestDataPath() + local_target_apk_path);
std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
if (!target_apk) {
return Error(R"(Failed to load target apk "%s")", target_apk_path.data());
}
- const std::string overlay_apk_path(GetTestDataPath() + local_overlay_apk_path.data());
+ const std::string overlay_apk_path(GetTestDataPath() + local_overlay_apk_path);
std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
if (!overlay_apk) {
return Error(R"(Failed to load overlay apk "%s")", overlay_apk_path.data());
}
LogInfo log_info;
- return ResourceMapping::FromApkAssets(*target_apk, *overlay_apk, overlay_info, fulfilled_policies,
- enforce_overlayable, log_info);
-}
-
-Result<ResourceMapping> TestGetResourceMapping(const android::StringPiece& local_target_apk_path,
- const android::StringPiece& local_overlay_apk_path,
- const PolicyBitmask& fulfilled_policies,
- bool enforce_overlayable) {
- auto overlay_info = ExtractOverlayManifestInfo(GetTestDataPath() + local_overlay_apk_path.data());
- if (!overlay_info) {
- return overlay_info.GetError();
- }
- return TestGetResourceMapping(local_target_apk_path, local_overlay_apk_path, *overlay_info,
- fulfilled_policies, enforce_overlayable);
+ return ResourceMapping::FromApkAssets(*target_apk, *overlay_apk, *overlay_info,
+ fulfilled_policies, enforce_overlayable, log_info);
}
Result<Unit> MappingExists(const ResourceMapping& mapping, ResourceId target_resource,
@@ -136,13 +128,8 @@
}
TEST(ResourceMappingTests, ResourcesFromApkAssetsLegacy) {
- OverlayManifestInfo info{};
- info.target_package = "test.target";
- info.target_name = "TestResources";
- info.resource_mapping = 0U; // no xml
- auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
- PolicyFlags::PUBLIC,
- /* enforce_overlayable */ false);
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay-legacy.apk", "",
+ PolicyFlags::PUBLIC, /* enforce_overlayable */ false);
ASSERT_TRUE(resources) << resources.GetErrorMessage();
auto& res = *resources;
@@ -158,11 +145,7 @@
}
TEST(ResourceMappingTests, ResourcesFromApkAssetsNonMatchingNames) {
- OverlayManifestInfo info{};
- info.target_package = "test.target";
- info.target_name = "TestResources";
- info.resource_mapping = 0x7f030003; // xml/overlays_swap
- auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", "SwapNames",
PolicyFlags::PUBLIC,
/* enforce_overlayable */ false);
@@ -178,12 +161,8 @@
}
TEST(ResourceMappingTests, DoNotRewriteNonOverlayResourceId) {
- OverlayManifestInfo info{};
- info.target_package = "test.target";
- info.target_name = "TestResources";
- info.resource_mapping = 0x7f030001; // xml/overlays_different_packages
- auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
- PolicyFlags::PUBLIC,
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
+ "DifferentPackages", PolicyFlags::PUBLIC,
/* enforce_overlayable */ false);
ASSERT_TRUE(resources) << resources.GetErrorMessage();
@@ -192,19 +171,15 @@
ASSERT_EQ(res.GetOverlayToTargetMap().size(), 1U);
ASSERT_RESULT(MappingExists(res, R::target::string::str1, 0x0104000a,
false /* rewrite */)); // -> android:string/ok
- ASSERT_RESULT(MappingExists(res, R::target::string::str3, 0x7f020001, true /* rewrite */));
+ ASSERT_RESULT(
+ MappingExists(res, R::target::string::str3, R::overlay::string::str3, true /* rewrite */));
}
TEST(ResourceMappingTests, InlineResources) {
- OverlayManifestInfo info{};
- info.target_package = "test.target";
- info.target_name = "TestResources";
- info.resource_mapping = 0x7f030002; // xml/overlays_inline
- auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
- PolicyFlags::PUBLIC,
- /* enforce_overlayable */ false);
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", "Inline",
+ PolicyFlags::PUBLIC, /* enforce_overlayable */ false);
- constexpr size_t overlay_string_pool_size = 8U;
+ constexpr size_t overlay_string_pool_size = 10U;
ASSERT_TRUE(resources) << resources.GetErrorMessage();
auto& res = *resources;
ASSERT_EQ(res.GetTargetToOverlayMap().size(), 2U);
@@ -215,28 +190,8 @@
}
TEST(ResourceMappingTests, CreateIdmapFromApkAssetsPolicySystemPublic) {
- auto resources =
- TestGetResourceMapping("/target/target.apk", "/system-overlay/system-overlay.apk",
- PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
- /* enforce_overlayable */ true);
-
- ASSERT_TRUE(resources) << resources.GetErrorMessage();
- auto& res = *resources;
- ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
- ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
- R::system_overlay::string::policy_public, false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
- R::system_overlay::string::policy_system, false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
- R::system_overlay::string::policy_system_vendor,
- false /* rewrite */));
-}
-
-// Resources that are not declared as overlayable and resources that a protected by policies the
-// overlay does not fulfill must not map to overlay resources.
-TEST(ResourceMappingTests, CreateIdmapFromApkAssetsPolicySystemPublicInvalid) {
- auto resources = TestGetResourceMapping("/target/target.apk",
- "/system-overlay-invalid/system-overlay-invalid.apk",
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
+ TestConstants::OVERLAY_NAME_ALL_POLICIES,
PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
/* enforce_overlayable */ true);
@@ -244,22 +199,38 @@
auto& res = *resources;
ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
- R::system_overlay_invalid::string::policy_public,
- false /* rewrite */));
+ R::overlay::string::policy_public, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
- R::system_overlay_invalid::string::policy_system,
- false /* rewrite */));
+ R::overlay::string::policy_system, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
- R::system_overlay_invalid::string::policy_system_vendor,
- false /* rewrite */));
+ R::overlay::string::policy_system_vendor, true /* rewrite */));
+}
+
+// Resources that are not declared as overlayable and resources that a protected by policies the
+// overlay does not fulfill must not map to overlay resources.
+TEST(ResourceMappingTests, CreateIdmapFromApkAssetsPolicySystemPublicInvalid) {
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
+ TestConstants::OVERLAY_NAME_ALL_POLICIES,
+ PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
+ /* enforce_overlayable */ true);
+
+ ASSERT_TRUE(resources) << resources.GetErrorMessage();
+ auto& res = *resources;
+ ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
+ ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
+ R::overlay::string::policy_public, true /* rewrite */));
+ ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
+ R::overlay::string::policy_system, true /* rewrite */));
+ ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
+ R::overlay::string::policy_system_vendor, true /* rewrite */));
}
// Resources that are not declared as overlayable and resources that a protected by policies the
// overlay does not fulfilled can map to overlay resources when overlayable enforcement is turned
// off.
TEST(ResourceMappingTests, ResourcesFromApkAssetsPolicySystemPublicInvalidIgnoreOverlayable) {
- auto resources = TestGetResourceMapping("/target/target.apk",
- "/system-overlay-invalid/system-overlay-invalid.apk",
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
+ TestConstants::OVERLAY_NAME_ALL_POLICIES,
PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
/* enforce_overlayable */ false);
@@ -267,41 +238,33 @@
auto& res = *resources;
ASSERT_EQ(res.GetTargetToOverlayMap().size(), 11U);
ASSERT_RESULT(MappingExists(res, R::target::string::not_overlayable,
- R::system_overlay_invalid::string::not_overlayable,
- false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::other,
- R::system_overlay_invalid::string::other, false /* rewrite */));
+ R::overlay::string::not_overlayable, true /* rewrite */));
+ ASSERT_RESULT(
+ MappingExists(res, R::target::string::other, R::overlay::string::other, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_actor,
- R::system_overlay_invalid::string::policy_actor,
- false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm,
- R::system_overlay_invalid::string::policy_odm, false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem,
- R::system_overlay_invalid::string::policy_oem, false /* rewrite */));
+ R::overlay::string::policy_actor, true /* rewrite */));
+ ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm, R::overlay::string::policy_odm,
+ true /* rewrite */));
+ ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem, R::overlay::string::policy_oem,
+ true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_product,
- R::system_overlay_invalid::string::policy_product,
- false /* rewrite */));
+ R::overlay::string::policy_product, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
- R::system_overlay_invalid::string::policy_public,
- false /* rewrite */));
+ R::overlay::string::policy_public, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_config_signature,
- R::system_overlay_invalid::string::policy_config_signature,
- false /* rewrite */));
+ R::overlay::string::policy_config_signature, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_signature,
- R::system_overlay_invalid::string::policy_signature,
- false /* rewrite */));
+ R::overlay::string::policy_signature, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
- R::system_overlay_invalid::string::policy_system,
- false /* rewrite */));
+ R::overlay::string::policy_system, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
- R::system_overlay_invalid::string::policy_system_vendor,
- false /* rewrite */));
+ R::overlay::string::policy_system_vendor, true /* rewrite */));
}
-// Overlays that do not target an <overlayable> tag can overlay resources defined within any
-// <overlayable> tag.
+// Overlays that do not target an <overlayable> tag can overlay any resource if overlayable
+// enforcement is disabled.
TEST(ResourceMappingTests, ResourcesFromApkAssetsNoDefinedOverlayableAndNoTargetName) {
- auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay-no-name.apk",
+ auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay-legacy.apk", "",
PolicyFlags::PUBLIC,
/* enforce_overlayable */ false);
@@ -321,9 +284,10 @@
// Overlays that are neither pre-installed nor signed with the same signature as the target cannot
// overlay packages that have not defined overlayable resources.
TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPoliciesPublicFail) {
- auto resources = TestGetResourceMapping("/target/target-no-overlayable.apk",
- "/overlay/overlay-no-name.apk", PolicyFlags::PUBLIC,
- /* enforce_overlayable */ true);
+ auto resources =
+ TestGetResourceMapping("/target/target-no-overlayable.apk", "/overlay/overlay.apk",
+ "NoTargetName", PolicyFlags::PUBLIC,
+ /* enforce_overlayable */ true);
ASSERT_TRUE(resources) << resources.GetErrorMessage();
ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 0U);
@@ -334,46 +298,36 @@
// defined overlayable resources.
TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPolicies) {
auto CheckEntries = [&](const PolicyBitmask& fulfilled_policies) -> void {
- auto resources = TestGetResourceMapping("/target/target-no-overlayable.apk",
- "/system-overlay-invalid/system-overlay-invalid.apk",
- fulfilled_policies,
- /* enforce_overlayable */ true);
+ auto resources =
+ TestGetResourceMapping("/target/target-no-overlayable.apk", "/overlay/overlay.apk",
+ TestConstants::OVERLAY_NAME_ALL_POLICIES, fulfilled_policies,
+ /* enforce_overlayable */ true);
ASSERT_TRUE(resources) << resources.GetErrorMessage();
auto& res = *resources;
ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 11U);
ASSERT_RESULT(MappingExists(res, R::target::string::not_overlayable,
- R::system_overlay_invalid::string::not_overlayable,
- false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::other,
- R::system_overlay_invalid::string::other, false /* rewrite */));
+ R::overlay::string::not_overlayable, true /* rewrite */));
+ ASSERT_RESULT(MappingExists(res, R::target::string::other, R::overlay::string::other,
+ true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_actor,
- R::system_overlay_invalid::string::policy_actor,
- false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm,
- R::system_overlay_invalid::string::policy_odm,
- false /* rewrite */));
- ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem,
- R::system_overlay_invalid::string::policy_oem,
- false /* rewrite */));
+ R::overlay::string::policy_actor, true /* rewrite */));
+ ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm, R::overlay::string::policy_odm,
+ true /* rewrite */));
+ ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem, R::overlay::string::policy_oem,
+ true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_product,
- R::system_overlay_invalid::string::policy_product,
- false /* rewrite */));
+ R::overlay::string::policy_product, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
- R::system_overlay_invalid::string::policy_public,
- false /* rewrite */));
+ R::overlay::string::policy_public, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_config_signature,
- R::system_overlay_invalid::string::policy_config_signature,
- false /* rewrite */));
+ R::overlay::string::policy_config_signature, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_signature,
- R::system_overlay_invalid::string::policy_signature,
- false /* rewrite */));
+ R::overlay::string::policy_signature, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
- R::system_overlay_invalid::string::policy_system,
- false /* rewrite */));
+ R::overlay::string::policy_system, true /* rewrite */));
ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
- R::system_overlay_invalid::string::policy_system_vendor,
- false /* rewrite */));
+ R::overlay::string::policy_system_vendor, true /* rewrite */));
};
CheckEntries(PolicyFlags::SIGNATURE);
diff --git a/cmds/idmap2/tests/TestConstants.h b/cmds/idmap2/tests/TestConstants.h
index 69575b8..d5799ad 100644
--- a/cmds/idmap2/tests/TestConstants.h
+++ b/cmds/idmap2/tests/TestConstants.h
@@ -22,8 +22,11 @@
constexpr const auto TARGET_CRC = 0x7c2d4719;
constexpr const auto TARGET_CRC_STRING = "7c2d4719";
-constexpr const auto OVERLAY_CRC = 0x5afff726;
-constexpr const auto OVERLAY_CRC_STRING = "5afff726";
+constexpr const auto OVERLAY_CRC = 0xb71095cf;
+constexpr const auto OVERLAY_CRC_STRING = "b71095cf";
+
+constexpr const char* OVERLAY_NAME_DEFAULT = "Default";
+constexpr const char* OVERLAY_NAME_ALL_POLICIES = "AllPolicies";
} // namespace android::idmap2::TestConstants
diff --git a/cmds/idmap2/tests/TestHelpers.h b/cmds/idmap2/tests/TestHelpers.h
index 5c934a3..842af3d 100644
--- a/cmds/idmap2/tests/TestHelpers.h
+++ b/cmds/idmap2/tests/TestHelpers.h
@@ -30,7 +30,7 @@
0x49, 0x44, 0x4d, 0x50,
// 0x4: version
- 0x06, 0x00, 0x00, 0x00,
+ 0x07, 0x00, 0x00, 0x00,
// 0x8: target crc
0x34, 0x12, 0x00, 0x00,
@@ -56,95 +56,102 @@
// 0x2c: overlay path "overlayX.apk"
0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x58, 0x2e, 0x61, 0x70, 0x6b,
- // 0x38: debug string
+ // 0x38: overlay name length
+ 0x0b, 0x00, 0x00, 0x00,
+
+ // 0x3c: overlay name "OverlayName"
+ 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6D, 0x65, 0x00,
+
+ // 0x48 -> 4c: debug string
// string length,
0x05, 0x00, 0x00, 0x00,
- // 0x3c string contents "debug\0\0\0" (padded to word alignment)
+ // 0x4c string contents "debug\0\0\0" (padded to word alignment)
0x64, 0x65, 0x62, 0x75, 0x67, 0x00, 0x00, 0x00,
// DATA HEADER
- // 0x44: target_package_id
+ // 0x54: target_package_id
0x7f,
- // 0x45: overlay_package_id
+ // 0x55: overlay_package_id
0x7f,
- // 0x46: padding
+ // 0x56: padding
0x00, 0x00,
- // 0x48: target_entry_count
+ // 0x58: target_entry_count
0x03, 0x00, 0x00, 0x00,
- // 0x4c: target_inline_entry_count
+ // 0x5c: target_inline_entry_count
0x01, 0x00, 0x00, 0x00,
- // 0x50: overlay_entry_count
+ // 0x60: overlay_entry_count
0x03, 0x00, 0x00, 0x00,
- // 0x54: string_pool_offset
+ // 0x64: string_pool_offset
0x00, 0x00, 0x00, 0x00,
// TARGET ENTRIES
- // 0x58: target id (0x7f020000)
+ // 0x68: target id (0x7f020000)
0x00, 0x00, 0x02, 0x7f,
- // 0x5c: overlay_id (0x7f020000)
+ // 0x6c: overlay_id (0x7f020000)
0x00, 0x00, 0x02, 0x7f,
- // 0x60: target id (0x7f030000)
+ // 0x70: target id (0x7f030000)
0x00, 0x00, 0x03, 0x7f,
- // 0x64: overlay_id (0x7f030000)
+ // 0x74: overlay_id (0x7f030000)
0x00, 0x00, 0x03, 0x7f,
- // 0x68: target id (0x7f030002)
+ // 0x78: target id (0x7f030002)
0x02, 0x00, 0x03, 0x7f,
- // 0x6c: overlay_id (0x7f030001)
+ // 0x7c: overlay_id (0x7f030001)
0x01, 0x00, 0x03, 0x7f,
// INLINE TARGET ENTRIES
- // 0x70: target_id
+ // 0x80: target_id
0x00, 0x00, 0x04, 0x7f,
- // 0x74: Res_value::size (value ignored by idmap)
+ // 0x84: Res_value::size (value ignored by idmap)
0x08, 0x00,
- // 0x77: Res_value::res0 (value ignored by idmap)
+ // 0x87: Res_value::res0 (value ignored by idmap)
0x00,
- // 0x78: Res_value::dataType (TYPE_INT_HEX)
+ // 0x88: Res_value::dataType (TYPE_INT_HEX)
0x11,
- // 0x7c: Res_value::data
+ // 0x8c: Res_value::data
0x78, 0x56, 0x34, 0x12,
// OVERLAY ENTRIES
- // 0x80: 0x7f020000 -> 0x7f020000
+ // 0x90: 0x7f020000 -> 0x7f020000
0x00, 0x00, 0x02, 0x7f, 0x00, 0x00, 0x02, 0x7f,
- // 0x88: 0x7f030000 -> 0x7f030000
+ // 0x98: 0x7f030000 -> 0x7f030000
0x00, 0x00, 0x03, 0x7f, 0x00, 0x00, 0x03, 0x7f,
- // 0x90: 0x7f030001 -> 0x7f030002
+ // 0xa0: 0x7f030001 -> 0x7f030002
0x01, 0x00, 0x03, 0x7f, 0x02, 0x00, 0x03, 0x7f,
- // 0x94: string pool
+ // 0xa4: string pool
// string length,
0x04, 0x00, 0x00, 0x00,
- // 0x98 string contents "test"
+ // 0xa8 string contents "test"
0x74, 0x65, 0x73, 0x74};
-const unsigned int idmap_raw_data_len = 0x9c;
-const unsigned int idmap_raw_data_offset = 0x44;
-const unsigned int idmap_raw_data_target_crc = 0x1234;
-const unsigned int idmap_raw_data_overlay_crc = 0x5678;
-const unsigned int idmap_raw_data_policies = 0x11;
-inline const std::string idmap_raw_data_target_path = "targetX.apk";
-inline const std::string idmap_raw_data_overlay_path = "overlayX.apk";
+const unsigned int kIdmapRawDataLen = 0xac;
+const unsigned int kIdmapRawDataOffset = 0x54;
+const unsigned int kIdmapRawDataTargetCrc = 0x1234;
+const unsigned int kIdmapRawOverlayCrc = 0x5678;
+const unsigned int kIdmapRawDataPolicies = 0x11;
+inline const std::string kIdmapRawTargetPath = "targetX.apk";
+inline const std::string kIdmapRawOverlayPath = "overlayX.apk";
+inline const std::string kIdmapRawOverlayName = "OverlayName";
std::string GetTestDataPath();
diff --git a/cmds/idmap2/tests/data/overlay/AndroidManifest.xml b/cmds/idmap2/tests/data/overlay/AndroidManifest.xml
index cf3691c..2c50dee 100644
--- a/cmds/idmap2/tests/data/overlay/AndroidManifest.xml
+++ b/cmds/idmap2/tests/data/overlay/AndroidManifest.xml
@@ -13,14 +13,37 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay">
-
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="test.overlay">
<application android:hasCode="false"/>
- <overlay
- android:targetPackage="test.target"
- android:targetName="TestResources"
- android:resourcesMap="@xml/overlays"/>
+ <overlay android:name="Default"
+ android:targetPackage="test.target"
+ android:targetName="TestResources"
+ android:resourcesMap="@xml/overlays"/>
+
+ <overlay android:name="NoTargetName"
+ android:targetPackage="test.target"
+ android:resourcesMap="@xml/overlays"/>
+
+ <overlay android:name="Inline"
+ android:targetName="TestResources"
+ android:targetPackage="test.target"
+ android:resourcesMap="@xml/overlays_inline"/>
+
+ <overlay android:name="DifferentPackages"
+ android:targetName="TestResources"
+ android:targetPackage="test.target"
+ android:resourcesMap="@xml/overlays_different_package"/>
+
+ <overlay android:name="SwapNames"
+ android:targetName="TestResources"
+ android:targetPackage="test.target"
+ android:resourcesMap="@xml/overlays_swap"/>
+
+ <overlay android:name="AllPolicies"
+ android:targetName="TestResources"
+ android:targetPackage="test.target"
+ android:resourcesMap="@xml/overlays_policies"/>
+
</manifest>
diff --git a/cmds/idmap2/tests/data/overlay/AndroidManifestStatic1.xml b/cmds/idmap2/tests/data/overlay/AndroidManifestLegacy.xml
similarity index 71%
rename from cmds/idmap2/tests/data/overlay/AndroidManifestStatic1.xml
rename to cmds/idmap2/tests/data/overlay/AndroidManifestLegacy.xml
index 1c4dae6..9fc2105 100644
--- a/cmds/idmap2/tests/data/overlay/AndroidManifestStatic1.xml
+++ b/cmds/idmap2/tests/data/overlay/AndroidManifestLegacy.xml
@@ -13,12 +13,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay.static1">
- <overlay
- android:targetPackage="test.target"
- android:targetName="TestResources"
- android:isStatic="true"
- android:priority="1" />
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="test.overlay">
+ <application android:hasCode="false"/>
+
+ <overlay android:targetPackage="test.target"/>
</manifest>
diff --git a/cmds/idmap2/tests/data/overlay/AndroidManifestNoName.xml b/cmds/idmap2/tests/data/overlay/AndroidManifestNoName.xml
deleted file mode 100644
index bc6b733..0000000
--- a/cmds/idmap2/tests/data/overlay/AndroidManifestNoName.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay.no.name">
- <overlay
- android:targetPackage="test.target"/>
-</manifest>
diff --git a/cmds/idmap2/tests/data/overlay/AndroidManifestNoNameStatic.xml b/cmds/idmap2/tests/data/overlay/AndroidManifestNoNameStatic.xml
deleted file mode 100644
index ed327ce..0000000
--- a/cmds/idmap2/tests/data/overlay/AndroidManifestNoNameStatic.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay.no.name.static">
- <overlay
- android:targetPackage="test.target"
- android:targetName="TestResources"
- android:isStatic="true"
- android:priority="1" />
-</manifest>
diff --git a/cmds/idmap2/tests/data/overlay/AndroidManifestStatic2.xml b/cmds/idmap2/tests/data/overlay/AndroidManifestStatic2.xml
deleted file mode 100644
index 70efc86..0000000
--- a/cmds/idmap2/tests/data/overlay/AndroidManifestStatic2.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay.static2">
- <overlay
- android:targetPackage="test.target"
- android:targetName="TestResources"
- android:isStatic="true"
- android:priority="2" />
-</manifest>
diff --git a/cmds/idmap2/tests/data/overlay/build b/cmds/idmap2/tests/data/overlay/build
index 114b099..1f1cedb0 100755
--- a/cmds/idmap2/tests/data/overlay/build
+++ b/cmds/idmap2/tests/data/overlay/build
@@ -26,37 +26,16 @@
aapt2 link \
--no-resource-removal \
-I "$FRAMEWORK_RES_APK" \
- --manifest AndroidManifestNoName.xml \
- -o overlay-no-name.apk \
- compiled.flata
-
-aapt2 link \
- --no-resource-removal \
- -I "$FRAMEWORK_RES_APK" \
- --manifest AndroidManifestNoNameStatic.xml \
- -o overlay-no-name-static.apk \
- compiled.flata
-
-aapt2 link \
- --no-resource-removal \
- -I "$FRAMEWORK_RES_APK" \
- --manifest AndroidManifestStatic1.xml \
- -o overlay-static-1.apk \
- compiled.flata
-
-aapt2 link \
- --no-resource-removal \
- -I "$FRAMEWORK_RES_APK" \
- --manifest AndroidManifestStatic2.xml \
- -o overlay-static-2.apk \
- compiled.flata
-
-aapt2 link \
- --no-resource-removal \
- --shared-lib \
- -I "$FRAMEWORK_RES_APK" \
--manifest AndroidManifest.xml \
-o overlay-shared.apk \
+ --shared-lib \
+ compiled.flata
+
+aapt2 link \
+ --no-resource-removal \
+ -I "$FRAMEWORK_RES_APK" \
+ --manifest AndroidManifestLegacy.xml \
+ -o overlay-legacy.apk \
compiled.flata
rm compiled.flata
diff --git a/cmds/idmap2/tests/data/overlay/overlay-legacy.apk b/cmds/idmap2/tests/data/overlay/overlay-legacy.apk
new file mode 100644
index 0000000..f03eebb
--- /dev/null
+++ b/cmds/idmap2/tests/data/overlay/overlay-legacy.apk
Binary files differ
diff --git a/cmds/idmap2/tests/data/overlay/overlay-no-name-static.apk b/cmds/idmap2/tests/data/overlay/overlay-no-name-static.apk
deleted file mode 100644
index dab25b1..0000000
--- a/cmds/idmap2/tests/data/overlay/overlay-no-name-static.apk
+++ /dev/null
Binary files differ
diff --git a/cmds/idmap2/tests/data/overlay/overlay-no-name.apk b/cmds/idmap2/tests/data/overlay/overlay-no-name.apk
deleted file mode 100644
index c8b95c2..0000000
--- a/cmds/idmap2/tests/data/overlay/overlay-no-name.apk
+++ /dev/null
Binary files differ
diff --git a/cmds/idmap2/tests/data/overlay/overlay-shared.apk b/cmds/idmap2/tests/data/overlay/overlay-shared.apk
index 0a8b737..3c896ea7 100644
--- a/cmds/idmap2/tests/data/overlay/overlay-shared.apk
+++ b/cmds/idmap2/tests/data/overlay/overlay-shared.apk
Binary files differ
diff --git a/cmds/idmap2/tests/data/overlay/overlay-static-1.apk b/cmds/idmap2/tests/data/overlay/overlay-static-1.apk
deleted file mode 100644
index fd41182..0000000
--- a/cmds/idmap2/tests/data/overlay/overlay-static-1.apk
+++ /dev/null
Binary files differ
diff --git a/cmds/idmap2/tests/data/overlay/overlay-static-2.apk b/cmds/idmap2/tests/data/overlay/overlay-static-2.apk
deleted file mode 100644
index b24765f..0000000
--- a/cmds/idmap2/tests/data/overlay/overlay-static-2.apk
+++ /dev/null
Binary files differ
diff --git a/cmds/idmap2/tests/data/overlay/overlay.apk b/cmds/idmap2/tests/data/overlay/overlay.apk
index 870575e..c7ea623 100644
--- a/cmds/idmap2/tests/data/overlay/overlay.apk
+++ b/cmds/idmap2/tests/data/overlay/overlay.apk
Binary files differ
diff --git a/cmds/idmap2/tests/data/overlay/res/values/values.xml b/cmds/idmap2/tests/data/overlay/res/values/values.xml
index 815d1a8..6e98b21 100644
--- a/cmds/idmap2/tests/data/overlay/res/values/values.xml
+++ b/cmds/idmap2/tests/data/overlay/res/values/values.xml
@@ -18,4 +18,25 @@
<string name="str3">overlay-3</string>
<integer name="int1">-1</integer>
<integer name="not_in_target">-1</integer>
+
+ <!-- This overlay will fulfill the policies "public|system". This allows it overlay the
+ following resources. -->
+ <string name="overlay_policy_system">overlaid</string>
+ <string name="overlay_policy_system_vendor">overlaid</string>
+ <string name="overlay_policy_public">overlaid</string>
+
+ <!-- Requests to overlay a resource that belongs to a policy the overlay does not fulfill. -->
+ <string name="overlay_policy_product">overlaid</string>
+ <string name="overlay_policy_signature">overlaid</string>
+ <string name="overlay_policy_odm">overlaid</string>
+ <string name="overlay_policy_oem">overlaid</string>
+ <string name="overlay_policy_actor">overlaid</string>
+ <string name="overlay_policy_config_signature">overlaid</string>
+
+ <!-- Requests to overlay a resource that is not declared as overlayable. -->
+ <string name="overlay_not_overlayable">overlaid</string>
+
+ <!-- Requests to overlay a resource that is defined in an overlayable with a name other than
+ the targetName in the manifest. -->
+ <string name="overlay_other">overlaid</string>
</resources>
diff --git a/cmds/idmap2/tests/data/overlay/res/xml/overlays_policies.xml b/cmds/idmap2/tests/data/overlay/res/xml/overlays_policies.xml
new file mode 100644
index 0000000..747f448
--- /dev/null
+++ b/cmds/idmap2/tests/data/overlay/res/xml/overlays_policies.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<overlay>
+ <item target="string/policy_system" value="@string/overlay_policy_system"/>
+ <item target="string/policy_system_vendor" value="@string/overlay_policy_system_vendor" />
+ <item target="string/policy_public" value="@string/overlay_policy_public" />
+ <item target="string/policy_product" value="@string/overlay_policy_product"/>
+ <item target="string/policy_signature" value="@string/overlay_policy_signature" />
+ <item target="string/policy_odm" value="@string/overlay_policy_odm" />
+ <item target="string/policy_oem" value="@string/overlay_policy_oem"/>
+ <item target="string/policy_actor" value="@string/overlay_policy_actor" />
+ <item target="string/policy_config_signature" value="@string/overlay_policy_config_signature" />
+
+ <!-- Requests to overlay a resource that is not declared as overlayable. -->
+ <item target="string/not_overlayable" value="@string/overlay_not_overlayable" />
+
+ <!-- Requests to overlay a resource that is defined in an overlayable with a name other than
+ the targetName in the manifest. -->
+ <item target="string/other" value="@string/overlay_other" />
+</overlay>
\ No newline at end of file
diff --git a/cmds/idmap2/tests/data/signature-overlay/AndroidManifest.xml b/cmds/idmap2/tests/data/signature-overlay/AndroidManifest.xml
deleted file mode 100644
index 5df0bea..0000000
--- a/cmds/idmap2/tests/data/signature-overlay/AndroidManifest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay.system">
- <application android:hasCode="false"/>
- <overlay
- android:targetPackage="test.target"
- android:targetName="TestResources"
- android:isStatic="true"
- android:priority="10"/>
-</manifest>
diff --git a/cmds/idmap2/tests/data/signature-overlay/build b/cmds/idmap2/tests/data/signature-overlay/build
deleted file mode 100755
index fdd8301..0000000
--- a/cmds/idmap2/tests/data/signature-overlay/build
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FRAMEWORK_RES_APK=${ANDROID_BUILD_TOP}/prebuilts/sdk/current/public/android.jar
-
-aapt2 compile --dir res -o compiled.flata
-
-aapt2 link \
- --no-resource-removal \
- -I "$FRAMEWORK_RES_APK" \
- --manifest AndroidManifest.xml \
- -o signature-overlay.apk \
- compiled.flata
-
-rm compiled.flata
diff --git a/cmds/idmap2/tests/data/signature-overlay/res/values/values.xml b/cmds/idmap2/tests/data/signature-overlay/res/values/values.xml
deleted file mode 100644
index 59e7d8e..0000000
--- a/cmds/idmap2/tests/data/signature-overlay/res/values/values.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <!-- This overlay will fulfill the policy "signature". This allows it overlay the
- following resources. -->
- <string name="policy_signature">policy_signature</string>
-</resources>
diff --git a/cmds/idmap2/tests/data/signature-overlay/signature-overlay.apk b/cmds/idmap2/tests/data/signature-overlay/signature-overlay.apk
deleted file mode 100644
index e0fd204..0000000
--- a/cmds/idmap2/tests/data/signature-overlay/signature-overlay.apk
+++ /dev/null
Binary files differ
diff --git a/cmds/idmap2/tests/data/system-overlay-invalid/AndroidManifest.xml b/cmds/idmap2/tests/data/system-overlay-invalid/AndroidManifest.xml
deleted file mode 100644
index c7b652c..0000000
--- a/cmds/idmap2/tests/data/system-overlay-invalid/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay.system.invalid">
- <application android:hasCode="false"/>
- <overlay
- android:targetPackage="test.target"
- android:targetName="TestResources"/>
-</manifest>
diff --git a/cmds/idmap2/tests/data/system-overlay-invalid/build b/cmds/idmap2/tests/data/system-overlay-invalid/build
deleted file mode 100755
index 920e1f8..0000000
--- a/cmds/idmap2/tests/data/system-overlay-invalid/build
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FRAMEWORK_RES_APK=${ANDROID_BUILD_TOP}/prebuilts/sdk/current/public/android.jar
-
-aapt2 compile --dir res -o compiled.flata
-
-aapt2 link \
- --no-resource-removal \
- -I "$FRAMEWORK_RES_APK" \
- --manifest AndroidManifest.xml \
- -o system-overlay-invalid.apk \
- compiled.flata
-
-rm compiled.flata
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
deleted file mode 100644
index ebaf49c..0000000
--- a/cmds/idmap2/tests/data/system-overlay-invalid/res/values/values.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <!-- This overlay will fulfill the policies "public|system". This allows it overlay the
- following resources. -->
- <string name="policy_system">policy_system</string>
- <string name="policy_system_vendor">policy_system_vendor</string>
- <string name="policy_public">policy_public</string>
-
- <!-- 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>
- <string name="policy_actor">policy_actor</string>
- <string name="policy_config_signature">policy_config_signature</string>
-
- <!-- Requests to overlay a resource that is not declared as overlayable. -->
- <string name="not_overlayable">not_overlayable</string>
-
- <!-- Requests to overlay a resource that is defined in an overlayable with a name other than
- the targetName in the manifest. -->
- <string name="other">other</string>
-</resources>
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
deleted file mode 100644
index a63daf8..0000000
--- a/cmds/idmap2/tests/data/system-overlay-invalid/system-overlay-invalid.apk
+++ /dev/null
Binary files differ
diff --git a/cmds/idmap2/tests/data/system-overlay/AndroidManifest.xml b/cmds/idmap2/tests/data/system-overlay/AndroidManifest.xml
deleted file mode 100644
index 9e6a453..0000000
--- a/cmds/idmap2/tests/data/system-overlay/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.overlay.system">
- <application android:hasCode="false"/>
- <overlay
- android:targetPackage="test.target"
- android:targetName="TestResources"/>
-</manifest>
diff --git a/cmds/idmap2/tests/data/system-overlay/build b/cmds/idmap2/tests/data/system-overlay/build
deleted file mode 100755
index be0d239..0000000
--- a/cmds/idmap2/tests/data/system-overlay/build
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FRAMEWORK_RES_APK=${ANDROID_BUILD_TOP}/prebuilts/sdk/current/public/android.jar
-
-aapt2 compile --dir res -o compiled.flata
-
-aapt2 link \
- --no-resource-removal \
- -I "$FRAMEWORK_RES_APK" \
- --manifest AndroidManifest.xml \
- -o system-overlay.apk \
- compiled.flata
-
-rm compiled.flata
diff --git a/cmds/idmap2/tests/data/system-overlay/res/values/values.xml b/cmds/idmap2/tests/data/system-overlay/res/values/values.xml
deleted file mode 100644
index 6aaa0b0..0000000
--- a/cmds/idmap2/tests/data/system-overlay/res/values/values.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <!-- This overlay will fulfill the policies "public|system". This allows it overlay the
- following resources. -->
- <string name="policy_system">policy_system</string>
- <string name="policy_system_vendor">policy_system_vendor</string>
- <string name="policy_public">policy_public</string>
-</resources>
diff --git a/cmds/idmap2/tests/data/system-overlay/system-overlay.apk b/cmds/idmap2/tests/data/system-overlay/system-overlay.apk
deleted file mode 100644
index 90d2803..0000000
--- a/cmds/idmap2/tests/data/system-overlay/system-overlay.apk
+++ /dev/null
Binary files differ