MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / writeProguardForXml

Function writeProguardForXml

tools/aapt/Resource.cpp:2438–2512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2436};
2437
2438status_t
2439writeProguardForXml(ProguardKeepSet* keep, const sp<AaptFile>& layoutFile,
2440 const char* startTag, const KeyedVector<String8, Vector<NamespaceAttributePair> >* tagAttrPairs)
2441{
2442 status_t err;
2443 ResXMLTree tree;
2444 size_t len;
2445 ResXMLTree::event_code_t code;
2446
2447 err = parseXMLResource(layoutFile, &tree);
2448 if (err != NO_ERROR) {
2449 return err;
2450 }
2451
2452 tree.restart();
2453
2454 if (startTag != NULL) {
2455 bool haveStart = false;
2456 while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) {
2457 if (code != ResXMLTree::START_TAG) {
2458 continue;
2459 }
2460 String8 tag(tree.getElementName(&len));
2461 if (tag == startTag) {
2462 haveStart = true;
2463 }
2464 break;
2465 }
2466 if (!haveStart) {
2467 return NO_ERROR;
2468 }
2469 }
2470
2471 while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) {
2472 if (code != ResXMLTree::START_TAG) {
2473 continue;
2474 }
2475 String8 tag(tree.getElementName(&len));
2476
2477 // If there is no '.', we'll assume that it's one of the built in names.
2478 if (strchr(tag.string(), '.')) {
2479 addProguardKeepRule(keep, tag, NULL,
2480 layoutFile->getPrintableSource(), tree.getLineNumber());
2481 } else if (tagAttrPairs != NULL) {
2482 ssize_t tagIndex = tagAttrPairs->indexOfKey(tag);
2483 if (tagIndex >= 0) {
2484 const Vector<NamespaceAttributePair>& nsAttrVector = tagAttrPairs->valueAt(tagIndex);
2485 for (size_t i = 0; i < nsAttrVector.size(); i++) {
2486 const NamespaceAttributePair& nsAttr = nsAttrVector[i];
2487
2488 ssize_t attrIndex = tree.indexOfAttribute(nsAttr.ns, nsAttr.attr);
2489 if (attrIndex < 0) {
2490 // fprintf(stderr, "%s:%d: <%s> does not have attribute %s:%s.\n",
2491 // layoutFile->getPrintableSource().string(), tree.getLineNumber(),
2492 // tag.string(), nsAttr.ns, nsAttr.attr);
2493 } else {
2494 size_t len;
2495 addProguardKeepRule(keep,

Callers 1

writeProguardForLayoutsFunction · 0.85

Calls 14

parseXMLResourceFunction · 0.85
addProguardKeepRuleFunction · 0.85
getElementNameMethod · 0.80
stringMethod · 0.80
getPrintableSourceMethod · 0.80
indexOfAttributeMethod · 0.80
restartMethod · 0.65
sizeMethod · 0.65
nextMethod · 0.45
getLineNumberMethod · 0.45

Tested by

no test coverage detected