From: Robert Greenwalt Date: Tue, 9 Jun 2009 16:14:20 +0000 (-0700) Subject: Make aapt Error out when an overlay adds a string. X-Git-Url: https://git.saurik.com/android/aapt.git/commitdiff_plain/6c9f72e4b1aa833c7051215ea7b0e47756daa7e4?ds=inline;hp=eca7446ff64d08be71464cef5ea990ca0ef03251 Make aapt Error out when an overlay adds a string. Final added check (I think) for 1585775 - not letting overlays add resources. modified: ResourceTable.cpp modified: ResourceTable.h --- diff --git a/ResourceTable.cpp b/ResourceTable.cpp index 770c7d8..b004664 100644 --- a/ResourceTable.cpp +++ b/ResourceTable.cpp @@ -1516,8 +1516,9 @@ status_t ResourceTable::addEntry(const SourcePos& sourcePos, String8(value).string()); } #endif - - sp e = getEntry(package, type, name, sourcePos, params, doSetIndex); + + sp e = getEntry(package, type, name, sourcePos, overwrite, + params, doSetIndex); if (e == NULL) { return UNKNOWN_ERROR; } @@ -1560,8 +1561,7 @@ status_t ResourceTable::startBag(const SourcePos& sourcePos, String8(name).string()); return UNKNOWN_ERROR; } - - sp e = getEntry(package, type, name, sourcePos, params); + sp e = getEntry(package, type, name, sourcePos, overlay, params); if (e == NULL) { return UNKNOWN_ERROR; } @@ -1615,8 +1615,7 @@ status_t ResourceTable::addBag(const SourcePos& sourcePos, sourcePos.file.striing(), sourcePos.line, String8(type).string()); } #endif - - sp e = getEntry(package, type, name, sourcePos, params); + sp e = getEntry(package, type, name, sourcePos, replace, params); if (e == NULL) { return UNKNOWN_ERROR; } @@ -2899,7 +2898,7 @@ status_t ResourceTable::Entry::setItem(const SourcePos& sourcePos, mItem.sourcePos.file.string(), mItem.sourcePos.line); return UNKNOWN_ERROR; } - + mType = TYPE_ITEM; mItem = item; mItemFormat = format; @@ -3219,11 +3218,17 @@ status_t ResourceTable::Type::addPublic(const SourcePos& sourcePos, sp ResourceTable::Type::getEntry(const String16& entry, const SourcePos& sourcePos, const ResTable_config* config, - bool doSetIndex) + bool doSetIndex, + bool overlay) { int pos = -1; sp c = mConfigs.valueFor(entry); if (c == NULL) { + if (overlay == true) { + sourcePos.error("Resource %s appears in overlay but not" + " in the base package.\n", String8(entry).string()); + return NULL; + } c = new ConfigList(entry, sourcePos); mConfigs.add(entry, c); pos = (int)mOrderedConfigs.size(); @@ -3522,6 +3527,7 @@ sp ResourceTable::getEntry(const String16& package, const String16& type, const String16& name, const SourcePos& sourcePos, + bool overlay, const ResTable_config* config, bool doSetIndex) { @@ -3529,7 +3535,7 @@ sp ResourceTable::getEntry(const String16& package, if (t == NULL) { return NULL; } - return t->getEntry(name, sourcePos, config, doSetIndex); + return t->getEntry(name, sourcePos, config, doSetIndex, overlay); } sp ResourceTable::getEntry(uint32_t resID, diff --git a/ResourceTable.h b/ResourceTable.h index 20865ea..ec4331a 100644 --- a/ResourceTable.h +++ b/ResourceTable.h @@ -418,7 +418,8 @@ public: sp getEntry(const String16& entry, const SourcePos& pos, const ResTable_config* config = NULL, - bool doSetIndex = false); + bool doSetIndex = false, + bool overlay = false); const SourcePos& getFirstPublicSourcePos() const { return *mFirstPublicSourcePos; } @@ -502,6 +503,7 @@ private: const String16& type, const String16& name, const SourcePos& pos, + bool overlay, const ResTable_config* config = NULL, bool doSetIndex = false); sp getEntry(uint32_t resID,