summaryrefslogtreecommitdiff
path: root/tools/aapt/Resource.cpp
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2014-06-18 15:06:01 -0700
committer Adam Lesinski <adamlesinski@google.com> 2014-08-04 18:48:14 -0700
commit833f3ccbc8f4dd1ec8abb9121988b99ff34ec4c1 (patch)
treea57e8389088178108de1424faf41ea3bb87c934a /tools/aapt/Resource.cpp
parent5c09e8ad5ee8e67976066366527ee58792551953 (diff)
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
Diffstat (limited to 'tools/aapt/Resource.cpp')
-rw-r--r--tools/aapt/Resource.cpp23
1 files changed, 22 insertions, 1 deletions
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<XMLNode> 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<AaptAssets>& assets, sp<ApkBuil
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;