From 4abc82859dc7f7ed5f01aaadb360542ae8ca303c Mon Sep 17 00:00:00 2001 From: Donald Chai Date: Fri, 13 Dec 2019 23:23:07 -0800 Subject: Fix deserialization of @id aliases I didn't realize that this was actually a thing, but: @id/id1 leads to a resource table which 'aapt dump resources' will render as: resource 0x7f030000 com.pkg:id/id1: t=0x03 d=0x00000001 (s=0x0008 r=0x00) resource 0x7f030001 com.pkg:id/id2: t=0x01 d=0x7f030000 (s=0x0008 r=0x00) while 'aapt2 dump resources' printed: type id id=03 entryCount=2 resource 0x7f030000 id/id1 () (id) resource 0x7f030001 id/id2 () (id) After this change, it prints: type id id=03 entryCount=2 resource 0x7f030000 id/id1 () (id) resource 0x7f030001 id/id2 () @id/id1 Bug: 69445910 Change-Id: I0001ff09345434577ac4c1d32f96a781f4190d8d Tested: manual, see above --- tools/aapt2/ResourceUtils.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/aapt2/ResourceUtils.cpp') diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index bd2ab5377311..03009aaeead2 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -738,7 +738,13 @@ std::unique_ptr ParseBinaryResValue(const ResourceType& type, const Config const android::Res_value& res_value, StringPool* dst_pool) { if (type == ResourceType::kId) { - return util::make_unique(); + if (res_value.dataType != android::Res_value::TYPE_REFERENCE && + res_value.dataType != android::Res_value::TYPE_DYNAMIC_REFERENCE) { + // plain "id" resources are actually encoded as dummy values (aapt1 uses an empty string, + // while aapt2 uses a false boolean). + return util::make_unique(); + } + // fall through to regular reference deserialization logic } const uint32_t data = util::DeviceToHost32(res_value.data); -- cgit v1.2.3-59-g8ed1b