summaryrefslogtreecommitdiffstats
path: root/tools/aapt/Resource.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2014-08-08 17:32:44 -0700
committerAdam Lesinski <adamlesinski@google.com>2014-08-15 15:53:35 -0700
commitd3edfde51bd069a63e820282421d1a534fcf00ce (patch)
tree9974d53c7ff2edc8577fd45066844de166fae7ed /tools/aapt/Resource.cpp
parent4482e4bb8d1f5fe586b641bc3d6298dc7b8fee80 (diff)
downloadframeworks_base-d3edfde51bd069a63e820282421d1a534fcf00ce.zip
frameworks_base-d3edfde51bd069a63e820282421d1a534fcf00ce.tar.gz
frameworks_base-d3edfde51bd069a63e820282421d1a534fcf00ce.tar.bz2
Add FeatureGroup to PackageInfo
FeatureGroups replace top-level FeatureInfo objects. FeatureGroups inherit top-level FeatureInfos but override them if the feature names are the same. Bug:16822121 Change-Id: I80b2cb778a0fbcb4521efce986fba641e0914290
Diffstat (limited to 'tools/aapt/Resource.cpp')
-rw-r--r--tools/aapt/Resource.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 010d59b..0a80805 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1470,6 +1470,8 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
String16 action16("action");
String16 category16("category");
String16 data16("scheme");
+ String16 feature_group16("feature-group");
+ String16 uses_feature16("uses-feature");
const char* packageIdentChars = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ._0123456789";
const char* packageIdentCharsWithTheStupid = "abcdefghijklmnopqrstuvwxyz"
@@ -1680,10 +1682,43 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
schemeIdentChars, true) != ATTR_OKAY) {
hasErrors = true;
}
+ } else if (strcmp16(block.getElementName(&len), feature_group16.string()) == 0) {
+ int depth = 1;
+ while ((code=block.next()) != ResXMLTree::END_DOCUMENT
+ && code > ResXMLTree::BAD_DOCUMENT) {
+ if (code == ResXMLTree::START_TAG) {
+ depth++;
+ if (strcmp16(block.getElementName(&len), uses_feature16.string()) == 0) {
+ ssize_t idx = block.indexOfAttribute(
+ RESOURCES_ANDROID_NAMESPACE, "required");
+ if (idx < 0) {
+ continue;
+ }
+
+ int32_t data = block.getAttributeData(idx);
+ if (data == 0) {
+ fprintf(stderr, "%s:%d: Tag <uses-feature> can not have "
+ "android:required=\"false\" when inside a "
+ "<feature-group> tag.\n",
+ manifestPath.string(), block.getLineNumber());
+ hasErrors = true;
+ }
+ }
+ } else if (code == ResXMLTree::END_TAG) {
+ depth--;
+ if (depth == 0) {
+ break;
+ }
+ }
+ }
}
}
}
+ if (hasErrors) {
+ return UNKNOWN_ERROR;
+ }
+
if (resFile != NULL) {
// These resources are now considered to be a part of the included
// resources, for others to reference.