Search in sources :

Example 1 with AssetModuleSizeAggregator

use of com.android.tools.build.bundletool.device.AssetModuleSizeAggregator in project bundletool by google.

the class GetSizeCommand method getSizeTotalInternal.

@VisibleForTesting
ConfigurationSizes getSizeTotalInternal() {
    BuildApksResult buildApksResult = ResultUtils.readTableOfContents(getApksArchivePath());
    ImmutableList<Variant> variants = new VariantMatcher(getDeviceSpec(), getInstant()).getAllMatchingVariants(buildApksResult);
    ImmutableMap<String, Long> variantCompressedSizeByApkPaths = getVariantCompressedSizeByApkPaths(variants, getApksArchivePath());
    ImmutableList<String> assetModuleApks = buildApksResult.getAssetSliceSetList().stream().flatMap(module -> module.getApkDescriptionList().stream()).map(ApkDescription::getPath).collect(toImmutableList());
    ImmutableMap<String, Long> assetModuleCompressedSizeByApkPaths = getCompressedSizeByApkPaths(assetModuleApks, getApksArchivePath());
    ImmutableMap<SizeConfiguration, Long> minSizeConfigurationMap = ImmutableMap.of();
    ImmutableMap<SizeConfiguration, Long> maxSizeConfigurationMap = ImmutableMap.of();
    for (Variant variant : variants) {
        ConfigurationSizes variantConfigurationSizes = new VariantTotalSizeAggregator(variantCompressedSizeByApkPaths, Version.of(buildApksResult.getBundletool().getVersion()), variant, this).getSize();
        ConfigurationSizes assetModuleConfigurationSizes = new AssetModuleSizeAggregator(buildApksResult.getAssetSliceSetList(), variant.getTargeting(), assetModuleCompressedSizeByApkPaths, this).getSize();
        ConfigurationSizes configurationSizes = ConfigurationSizesMerger.merge(variantConfigurationSizes, assetModuleConfigurationSizes);
        minSizeConfigurationMap = combineMaps(minSizeConfigurationMap, configurationSizes.getMinSizeConfigurationMap(), Math::min);
        maxSizeConfigurationMap = combineMaps(maxSizeConfigurationMap, configurationSizes.getMaxSizeConfigurationMap(), Math::max);
    }
    return ConfigurationSizes.create(minSizeConfigurationMap, maxSizeConfigurationMap);
}
Also used : BuildApksResult(com.android.bundle.Commands.BuildApksResult) VariantMatcher(com.android.tools.build.bundletool.device.VariantMatcher) AssetModuleSizeAggregator(com.android.tools.build.bundletool.device.AssetModuleSizeAggregator) Variant(com.android.bundle.Commands.Variant) ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) VariantTotalSizeAggregator(com.android.tools.build.bundletool.device.VariantTotalSizeAggregator) SizeConfiguration(com.android.tools.build.bundletool.model.SizeConfiguration) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

BuildApksResult (com.android.bundle.Commands.BuildApksResult)1 Variant (com.android.bundle.Commands.Variant)1 AssetModuleSizeAggregator (com.android.tools.build.bundletool.device.AssetModuleSizeAggregator)1 VariantMatcher (com.android.tools.build.bundletool.device.VariantMatcher)1 VariantTotalSizeAggregator (com.android.tools.build.bundletool.device.VariantTotalSizeAggregator)1 ConfigurationSizes (com.android.tools.build.bundletool.model.ConfigurationSizes)1 SizeConfiguration (com.android.tools.build.bundletool.model.SizeConfiguration)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1