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

Function applyFileOverlay

tools/aapt/Resource.cpp:567–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565}
566
567static bool applyFileOverlay(Bundle *bundle,
568 const sp<AaptAssets>& assets,
569 sp<ResourceTypeSet> *baseSet,
570 const char *resType)
571{
572 if (bundle->getVerbose()) {
573 printf("applyFileOverlay for %s\n", resType);
574 }
575
576 // Replace any base level files in this category with any found from the overlay
577 // Also add any found only in the overlay.
578 sp<AaptAssets> overlay = assets->getOverlay();
579 String8 resTypeString(resType);
580
581 // work through the linked list of overlays
582 while (overlay.get()) {
583 KeyedVector<String8, sp<ResourceTypeSet> >* overlayRes = overlay->getResources();
584
585 // get the overlay resources of the requested type
586 ssize_t index = overlayRes->indexOfKey(resTypeString);
587 if (index >= 0) {
588 sp<ResourceTypeSet> overlaySet = overlayRes->valueAt(index);
589
590 // for each of the resources, check for a match in the previously built
591 // non-overlay "baseset".
592 size_t overlayCount = overlaySet->size();
593 for (size_t overlayIndex=0; overlayIndex<overlayCount; overlayIndex++) {
594 if (bundle->getVerbose()) {
595 printf("trying overlaySet Key=%s\n",overlaySet->keyAt(overlayIndex).string());
596 }
597 size_t baseIndex = UNKNOWN_ERROR;
598 if (baseSet->get() != NULL) {
599 baseIndex = (*baseSet)->indexOfKey(overlaySet->keyAt(overlayIndex));
600 }
601 if (baseIndex < UNKNOWN_ERROR) {
602 // look for same flavor. For a given file (strings.xml, for example)
603 // there may be a locale specific or other flavors - we want to match
604 // the same flavor.
605 sp<AaptGroup> overlayGroup = overlaySet->valueAt(overlayIndex);
606 sp<AaptGroup> baseGroup = (*baseSet)->valueAt(baseIndex);
607
608 DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> > overlayFiles =
609 overlayGroup->getFiles();
610 if (bundle->getVerbose()) {
611 DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> > baseFiles =
612 baseGroup->getFiles();
613 for (size_t i=0; i < baseFiles.size(); i++) {
614 printf("baseFile " ZD " has flavor %s\n", (ZD_TYPE) i,
615 baseFiles.keyAt(i).toString().string());
616 }
617 for (size_t i=0; i < overlayFiles.size(); i++) {
618 printf("overlayFile " ZD " has flavor %s\n", (ZD_TYPE) i,
619 overlayFiles.keyAt(i).toString().string());
620 }
621 }
622
623 size_t overlayGroupSize = overlayFiles.size();
624 for (size_t overlayGroupIndex = 0;

Callers 1

buildResourcesFunction · 0.85

Calls 14

getVerboseMethod · 0.80
stringMethod · 0.80
addGroupEntryMethod · 0.80
getMethod · 0.65
sizeMethod · 0.65
addMethod · 0.65
getOverlayMethod · 0.45
getResourcesMethod · 0.45
indexOfKeyMethod · 0.45
valueAtMethod · 0.45
keyAtMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected