am 0f0e85a6: Merge "AAPT: attributes showing up after v21 attributes would be removed for pre-21 devices" into lmp-mr1-dev
automerge: 465d123
* commit '465d123464eadf180b618164b2ed23702bca3d86':
AAPT: attributes showing up after v21 attributes would be removed for pre-21 devices
This commit is contained in:
@@ -4561,7 +4561,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<key_value_pair_t<sp<XMLNode>, size_t> > attrsToRemove;
|
sp<XMLNode> newRoot = NULL;
|
||||||
|
|
||||||
Vector<sp<XMLNode> > nodesToVisit;
|
Vector<sp<XMLNode> > nodesToVisit;
|
||||||
nodesToVisit.push(root);
|
nodesToVisit.push(root);
|
||||||
@@ -4570,11 +4570,23 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
|
|||||||
nodesToVisit.pop();
|
nodesToVisit.pop();
|
||||||
|
|
||||||
const Vector<XMLNode::attribute_entry>& attrs = node->getAttributes();
|
const Vector<XMLNode::attribute_entry>& attrs = node->getAttributes();
|
||||||
const size_t attrCount = attrs.size();
|
for (size_t i = 0; i < attrs.size(); i++) {
|
||||||
for (size_t i = 0; i < attrCount; i++) {
|
|
||||||
const XMLNode::attribute_entry& attr = attrs[i];
|
const XMLNode::attribute_entry& attr = attrs[i];
|
||||||
if (isAttributeFromL(attr.nameResId)) {
|
if (isAttributeFromL(attr.nameResId)) {
|
||||||
attrsToRemove.add(key_value_pair_t<sp<XMLNode>, size_t>(node, i));
|
if (newRoot == NULL) {
|
||||||
|
newRoot = root->clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bundle->getVerbose()) {
|
||||||
|
SourcePos(node->getFilename(), node->getStartLineNumber()).printf(
|
||||||
|
"removing attribute %s%s%s from <%s>",
|
||||||
|
String8(attr.ns).string(),
|
||||||
|
(attr.ns.size() == 0 ? "" : ":"),
|
||||||
|
String8(attr.name).string(),
|
||||||
|
String8(node->getElementName()).string());
|
||||||
|
}
|
||||||
|
node->removeAttribute(i);
|
||||||
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4586,7 +4598,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrsToRemove.isEmpty()) {
|
if (newRoot == NULL) {
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4596,12 +4608,8 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
|
|||||||
// Look to see if we already have an overriding v21 configuration.
|
// Look to see if we already have an overriding v21 configuration.
|
||||||
sp<ConfigList> cl = getConfigList(String16(mAssets->getPackage()),
|
sp<ConfigList> cl = getConfigList(String16(mAssets->getPackage()),
|
||||||
String16(target->getResourceType()), resourceName);
|
String16(target->getResourceType()), resourceName);
|
||||||
//if (cl == NULL) {
|
|
||||||
// fprintf(stderr, "fuuuuck\n");
|
|
||||||
//}
|
|
||||||
if (cl->getEntries().indexOfKey(newConfig) < 0) {
|
if (cl->getEntries().indexOfKey(newConfig) < 0) {
|
||||||
// We don't have an overriding entry for v21, so we must duplicate this one.
|
// We don't have an overriding entry for v21, so we must duplicate this one.
|
||||||
sp<XMLNode> newRoot = root->clone();
|
|
||||||
sp<AaptFile> newFile = new AaptFile(target->getSourceFile(),
|
sp<AaptFile> newFile = new AaptFile(target->getSourceFile(),
|
||||||
AaptGroupEntry(newConfig), target->getResourceType());
|
AaptGroupEntry(newConfig), target->getResourceType());
|
||||||
String8 resPath = String8::format("res/%s/%s",
|
String8 resPath = String8::format("res/%s/%s",
|
||||||
@@ -4636,22 +4644,6 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
|
|||||||
mWorkQueue.push(item);
|
mWorkQueue.push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t removeCount = attrsToRemove.size();
|
|
||||||
for (size_t i = 0; i < removeCount; i++) {
|
|
||||||
sp<XMLNode> node = attrsToRemove[i].key;
|
|
||||||
size_t attrIndex = attrsToRemove[i].value;
|
|
||||||
const XMLNode::attribute_entry& ae = node->getAttributes()[attrIndex];
|
|
||||||
if (bundle->getVerbose()) {
|
|
||||||
SourcePos(node->getFilename(), node->getStartLineNumber()).printf(
|
|
||||||
"removing attribute %s%s%s from <%s>",
|
|
||||||
String8(ae.ns).string(),
|
|
||||||
(ae.ns.size() == 0 ? "" : ":"),
|
|
||||||
String8(ae.name).string(),
|
|
||||||
String8(node->getElementName()).string());
|
|
||||||
}
|
|
||||||
node->removeAttribute(attrIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user