summaryrefslogtreecommitdiff
path: root/cmds/idmap2
diff options
context:
space:
mode:
author Ryan Mitchell <rtmitchell@google.com> 2019-07-01 09:48:23 -0700
committer Ryan Mitchell <rtmitchell@google.com> 2019-10-17 13:09:33 -0700
commit8a891d86abdf35b6703785fb3368b39510e91357 (patch)
treea58684aba049e9345ad0c1cf23f2bc4593a9892c /cmds/idmap2
parente753ffef5499bc0150827a06d44b50abe78b36dd (diff)
Allow for RRO internal referencing
This change allows RROs to reference their own internal resources as expected. Overlays are loaded as shared libraries so they can have their own resource id space that does not conflict with the resource id space of the target or other overlays. References to overlay resources that override target resources now appear as references to the target resources. Overlay values that are inlined into the xml file specified using android:overlayResources are now able to be used at runtime. See go/rro-references for more information. Bug: 135943783 Test: idmap2_tests Test: libandroidfw_tests Change-Id: Ie349c56d7fd3f7d94b7d595ed6d01dc6b59b6178
Diffstat (limited to 'cmds/idmap2')
-rw-r--r--cmds/idmap2/tests/BinaryStreamVisitorTests.cpp4
-rw-r--r--cmds/idmap2/tests/Idmap2BinaryTests.cpp49
-rw-r--r--cmds/idmap2/tests/IdmapTests.cpp4
-rw-r--r--cmds/idmap2/tests/RawPrintVisitorTests.cpp2
4 files changed, 51 insertions, 8 deletions
diff --git a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
index 3a01e8fca70b..db4778c8ee09 100644
--- a/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
+++ b/cmds/idmap2/tests/BinaryStreamVisitorTests.cpp
@@ -88,8 +88,4 @@ TEST(BinaryStreamVisitorTests, CreateBinaryStreamViaBinaryStreamVisitor) {
ASSERT_EQ(overlay_entries1[2].target_id, overlay_entries2[2].target_id);
}
-TEST(BinaryStreamVisitorTests, CreateIdmapFromApkAssetsInteropWithLoadedIdmap) {
- // TODO(135943783): Removed temporarily until libandroidfw idmap loading is fixed.
-}
-
} // namespace android::idmap2
diff --git a/cmds/idmap2/tests/Idmap2BinaryTests.cpp b/cmds/idmap2/tests/Idmap2BinaryTests.cpp
index b1685b7f1312..b535f30de1f5 100644
--- a/cmds/idmap2/tests/Idmap2BinaryTests.cpp
+++ b/cmds/idmap2/tests/Idmap2BinaryTests.cpp
@@ -280,7 +280,54 @@ TEST_F(Idmap2BinaryTests, Scan) {
}
TEST_F(Idmap2BinaryTests, Lookup) {
- // TODO(135943783): Removed temporarily until libandroidfw idmap loading is fixed.
+ SKIP_TEST_IF_CANT_EXEC_IDMAP2;
+
+ // clang-format off
+ auto result = ExecuteBinary({"idmap2",
+ "create",
+ "--target-apk-path", GetTargetApkPath(),
+ "--overlay-apk-path", GetOverlayApkPath(),
+ "--idmap-path", GetIdmapPath()});
+ // clang-format on
+ ASSERT_THAT(result, NotNull());
+ ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
+
+ // clang-format off
+ result = ExecuteBinary({"idmap2",
+ "lookup",
+ "--idmap-path", GetIdmapPath(),
+ "--config", "",
+ "--resid", "0x7f02000c"}); // string/str1
+ // clang-format on
+ ASSERT_THAT(result, NotNull());
+ ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
+ ASSERT_NE(result->stdout.find("overlay-1"), std::string::npos);
+ ASSERT_EQ(result->stdout.find("overlay-1-sv"), std::string::npos);
+
+ // clang-format off
+ result = ExecuteBinary({"idmap2",
+ "lookup",
+ "--idmap-path", GetIdmapPath(),
+ "--config", "",
+ "--resid", "test.target:string/str1"});
+ // clang-format on
+ ASSERT_THAT(result, NotNull());
+ ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
+ ASSERT_NE(result->stdout.find("overlay-1"), std::string::npos);
+ ASSERT_EQ(result->stdout.find("overlay-1-sv"), std::string::npos);
+
+ // clang-format off
+ result = ExecuteBinary({"idmap2",
+ "lookup",
+ "--idmap-path", GetIdmapPath(),
+ "--config", "sv",
+ "--resid", "test.target:string/str1"});
+ // clang-format on
+ ASSERT_THAT(result, NotNull());
+ ASSERT_EQ(result->status, EXIT_SUCCESS) << result->stderr;
+ ASSERT_NE(result->stdout.find("overlay-1-sv"), std::string::npos);
+
+ unlink(GetIdmapPath().c_str());
}
TEST_F(Idmap2BinaryTests, InvalidCommandLineOptions) {
diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp
index 30b1372005db..cd816ddea814 100644
--- a/cmds/idmap2/tests/IdmapTests.cpp
+++ b/cmds/idmap2/tests/IdmapTests.cpp
@@ -248,7 +248,7 @@ TEST(IdmapTests, CreateIdmapDataDoNotRewriteNonOverlayResourceId) {
OverlayManifestInfo info{};
info.target_package = "test.target";
info.target_name = "TestResources";
- info.resource_mapping = 0x7f030002; // xml/overlays_different_packages
+ info.resource_mapping = 0x7f030001; // xml/overlays_different_packages
auto idmap_data = TestIdmapDataFromApkAssets("/target/target.apk", "/overlay/overlay.apk", info,
PolicyFlags::POLICY_PUBLIC,
/* enforce_overlayable */ false);
@@ -272,7 +272,7 @@ TEST(IdmapTests, CreateIdmapDataInlineResources) {
OverlayManifestInfo info{};
info.target_package = "test.target";
info.target_name = "TestResources";
- info.resource_mapping = 0x7f030000; // xml/overlays_inline
+ info.resource_mapping = 0x7f030002; // xml/overlays_inline
auto idmap_data = TestIdmapDataFromApkAssets("/target/target.apk", "/overlay/overlay.apk", info,
PolicyFlags::POLICY_PUBLIC,
/* enforce_overlayable */ false);
diff --git a/cmds/idmap2/tests/RawPrintVisitorTests.cpp b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
index 24f9845df87b..d387880cb771 100644
--- a/cmds/idmap2/tests/RawPrintVisitorTests.cpp
+++ b/cmds/idmap2/tests/RawPrintVisitorTests.cpp
@@ -49,7 +49,7 @@ TEST(RawPrintVisitorTests, CreateRawPrintVisitor) {
ASSERT_NE(stream.str().find("00000000: 504d4449 magic\n"), std::string::npos);
ASSERT_NE(stream.str().find("00000004: 00000002 version\n"), std::string::npos);
ASSERT_NE(stream.str().find("00000008: 76a20829 target crc\n"), std::string::npos);
- ASSERT_NE(stream.str().find("0000000c: e3c188b6 overlay crc\n"), std::string::npos);
+ ASSERT_NE(stream.str().find("0000000c: c054fb26 overlay crc\n"), std::string::npos);
ASSERT_NE(stream.str().find("00000210: 7f target package id\n"), std::string::npos);
ASSERT_NE(stream.str().find("00000211: 7f overlay package id\n"), std::string::npos);
ASSERT_NE(stream.str().find("00000212: 00000004 target entry count\n"), std::string::npos);