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
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 4f1d15e..033ff40 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -860,6 +860,18 @@
}
}
+ // 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 @@
NOISY(printf("Creating resources for package %s\n",
assets->getPackage().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;