From e9fedbe223bc1eb4498e375f4714ca73444bd1ce Mon Sep 17 00:00:00 2001 From: Clark DuVall Date: Thu, 9 Jan 2020 11:52:52 -0800 Subject: Fix serializing dynamic references to proto The is_dynamic bit on references was getting lost when converting to proto and back. This was preventing bundles from being used as shared libraries, since layout inflation would fail when it hit a dynamic reference. Bug: 146491000 Test: Build a shared library with a layout that has a dynamic reference, and attempt to inflate that layout. Change-Id: Ia0e615670d2ac52f9266e3eec8813af7687d3323 --- tools/aapt2/ResourceUtils_test.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/aapt2/ResourceUtils_test.cpp') diff --git a/tools/aapt2/ResourceUtils_test.cpp b/tools/aapt2/ResourceUtils_test.cpp index c016cb44af00..b08bf9a1ff17 100644 --- a/tools/aapt2/ResourceUtils_test.cpp +++ b/tools/aapt2/ResourceUtils_test.cpp @@ -109,6 +109,20 @@ TEST(ResourceUtilsTest, ParsePrivateReference) { EXPECT_TRUE(private_ref); } +TEST(ResourceUtilsTest, ParseBinaryDynamicReference) { + android::Res_value value = {}; + value.data = util::HostToDevice32(0x01); + value.dataType = android::Res_value::TYPE_DYNAMIC_REFERENCE; + std::unique_ptr item = ResourceUtils::ParseBinaryResValue(ResourceType::kId, + android::ConfigDescription(), + android::ResStringPool(), value, + nullptr); + + Reference* ref = ValueCast(item.get()); + EXPECT_TRUE(ref->is_dynamic); + EXPECT_EQ(ref->id.value().id, 0x01); +} + TEST(ResourceUtilsTest, FailToParseAutoCreateNonIdReference) { bool create = false; bool private_ref = false; -- cgit v1.2.3