From fab50875b98e8274ac8ee44b38ba42521bbbf1f9 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 16 Apr 2014 14:40:42 -0700 Subject: Add support for building split APKs Build multiple APKs, each containing a disjoint subset of configurations. These can then be loaded into the device AssetManager and should operate as if they were never split. Use the idea of building multiple sets of files, where each set represents an APK. An ApkBuilder can place files in a set based on its configuration, but you can actually add directly to a set, in the case of the resources.arsc and generated AndroidManifest.xml for splits. Change-Id: Ic65d3f0ac1bbd290185695b9971d425c85ab1de3 --- tools/aapt/ResourceTable.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'tools/aapt/ResourceTable.cpp') diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index b445b8aa16d0..337575df5258 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -2080,10 +2080,10 @@ bool ResourceTable::hasResources() const { return mNumLocal > 0; } -sp ResourceTable::flatten(Bundle* bundle) +sp ResourceTable::flatten(Bundle* bundle, const sp& filter) { sp data = new AaptFile(String8(), AaptGroupEntry(), String8()); - status_t err = flatten(bundle, data); + status_t err = flatten(bundle, filter, data); return err == NO_ERROR ? data : NULL; } @@ -2643,8 +2643,8 @@ ResourceTable::validateLocalizations(void) } // Check that all requested localizations are present for this string - if (mBundle->getConfigurations() != NULL && mBundle->getRequireLocalization()) { - const char* allConfigs = mBundle->getConfigurations(); + if (mBundle->getConfigurations().size() > 0 && mBundle->getRequireLocalization()) { + const char* allConfigs = mBundle->getConfigurations().string(); const char* start = allConfigs; const char* comma; @@ -2698,14 +2698,8 @@ ResourceTable::validateLocalizations(void) return err; } -status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) +status_t ResourceTable::flatten(Bundle* bundle, const sp& filter, const sp& dest) { - ResourceFilter filter; - status_t err = filter.parse(bundle->getConfigurations()); - if (err != NO_ERROR) { - return err; - } - const ConfigDescription nullConfig; const size_t N = mOrderedPackages.size(); @@ -2780,7 +2774,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) const size_t N = c->getEntries().size(); for (size_t ei=0; eigetEntries().keyAt(ei); - if (filterable && !filter.match(config)) { + if (filterable && !filter->match(config)) { continue; } sp e = c->getEntries().valueAt(ei); @@ -2872,7 +2866,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) return amt; } - err = flattenLibraryTable(data, libraryPackages); + status_t err = flattenLibraryTable(data, libraryPackages); if (err != NO_ERROR) { fprintf(stderr, "ERROR: failed to write library table\n"); return err; @@ -2928,11 +2922,11 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) } const size_t CN = cl->getEntries().size(); for (size_t ci=0; cigetEntries().keyAt(ci))) { + if (filterable && !filter->match(cl->getEntries().keyAt(ci))) { continue; } for (size_t cj=ci+1; cjgetEntries().keyAt(cj))) { + if (filterable && !filter->match(cl->getEntries().keyAt(cj))) { continue; } typeSpecFlags[ei] |= htodl( @@ -2974,7 +2968,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) config.screenHeightDp, config.layoutDirection)); - if (filterable && !filter.match(config)) { + if (filterable && !filter->match(config)) { continue; } @@ -3093,7 +3087,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) } ssize_t strStart = dest->getSize(); - err = valueStrings.writeStringBlock(dest); + status_t err = valueStrings.writeStringBlock(dest); if (err != NO_ERROR) { return err; } -- cgit v1.2.3-59-g8ed1b