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
This commit is contained in:
Clark DuVall
2020-01-09 11:52:52 -08:00
parent 3df3e3b0bf
commit e9fedbe223
6 changed files with 69 additions and 1 deletions

View File

@@ -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> item = ResourceUtils::ParseBinaryResValue(ResourceType::kId,
android::ConfigDescription(),
android::ResStringPool(), value,
nullptr);
Reference* ref = ValueCast<Reference>(item.get());
EXPECT_TRUE(ref->is_dynamic);
EXPECT_EQ(ref->id.value().id, 0x01);
}
TEST(ResourceUtilsTest, FailToParseAutoCreateNonIdReference) {
bool create = false;
bool private_ref = false;