From 4d35cca96ce55eb29d1948086214f91ae94e9adb Mon Sep 17 00:00:00 2001 From: Yuichi Araki Date: Wed, 18 Jan 2017 20:42:17 +0900 Subject: AAPT: Add --no-version-transitions flag Add a new flag to disable versioning of Transition related XMLs. Transition support library will use this to handle these XMLs on older API levels. Test: make libaapt_tests AaptTestAppOne Bug: 34427868 Change-Id: I66e81cca049e71ef6704177b2ca21c9cdeaff78f --- tools/aapt/ResourceTable.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tools/aapt/ResourceTable.cpp') diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 661409e3d4bc..63498f7cef08 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -4730,6 +4730,32 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) { return NO_ERROR; } +const String16 kTransitionElements[] = { + String16("fade"), + String16("changeBounds"), + String16("slide"), + String16("explode"), + String16("changeImageTransform"), + String16("changeTransform"), + String16("changeClipBounds"), + String16("autoTransition"), + String16("recolor"), + String16("changeScroll"), + String16("transitionSet"), + String16("transition"), + String16("transitionManager"), +}; + +static bool IsTransitionElement(const String16& name) { + for (int i = 0, size = sizeof(kTransitionElements) / sizeof(kTransitionElements[0]); + i < size; ++i) { + if (name == kTransitionElements[i]) { + return true; + } + } + return false; +} + status_t ResourceTable::modifyForCompat(const Bundle* bundle, const String16& resourceName, const sp& target, @@ -4766,6 +4792,11 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, continue; } + if (bundle->getNoVersionTransitions() && (IsTransitionElement(node->getElementName()))) { + // We were told not to version transition 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