From 978ab9d92934b79409638cf220de3002fea8d505 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 24 Sep 2014 19:02:52 -0700 Subject: [PATCH] AAPT: Fix issue with synthesized resource not actually showing up AAPT keeps around a few pieces of state that are disjoint, so simply adding to a collection won't add the resource to the final flattened output. Instead, we create the resource from the top and then copy over the values into the newly created resource. Bug:17647890 Change-Id: I214263e84c18f9370c6e6a5aa53aa2d833fc842d --- tools/aapt/ResourceTable.cpp | 19 ++++++++++++++++++- tools/aapt/ResourceTable.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index b8c34543c3610..77d3beb731e2d 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -3310,6 +3310,19 @@ ResourceTable::Entry::Entry(const Entry& entry) , mParentId(entry.mParentId) , mPos(entry.mPos) {} +ResourceTable::Entry& ResourceTable::Entry::operator=(const Entry& entry) { + mName = entry.mName; + mParent = entry.mParent; + mType = entry.mType; + mItem = entry.mItem; + mItemFormat = entry.mItemFormat; + mBag = entry.mBag; + mNameIndex = entry.mNameIndex; + mParentId = entry.mParentId; + mPos = entry.mPos; + return *this; +} + status_t ResourceTable::Entry::makeItABag(const SourcePos& sourcePos) { if (mType == TYPE_BAG) { @@ -4352,7 +4365,11 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) { String8(entriesToAdd[i].value->getName()).string(), entriesToAdd[i].key.toString().string()); - c->addEntry(entriesToAdd[i].key, entriesToAdd[i].value); + sp newEntry = t->getEntry(c->getName(), + entriesToAdd[i].value->getPos(), + &entriesToAdd[i].key); + + *newEntry = *entriesToAdd[i].value; } } } diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h index c548a851fb2e6..eac5dd3f919fb 100644 --- a/tools/aapt/ResourceTable.h +++ b/tools/aapt/ResourceTable.h @@ -316,6 +316,7 @@ public: { } Entry(const Entry& entry); + Entry& operator=(const Entry& entry); virtual ~Entry() { }