From f90f2f8dc36e7243b85e0b6a7fd5a590893c827e Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 6 Jun 2014 14:27:00 -0700 Subject: Support multiple resource tables with same package In order to support APK split features, the resource table needs to support loading multiple resource tables with the same package but potentially new set of type IDs. This adds some complexity as the type ID space changes from dense and ordered to potentially sparse. A ByteBucketArray is used to store the type IDs in a memory efficient way that allows for fast retrieval. In addition, the IDMAP format has changed. We no longer need random access to the type data, since we store the types differently. However, random access to entries of a given type is still required. Change-Id: If6f5be680b405b368941d9c1f2b5d2ddca964160 --- tools/aapt/Resource.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tools/aapt/Resource.cpp') diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index f10904c871f4..3d93bbe62f67 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -589,11 +589,11 @@ static bool applyFileOverlay(Bundle *bundle, if (bundle->getVerbose()) { printf("trying overlaySet Key=%s\n",overlaySet->keyAt(overlayIndex).string()); } - size_t baseIndex = UNKNOWN_ERROR; + ssize_t baseIndex = -1; if (baseSet->get() != NULL) { baseIndex = (*baseSet)->indexOfKey(overlaySet->keyAt(overlayIndex)); } - if (baseIndex < UNKNOWN_ERROR) { + if (baseIndex >= 0) { // look for same flavor. For a given file (strings.xml, for example) // there may be a locale specific or other flavors - we want to match // the same flavor. @@ -619,10 +619,10 @@ static bool applyFileOverlay(Bundle *bundle, for (size_t overlayGroupIndex = 0; overlayGroupIndexgetFiles().indexOfKey(overlayFiles. keyAt(overlayGroupIndex)); - if (baseFileIndex < UNKNOWN_ERROR) { + if (baseFileIndex >= 0) { if (bundle->getVerbose()) { printf("found a match (" ZD ") for overlay file %s, for flavor %s\n", (ZD_TYPE) baseFileIndex, @@ -1363,7 +1363,11 @@ status_t buildResources(Bundle* bundle, const sp& assets, spisBase()) { resFile = flattenedTable; - finalResTable.add(flattenedTable->getData(), flattenedTable->getSize()); + err = finalResTable.add(flattenedTable->getData(), flattenedTable->getSize()); + if (err != NO_ERROR) { + fprintf(stderr, "Generated resource table is corrupt.\n"); + return err; + } } else { sp generatedManifest = new AaptFile(String8("AndroidManifest.xml"), AaptGroupEntry(), String8()); -- cgit v1.2.3-59-g8ed1b