Loading cmds/idmap2/tests/FabricatedOverlayTests.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ TEST(FabricatedOverlayTests, SerializeAndDeserialize) { "com.example.target:string/string1", Res_value::TYPE_STRING, "foobar", "") .Build(); ASSERT_TRUE(overlay); TemporaryFile tf; TempFrroFile tf; std::ofstream out(tf.path); ASSERT_TRUE((*overlay).ToBinaryStream(out)); out.close(); Loading cmds/idmap2/tests/IdmapTests.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -274,7 +274,7 @@ TEST(IdmapTests, FabricatedOverlay) { .Build(); ASSERT_TRUE(frro); TemporaryFile tf; TempFrroFile tf; std::ofstream out(tf.path); ASSERT_TRUE((*frro).ToBinaryStream(out)); out.close(); Loading Loading @@ -467,9 +467,9 @@ TEST(IdmapTests, CreateIdmapDataInlineResources) { TEST(IdmapTests, IdmapHeaderIsUpToDate) { fclose(stderr); // silence expected warnings from libandroidfw const std::string target_apk_path = kIdmapRawTargetPath; const std::string overlay_apk_path = kIdmapRawOverlayPath; const std::string overlay_name = kIdmapRawOverlayName; 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; Loading cmds/idmap2/tests/ResourceMappingTests.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ TEST(ResourceMappingTests, FabricatedOverlay) { .Build(); ASSERT_TRUE(frro); TemporaryFile tf; TempFrroFile tf; std::ofstream out(tf.path); ASSERT_TRUE((*frro).ToBinaryStream(out)); out.close(); Loading cmds/idmap2/tests/TestHelpers.h +18 −3 Original line number Diff line number Diff line Loading @@ -17,11 +17,15 @@ #ifndef IDMAP2_TESTS_TESTHELPERS_H_ #define IDMAP2_TESTS_TESTHELPERS_H_ #include <stdio.h> #include <string> #include <string_view> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "android-base/file.h" namespace android::idmap2 { const unsigned char kIdmapRawData[] = { Loading Loading @@ -197,12 +201,23 @@ 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"; inline const std::string_view kIdmapRawTargetPath = "targetX.apk"; inline const std::string_view kIdmapRawOverlayPath = "overlayX.apk"; inline const std::string_view kIdmapRawOverlayName = "OverlayName"; std::string GetTestDataPath(); class TempFrroFile : public TemporaryFile { public: TempFrroFile() { std::string new_path = path; new_path += ".frro"; ::rename(path, new_path.c_str()); const auto new_len = new_path.copy(path, sizeof(path) - 1); path[new_len] = '\0'; } }; class Idmap2Tests : public testing::Test { protected: void SetUp() override { Loading libs/androidfw/ApkAssets.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ ApkAssetsPtr ApkAssets::LoadOverlay(const std::string& idmap_path, package_prope std::string overlay_path(loaded_idmap->OverlayApkPath()); auto fd = unique_fd(base::utf8::open(overlay_path.c_str(), O_RDONLY | O_CLOEXEC)); std::unique_ptr<AssetsProvider> overlay_assets; if (IsFabricatedOverlay(fd)) { if (IsFabricatedOverlayName(overlay_path) && IsFabricatedOverlay(fd)) { // Fabricated overlays do not contain resource definitions. All of the overlay resource values // are defined inline in the idmap. overlay_assets = EmptyAssetsProvider::Create(std::move(overlay_path)); Loading Loading @@ -137,8 +137,7 @@ ApkAssetsPtr ApkAssets::LoadImpl(std::unique_ptr<Asset> resources_asset, return {}; } loaded_arsc = LoadedArsc::Load(data, length, loaded_idmap.get(), property_flags); } else if (loaded_idmap != nullptr && IsFabricatedOverlay(std::string(loaded_idmap->OverlayApkPath()))) { } else if (loaded_idmap != nullptr && IsFabricatedOverlay(loaded_idmap->OverlayApkPath())) { loaded_arsc = LoadedArsc::Load(loaded_idmap.get()); } else { loaded_arsc = LoadedArsc::CreateEmpty(); Loading Loading
cmds/idmap2/tests/FabricatedOverlayTests.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ TEST(FabricatedOverlayTests, SerializeAndDeserialize) { "com.example.target:string/string1", Res_value::TYPE_STRING, "foobar", "") .Build(); ASSERT_TRUE(overlay); TemporaryFile tf; TempFrroFile tf; std::ofstream out(tf.path); ASSERT_TRUE((*overlay).ToBinaryStream(out)); out.close(); Loading
cmds/idmap2/tests/IdmapTests.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -274,7 +274,7 @@ TEST(IdmapTests, FabricatedOverlay) { .Build(); ASSERT_TRUE(frro); TemporaryFile tf; TempFrroFile tf; std::ofstream out(tf.path); ASSERT_TRUE((*frro).ToBinaryStream(out)); out.close(); Loading Loading @@ -467,9 +467,9 @@ TEST(IdmapTests, CreateIdmapDataInlineResources) { TEST(IdmapTests, IdmapHeaderIsUpToDate) { fclose(stderr); // silence expected warnings from libandroidfw const std::string target_apk_path = kIdmapRawTargetPath; const std::string overlay_apk_path = kIdmapRawOverlayPath; const std::string overlay_name = kIdmapRawOverlayName; 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; Loading
cmds/idmap2/tests/ResourceMappingTests.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ TEST(ResourceMappingTests, FabricatedOverlay) { .Build(); ASSERT_TRUE(frro); TemporaryFile tf; TempFrroFile tf; std::ofstream out(tf.path); ASSERT_TRUE((*frro).ToBinaryStream(out)); out.close(); Loading
cmds/idmap2/tests/TestHelpers.h +18 −3 Original line number Diff line number Diff line Loading @@ -17,11 +17,15 @@ #ifndef IDMAP2_TESTS_TESTHELPERS_H_ #define IDMAP2_TESTS_TESTHELPERS_H_ #include <stdio.h> #include <string> #include <string_view> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "android-base/file.h" namespace android::idmap2 { const unsigned char kIdmapRawData[] = { Loading Loading @@ -197,12 +201,23 @@ 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"; inline const std::string_view kIdmapRawTargetPath = "targetX.apk"; inline const std::string_view kIdmapRawOverlayPath = "overlayX.apk"; inline const std::string_view kIdmapRawOverlayName = "OverlayName"; std::string GetTestDataPath(); class TempFrroFile : public TemporaryFile { public: TempFrroFile() { std::string new_path = path; new_path += ".frro"; ::rename(path, new_path.c_str()); const auto new_len = new_path.copy(path, sizeof(path) - 1); path[new_len] = '\0'; } }; class Idmap2Tests : public testing::Test { protected: void SetUp() override { Loading
libs/androidfw/ApkAssets.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ ApkAssetsPtr ApkAssets::LoadOverlay(const std::string& idmap_path, package_prope std::string overlay_path(loaded_idmap->OverlayApkPath()); auto fd = unique_fd(base::utf8::open(overlay_path.c_str(), O_RDONLY | O_CLOEXEC)); std::unique_ptr<AssetsProvider> overlay_assets; if (IsFabricatedOverlay(fd)) { if (IsFabricatedOverlayName(overlay_path) && IsFabricatedOverlay(fd)) { // Fabricated overlays do not contain resource definitions. All of the overlay resource values // are defined inline in the idmap. overlay_assets = EmptyAssetsProvider::Create(std::move(overlay_path)); Loading Loading @@ -137,8 +137,7 @@ ApkAssetsPtr ApkAssets::LoadImpl(std::unique_ptr<Asset> resources_asset, return {}; } loaded_arsc = LoadedArsc::Load(data, length, loaded_idmap.get(), property_flags); } else if (loaded_idmap != nullptr && IsFabricatedOverlay(std::string(loaded_idmap->OverlayApkPath()))) { } else if (loaded_idmap != nullptr && IsFabricatedOverlay(loaded_idmap->OverlayApkPath())) { loaded_arsc = LoadedArsc::Load(loaded_idmap.get()); } else { loaded_arsc = LoadedArsc::CreateEmpty(); Loading