From 6e46056abc1c2803ed7f195bab169bbb1cacec6b Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Tue, 21 Apr 2015 14:20:15 -0700 Subject: AAPT: Add flag to disable versioning of vector related XML AAPT automatically versions XML files according to the SDK level in which their attributes were introduced. Support libraries know how to handle resources built against newer SDKs, so offer the option to disable some of the automatic versioning, namely vectors. Bug:19336994 Change-Id: I9f9d0ae8f2a0c28404f82e27de416f80e38493c9 --- tools/aapt/ResourceTable.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tools/aapt/ResourceTable.cpp') diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index c5fccbf02914..3b146da630d8 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -4611,6 +4611,9 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, const String16& resourceName, const sp& target, const sp& root) { + const String16 vector16("vector"); + const String16 animatedVector16("animated-vector"); + const int minSdk = getMinSdkVersion(bundle); if (minSdk >= SDK_LOLLIPOP_MR1) { // Lollipop MR1 and up handles public attributes differently, no @@ -4620,8 +4623,8 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, const ConfigDescription config(target->getGroupEntry().toParams()); if (target->getResourceType() == "" || config.sdkVersion >= SDK_LOLLIPOP_MR1) { - // Skip resources that have no type (AndroidManifest.xml) or are already version qualified with v21 - // or higher. + // Skip resources that have no type (AndroidManifest.xml) or are already version qualified + // with v21 or higher. return NO_ERROR; } @@ -4635,6 +4638,12 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, sp node = nodesToVisit.top(); nodesToVisit.pop(); + if (bundle->getNoVersionVectors() && (node->getElementName() == vector16 || + node->getElementName() == animatedVector16)) { + // We were told not to version vector tags, so skip the children here. + continue; + } + const Vector& attrs = node->getAttributes(); for (size_t i = 0; i < attrs.size(); i++) { const XMLNode::attribute_entry& attr = attrs[i]; -- cgit v1.2.3-59-g8ed1b