From 27f69f4e06961fdecd1078b2292d764a157e5e1c Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Thu, 21 Aug 2014 13:19:12 -0700 Subject: AAPT: mipmaps should not end up in Splits Mipmaps are never filtered, and so they will always end up in the base APK. Make sure they get omitted from any split. Change-Id: Id24b082bc9bd2d3f031a58bd0de4d30b4f0de7e0 --- tools/aapt/ResourceTable.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'tools/aapt/ResourceTable.cpp') diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 49d8699def1f..b3c364be2451 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -2074,10 +2074,11 @@ bool ResourceTable::hasResources() const { return mNumLocal > 0; } -sp ResourceTable::flatten(Bundle* bundle, const sp& filter) +sp ResourceTable::flatten(Bundle* bundle, const sp& filter, + const bool isBase) { sp data = new AaptFile(String8(), AaptGroupEntry(), String8()); - status_t err = flatten(bundle, filter, data); + status_t err = flatten(bundle, filter, data, isBase); return err == NO_ERROR ? data : NULL; } @@ -2699,7 +2700,9 @@ ResourceTable::validateLocalizations(void) return err; } -status_t ResourceTable::flatten(Bundle* bundle, const sp& filter, const sp& dest) +status_t ResourceTable::flatten(Bundle* bundle, const sp& filter, + const sp& dest, + const bool isBase) { const ConfigDescription nullConfig; @@ -2768,6 +2771,13 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& configTypeName = "2value"; } + // mipmaps don't get filtered, so they will + // allways end up in the base. Make sure they + // don't end up in a split. + if (typeName == mipmap16 && !isBase) { + continue; + } + const bool filterable = (typeName != mipmap16); const size_t N = t->getOrderedConfigs().size(); @@ -2871,10 +2881,12 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& return amt; } - status_t err = flattenLibraryTable(data, libraryPackages); - if (err != NO_ERROR) { - fprintf(stderr, "ERROR: failed to write library table\n"); - return err; + if (isBase) { + status_t err = flattenLibraryTable(data, libraryPackages); + if (err != NO_ERROR) { + fprintf(stderr, "ERROR: failed to write library table\n"); + return err; + } } // Build the type chunks inside of this package. @@ -2890,6 +2902,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& continue; } const bool filterable = (typeName != mipmap16); + const bool skipEntireType = (typeName == mipmap16 && !isBase); const size_t N = t != NULL ? t->getOrderedConfigs().size() : 0; @@ -2927,6 +2940,11 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& if (cl->getPublic()) { typeSpecFlags[ei] |= htodl(ResTable_typeSpec::SPEC_PUBLIC); } + + if (skipEntireType) { + continue; + } + const size_t CN = cl->getEntries().size(); for (size_t ci=0; cimatch(cl->getEntries().keyAt(ci))) { @@ -2943,6 +2961,10 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& } } + if (skipEntireType) { + continue; + } + // We need to write one type chunk for each configuration for // which we have entries in this type. const size_t NC = t->getUniqueConfigs().size(); -- cgit v1.2.3-59-g8ed1b