From 833f3ccbc8f4dd1ec8abb9121988b99ff34ec4c1 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 18 Jun 2014 15:06:01 -0700 Subject: AAPT support for feature splits This change allows the developer to add a base package for which to build a feature split. The generated resource types will begin after the base APK's defined types so as not to collide or override resources. Multiple features can be generated by first choosing an arbitrary order for the features. Then for each feature, the base APK and any preceding features are specified with the --feature-of flags. So with a base APK 'A' and features, 'B', and 'C', 'B' would be built with aapt package [...] --feature-of A [...] and 'C' would be built with aapt package [...] --feature-of A --feature-of B [...] Change-Id: I1be66e3f8df9a737b21c71f8a93685376c7e6780 --- tools/aapt/Resource.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tools/aapt/Resource.cpp') diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index 4f1d15ec23e1..033ff40e822e 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -860,6 +860,18 @@ status_t massageManifest(Bundle* bundle, sp root) } } + // Generate split name if feature is present. + const XMLNode::attribute_entry* attr = root->getAttribute(String16(), String16("featureName")); + if (attr != NULL) { + String16 splitName("feature_"); + splitName.append(attr->string); + status_t err = root->addAttribute(String16(), String16("split"), splitName); + if (err != NO_ERROR) { + ALOGE("Failed to insert split name into AndroidManifest.xml"); + return err; + } + } + return NO_ERROR; } @@ -968,7 +980,16 @@ status_t buildResources(Bundle* bundle, const sp& assets, spgetPackage().string())); - ResourceTable table(bundle, String16(assets->getPackage())); + ResourceTable::PackageType packageType = ResourceTable::App; + if (bundle->getBuildSharedLibrary()) { + packageType = ResourceTable::SharedLibrary; + } else if (bundle->getExtending()) { + packageType = ResourceTable::System; + } else if (!bundle->getFeatureOfPackage().isEmpty()) { + packageType = ResourceTable::AppFeature; + } + + ResourceTable table(bundle, String16(assets->getPackage()), packageType); err = table.addIncludedResources(bundle, assets); if (err != NO_ERROR) { return err; -- cgit v1.2.3-59-g8ed1b