use of com.android.bundle.Targeting.VariantTargeting in project bundletool by google.
the class VariantTotalSizeAggregator method getSizeStandaloneVariant.
private ConfigurationSizes getSizeStandaloneVariant() {
checkState(!getSizeRequest.getInstant(), "Standalone Variants can't be selected when instant flag is set");
// When modules are specified we ignore standalone variants.
if (getSizeRequest.getModules().isPresent()) {
return ConfigurationSizes.create(ImmutableMap.of(), ImmutableMap.of());
}
VariantTargeting variantTargeting = variant.getTargeting();
SizeConfiguration sizeConfiguration = mergeWithDeviceSpec(getSizeConfiguration(variantTargeting.getSdkVersionTargeting(), variantTargeting.getAbiTargeting(), variantTargeting.getScreenDensityTargeting(), LanguageTargeting.getDefaultInstance(), variantTargeting.getTextureCompressionFormatTargeting(), DeviceTierTargeting.getDefaultInstance()), getSizeRequest.getDeviceSpec());
// Variants of standalone APKs have only one APK each.
long compressedSize = sizeByApkPaths.get(Iterables.getOnlyElement(Iterables.getOnlyElement(variant.getApkSetList()).getApkDescriptionList()).getPath());
ImmutableMap<SizeConfiguration, Long> sizeConfigurationMap = ImmutableMap.of(sizeConfiguration, compressedSize);
return ConfigurationSizes.create(sizeConfigurationMap, sizeConfigurationMap);
}
use of com.android.bundle.Targeting.VariantTargeting in project bundletool by google.
the class DexCompressionVariantGeneratorTest method variantsGeneration_withoutDexFile_generatesNoVariant.
@Test
public void variantsGeneration_withoutDexFile_generatesNoVariant() throws Exception {
DexCompressionVariantGenerator dexCompressionVariantGenerator = new DexCompressionVariantGenerator(ApkGenerationConfiguration.builder().setEnableDexCompressionSplitter(true).build());
BundleModule bundleModule = new BundleModuleBuilder("testModule").addFile("assets/leftover.txt").setManifest(androidManifest("com.test.app")).build();
ImmutableCollection<VariantTargeting> splits = dexCompressionVariantGenerator.generate(bundleModule).collect(toImmutableList());
assertThat(splits).isEmpty();
}
use of com.android.bundle.Targeting.VariantTargeting in project bundletool by google.
the class SplitApksGeneratorTest method multipleModules_withOnlyBaseModuleWithNativeLibrariesOtherModuleWithDexFiles.
@Test
public void multipleModules_withOnlyBaseModuleWithNativeLibrariesOtherModuleWithDexFiles() throws Exception {
ImmutableList<BundleModule> bundleModule = ImmutableList.of(new BundleModuleBuilder("base").addFile("assets/leftover.txt").addFile("lib/x86_64/libsome.so").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(AbiAlias.X86_64)))).build(), new BundleModuleBuilder("test").addFile("assets/test.txt").addFile("dex/classes.dex").setManifest(androidManifest("com.test.app")).build());
ImmutableList<ModuleSplit> moduleSplits = splitApksGenerator.generateSplits(bundleModule, ApkGenerationConfiguration.builder().setEnableUncompressedNativeLibraries(true).setEnableDexCompressionSplitter(true).build());
VariantTargeting lVariantTargeting = variantMinSdkTargeting(/* minSdkVersion= */
ANDROID_L_API_VERSION, /* alternativeSdkVersions...= */
ANDROID_M_API_VERSION, ANDROID_Q_API_VERSION);
VariantTargeting mVariantTargeting = variantMinSdkTargeting(/* minSdkVersion= */
ANDROID_M_API_VERSION, /* alternativeSdkVersions...= */
ANDROID_L_API_VERSION, ANDROID_Q_API_VERSION);
VariantTargeting qVariantTargeting = variantMinSdkTargeting(/* minSdkVersion= */
ANDROID_Q_API_VERSION, /* alternativeSdkVersions...= */
ANDROID_L_API_VERSION, ANDROID_M_API_VERSION);
// 2 splits for L, M, P variants.
assertThat(moduleSplits).hasSize(6);
assertThat(moduleSplits.stream().map(ModuleSplit::getVariantTargeting).collect(toImmutableSet())).containsExactly(lVariantTargeting, mVariantTargeting, qVariantTargeting);
ModuleSplit baseLModule = getModuleSplit(moduleSplits, lVariantTargeting, "base");
assertThat(baseLModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(baseLModule.getEntries())).containsExactly("assets/leftover.txt", "lib/x86_64/libsome.so");
assertThat(getForceUncompressed(baseLModule, "lib/x86_64/libsome.so")).isFalse();
ModuleSplit testLModule = getModuleSplit(moduleSplits, lVariantTargeting, "test");
assertThat(testLModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(testLModule.getEntries())).containsExactly("assets/test.txt", "dex/classes.dex");
assertThat(getForceUncompressed(testLModule, "dex/classes.dex")).isFalse();
ModuleSplit baseMModule = getModuleSplit(moduleSplits, mVariantTargeting, "base");
assertThat(baseMModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(baseMModule.getEntries())).containsExactly("assets/leftover.txt", "lib/x86_64/libsome.so");
assertThat(getForceUncompressed(baseMModule, "lib/x86_64/libsome.so")).isTrue();
ModuleSplit testMModule = getModuleSplit(moduleSplits, mVariantTargeting, "test");
assertThat(testMModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(testMModule.getEntries())).containsExactly("assets/test.txt", "dex/classes.dex");
assertThat(getForceUncompressed(testMModule, "dex/classes.dex")).isFalse();
ModuleSplit basePModule = getModuleSplit(moduleSplits, qVariantTargeting, "base");
assertThat(basePModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(basePModule.getEntries())).containsExactly("assets/leftover.txt", "lib/x86_64/libsome.so");
assertThat(getForceUncompressed(basePModule, "lib/x86_64/libsome.so")).isTrue();
ModuleSplit testPModule = getModuleSplit(moduleSplits, qVariantTargeting, "test");
assertThat(testPModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(testPModule.getEntries())).containsExactly("assets/test.txt", "dex/classes.dex");
assertThat(getForceUncompressed(testPModule, "dex/classes.dex")).isTrue();
}
use of com.android.bundle.Targeting.VariantTargeting in project bundletool by google.
the class VariantGeneratorTest method variantsWithV3SigningRestrictedToRPlus_minSdkAffectsRPlusVariant.
@Test
public void variantsWithV3SigningRestrictedToRPlus_minSdkAffectsRPlusVariant() throws Exception {
BundleModule bundleModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app", withMinSdkVersion(ANDROID_R_API_VERSION + 1))).build();
VariantGenerator variantGenerator = new VariantGenerator();
ImmutableCollection<VariantTargeting> splits = variantGenerator.generateVariants(bundleModule, ApkGenerationConfiguration.builder().setMinSdkForAdditionalVariantWithV3Rotation(ANDROID_R_API_VERSION).build());
assertThat(splits).containsExactly(variantMinSdkTargeting(ANDROID_R_API_VERSION + 1));
}
use of com.android.bundle.Targeting.VariantTargeting in project bundletool by google.
the class VariantGeneratorTest method variantsWithV3SigningRestrictedToRPlus_maxSdkRemovesRPlusVariant.
@Test
public void variantsWithV3SigningRestrictedToRPlus_maxSdkRemovesRPlusVariant() throws Exception {
BundleModule bundleModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app", withMaxSdkVersion(ANDROID_R_API_VERSION - 1))).build();
VariantGenerator variantGenerator = new VariantGenerator();
ImmutableCollection<VariantTargeting> splits = variantGenerator.generateVariants(bundleModule, ApkGenerationConfiguration.builder().setMinSdkForAdditionalVariantWithV3Rotation(ANDROID_R_API_VERSION).build());
assertThat(splits).containsExactly(lPlusVariantTargeting());
}
Aggregations