From 249e3ed5400e5c7ab2e9aa8017f612d79d2e8089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Wed, 8 Feb 2012 10:22:47 +0100 Subject: Runtime resource overlay: clean-up. This is a combination of three minor clean-up tasks: - Generate correct idmap even if name lookup fails: Any resources following a resource with a spec but no actual values would receive an incorrect ID in the idmap due to an accumulating offset error. To combat this, a dummy value is inserted in the idmap whenever a resource with a spec but no values is encountered. - Optimize pruning of padding zeroes in idmaps: Earlier, trailing zeroes were iteratively popped from the end of each type block of an idmap. This commit instead tracks where to make the cut, and does so with a single function call. - aapt: warn about resources which lack values: The resource framework assumes every resource to have a value for at least one valid configuration. However, if multiple resource directories are used (several -S options to aapt), the list of configurations is limited by dpi (-c option to aapt) and a resource is only available in discarded dpi configurations, aapt will create a resource entry where each configuration lack an actual value. This commit lets aapt emit a warning whenever this has happened. Change-Id: Ic7451b7f4adfef5bfa6b0d7e64e057f317a2cdaa --- tools/aapt/ResourceTable.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tools/aapt') diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 20e221d..770b027 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -2661,6 +2661,12 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) const bool filterable = (typeName != mipmap16); const size_t N = t != NULL ? t->getOrderedConfigs().size() : 0; + + // Until a non-NO_ENTRY value has been written for a resource, + // that resource is invalid; validResources[i] represents + // the item at t->getOrderedConfigs().itemAt(i). + Vector validResources; + validResources.insertAt(false, 0, N); // First write the typeSpec chunk, containing information about // each resource entry in this type. @@ -2797,6 +2803,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) if (amt < 0) { return amt; } + validResources.editItemAt(ei) = true; } else { index[ei] = htodl(ResTable_type::NO_ENTRY); } @@ -2807,6 +2814,14 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) (((uint8_t*)data->editData()) + typeStart); tHeader->header.size = htodl(data->getSize()-typeStart); } + + for (size_t i = 0; i < N; ++i) { + if (!validResources[i]) { + sp c = t->getOrderedConfigs().itemAt(i); + fprintf(stderr, "warning: no entries written for %s/%s\n", + String8(typeName).string(), String8(c->getName()).string()); + } + } } // Fill in the rest of the package information. -- cgit v1.1