use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class VariantTotalSizeAggregatorTest method getSize_standaloneVariant_withDimensionsAndWithoutDeviceSpec.
@Test
public void getSize_standaloneVariant_withDimensionsAndWithoutDeviceSpec() {
ZipPath apk = ZipPath.create("sample.apk");
Variant variant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(ARMEABI_V7A, ImmutableSet.of(X86, ARM64_V8A)), variantDensityTargeting(XHDPI, ImmutableSet.of(MDPI, LDPI))), ApkTargeting.getDefaultInstance(), apk);
ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("sample.apk", 20L), BundleToolVersion.getCurrentVersion(), variant, getSizeCommand.setDimensions(ImmutableSet.of(ABI, SCREEN_DENSITY, LANGUAGE, SDK)).build()).getSize();
assertThat(configurationSizes.getMinSizeConfigurationMap()).isEqualTo(configurationSizes.getMaxSizeConfigurationMap());
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setAbi("armeabi-v7a").setScreenDensity("XHDPI").setSdkVersion("1-20").build(), 20L);
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class ConfigurationSizesMergerTest method merge_withSubsetOfConfiguration.
@Test
public void merge_withSubsetOfConfiguration() throws Exception {
ConfigurationSizes configurationSizes1 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").setSdkVersion("21-").build(), 10L, SizeConfiguration.builder().setAbi("x86_64").setSdkVersion("21-").build(), 15L), ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").setSdkVersion("21-").build(), 20L, SizeConfiguration.builder().setAbi("x86_64").setSdkVersion("21-").build(), 25L));
ConfigurationSizes configurationSizes2 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.builder().setSdkVersion("21-").build(), 0L), ImmutableMap.of(SizeConfiguration.builder().setSdkVersion("21-").build(), 0L));
ConfigurationSizes mergedConfigurationSizes = ConfigurationSizesMerger.merge(configurationSizes1, configurationSizes2);
assertThat(mergedConfigurationSizes.getMinSizeConfigurationMap()).isEqualTo(configurationSizes1.getMinSizeConfigurationMap());
assertThat(mergedConfigurationSizes.getMaxSizeConfigurationMap()).isEqualTo(configurationSizes1.getMaxSizeConfigurationMap());
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes 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);
}
Aggregations