Search in sources :

Example 1 with Item

use of com.android.aapt.Resources.Item in project bundletool by google.

the class ResourceAnalyzer method transitiveClosure.

private ImmutableSet<ResourceId> transitiveClosure(ImmutableSet<ResourceId> anchorResources) throws IOException {
    Set<ResourceId> referencedResources = new HashSet<>();
    Queue<ResourceId> resourcesToInspect = new ArrayDeque<>();
    resourcesToInspect.addAll(anchorResources);
    while (!resourcesToInspect.isEmpty()) {
        ResourceId resourceId = resourcesToInspect.remove();
        if (referencedResources.contains(resourceId) || !baseModuleResourcesById.containsKey(resourceId)) {
            continue;
        }
        referencedResources.add(resourceId);
        ResourceTableEntry resourceEntry = baseModuleResourcesById.get(resourceId);
        for (ConfigValue configValue : resourceEntry.getEntry().getConfigValueList()) {
            switch(configValue.getValue().getValueCase()) {
                case ITEM:
                    Item item = configValue.getValue().getItem();
                    resourcesToInspect.addAll(findAllReferencedAppResources(item));
                    break;
                case COMPOUND_VALUE:
                    CompoundValue compoundValue = configValue.getValue().getCompoundValue();
                    resourcesToInspect.addAll(findAllReferencedAppResources(compoundValue));
                    break;
                case VALUE_NOT_SET:
            }
        }
    }
    return ImmutableSet.copyOf(referencedResources);
}
Also used : Item(com.android.aapt.Resources.Item) ConfigValue(com.android.aapt.Resources.ConfigValue) CompoundValue(com.android.aapt.Resources.CompoundValue) ResourceTableEntry(com.android.tools.build.bundletool.model.ResourceTableEntry) ResourceId(com.android.tools.build.bundletool.model.ResourceId) ArrayDeque(java.util.ArrayDeque) HashSet(java.util.HashSet)

Aggregations

CompoundValue (com.android.aapt.Resources.CompoundValue)1 ConfigValue (com.android.aapt.Resources.ConfigValue)1 Item (com.android.aapt.Resources.Item)1 ResourceId (com.android.tools.build.bundletool.model.ResourceId)1 ResourceTableEntry (com.android.tools.build.bundletool.model.ResourceTableEntry)1 ArrayDeque (java.util.ArrayDeque)1 HashSet (java.util.HashSet)1