use of com.android.bundle.Commands.Variant in project bundletool by google.
the class BuildSdkApksManagerTest method sdkManifestMutation_highMinSdkVersion_minSdkVersionUnchanged.
@Test
public void sdkManifestMutation_highMinSdkVersion_minSdkVersionUnchanged() throws Exception {
SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withMinSdkVersion(SDK_SANDBOX_MIN_VERSION + 5), withSdkLibraryElement("20"), withMetadataValue(SDK_PATCH_VERSION_ATTRIBUTE_NAME, "12"))).build()).build();
execute(sdkBundle);
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
Variant variant = result.getVariant(0);
ApkDescription apkDescription = variant.getApkSet(0).getApkDescription(0);
File apkFile = extractFromApkSetFile(apkSetFile, apkDescription.getPath(), tmpDir);
AndroidManifest manifest = extractAndroidManifest(apkFile, tmpDir);
assertThat(manifest.getMinSdkVersion()).hasValue(SDK_SANDBOX_MIN_VERSION + 5);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class GetSizeCommandTest method getSizeTotalInternal_multipleDimensions.
@Test
public void getSizeTotalInternal_multipleDimensions() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkDensityTargeting(LDPI, ImmutableSet.of(MDPI)), ZipPath.create("base-ldpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkDensityTargeting(MDPI, ImmutableSet.of(LDPI)), ZipPath.create("base-mdpi.apk"), /* isMasterSplit= */
false)));
Variant preLVariant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(15), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(ARMEABI, ImmutableSet.of(X86))), ApkTargeting.getDefaultInstance(), ZipPath.create("preL.apk"));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).addVariant(preLVariant).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ConfigurationSizes configurationSizes = GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDimensions(ImmutableSet.of(Dimension.SDK, Dimension.ABI, Dimension.LANGUAGE, Dimension.SCREEN_DENSITY)).build().getSizeTotalInternal();
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("LDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("MDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("15-20").setAbi("armeabi").build(), compressedApkSize);
assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("LDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("MDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("15-20").setAbi("armeabi").build(), compressedApkSize);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class GetSizeCommandTest method getSizeTotal_withDimensionsAndDeviceSpec.
@Test
public void getSizeTotal_withDimensionsAndDeviceSpec() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkDensityTargeting(LDPI, ImmutableSet.of(MDPI)), ZipPath.create("base-ldpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkDensityTargeting(MDPI, ImmutableSet.of(LDPI)), ZipPath.create("base-mdpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(X86, ImmutableSet.of(X86_64)), ZipPath.create("base-x86.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(X86_64, ImmutableSet.of(X86)), ZipPath.create("base-x86_64.apk"), /* isMasterSplit= */
false)));
Variant preLVariant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(15), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(X86), variantDensityTargeting(LDPI)), ApkTargeting.getDefaultInstance(), ZipPath.create("preL.apk"));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).addVariant(preLVariant).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDeviceSpec(DeviceSpec.newBuilder().setScreenDensity(124).addSupportedAbis("x86").build()).setDimensions(ImmutableSet.of(Dimension.ABI, Dimension.SCREEN_DENSITY)).build().getSizeTotal(new PrintStream(outputStream));
assertThat(new String(outputStream.toByteArray(), UTF_8)).isEqualTo("ABI,SCREEN_DENSITY,MIN,MAX" + CRLF + String.format("x86,124,%d,%d", compressedApkSize, 3 * compressedApkSize) + CRLF);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class GetSizeCommandTest method getSizeTotalInternal_singleSplitVariant.
@Test
public void getSizeTotalInternal_singleSplitVariant() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkAbiTargeting(X86, ImmutableSet.of(X86_64)), ZipPath.create("base-x86.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(X86_64, ImmutableSet.of(X86)), ZipPath.create("base-x86_64.apk"), /* isMasterSplit= */
false)));
ZipBuilder archiveBuilder = new ZipBuilder();
archiveBuilder.addFileWithContent(ZipPath.create("base-master.apk"), DUMMY_BYTES);
archiveBuilder.addFileWithContent(ZipPath.create("base-x86.apk"), DUMMY_BYTES, // APK stored uncompressed in the APKs zip.
EntryOption.UNCOMPRESSED);
archiveBuilder.addFileWithContent(ZipPath.create("base-x86_64.apk"), new byte[10000]);
archiveBuilder.addFileWithProtoContent(ZipPath.create("toc.pb"), BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).build());
Path apksArchiveFile = archiveBuilder.writeTo(tmpDir.resolve("bundle.apks"));
ConfigurationSizes configurationSizes = GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).build().getSizeTotalInternal();
assertThat(configurationSizes.getMinSizeConfigurationMap().keySet()).containsExactly(SizeConfiguration.getDefaultInstance());
assertThat(configurationSizes.getMinSizeConfigurationMap().get(SizeConfiguration.getDefaultInstance())).isEqualTo(// base+x86
2 * compressedApkSize);
assertThat(configurationSizes.getMaxSizeConfigurationMap().keySet()).containsExactly(SizeConfiguration.getDefaultInstance());
assertThat(configurationSizes.getMaxSizeConfigurationMap().get(SizeConfiguration.getDefaultInstance())).isGreaterThan(// base+x86_64
2 * compressedApkSize);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class GetSizeCommandTest method getSizeTotal_withAssetModulesAndDeviceSpec.
@Test
public void getSizeTotal_withAssetModulesAndDeviceSpec() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkAbiTargeting(X86, ImmutableSet.of(X86_64)), ZipPath.create("base-x86.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(X86_64, ImmutableSet.of(X86)), ZipPath.create("base-x86_64.apk"), /* isMasterSplit= */
false)));
AssetSliceSet assetModule = createAssetSliceSet(/* moduleName= */
"asset1", DeliveryType.INSTALL_TIME, createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("asset1-master.apk")), createApkDescription(apkTextureTargeting(ETC2, ImmutableSet.of(ASTC)), ZipPath.create("asset1-tcf_etc2.apk"), /* isMasterSplit= */
false), createApkDescription(apkTextureTargeting(ASTC, ImmutableSet.of(ETC2)), ZipPath.create("asset1-tcf_astc.apk"), /* isMasterSplit= */
false));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).addAssetSliceSet(assetModule).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDimensions(ImmutableSet.of(Dimension.ABI, Dimension.TEXTURE_COMPRESSION_FORMAT, Dimension.SDK)).setDeviceSpec(DeviceSpec.newBuilder().setSdkVersion(25).addSupportedAbis("x86").addGlExtensions("GL_KHR_texture_compression_astc_ldr").build()).build().getSizeTotal(new PrintStream(outputStream));
assertThat(new String(outputStream.toByteArray(), UTF_8)).isEqualTo("SDK,ABI,TEXTURE_COMPRESSION_FORMAT,MIN,MAX" + CRLF + String.format("%s,%s,%s,%d,%d", "25", "x86", "astc", 4 * compressedApkSize, 4 * compressedApkSize) + CRLF);
}
Aggregations