summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceUtils.cpp
diff options
context:
space:
mode:
authorDonald Chai <dchai@google.com>2019-12-13 23:23:07 -0800
committerDonald Chai <dchai@google.com>2019-12-14 07:29:01 +0000
commit4abc82859dc7f7ed5f01aaadb360542ae8ca303c (patch)
tree86bffef18055b3964568d9ee3a66b760526f3e8d /tools/aapt2/ResourceUtils.cpp
parentd406123c4790053077cc90571e603b57d62e9d72 (diff)
Fix deserialization of @id aliases
I didn't realize that this was actually a thing, but: <resources> <item name="id1" type="id"></item> <item name="id2" type="id">@id/id1</item> </resources> 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
Diffstat (limited to 'tools/aapt2/ResourceUtils.cpp')
-rw-r--r--tools/aapt2/ResourceUtils.cpp8
1 files changed, 7 insertions, 1 deletions
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<Item> ParseBinaryResValue(const ResourceType& type, const Config
const android::Res_value& res_value,
StringPool* dst_pool) {
if (type == ResourceType::kId) {
- return util::make_unique<Id>();
+ 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<Id>();
+ }
+ // fall through to regular reference deserialization logic
}
const uint32_t data = util::DeviceToHost32(res_value.data);