use of com.android.bundle.Targeting.SdkVersionTargeting in project bundletool by google.
the class AbstractSizeAggregator method getSizesPerConfiguration.
protected ConfigurationSizes getSizesPerConfiguration(ImmutableSet<SdkVersionTargeting> sdkTargetingOptions, ImmutableSet<AbiTargeting> abiTargetingOptions, ImmutableSet<LanguageTargeting> languageTargetingOptions, ImmutableSet<ScreenDensityTargeting> screenDensityTargetingOptions, ImmutableSet<TextureCompressionFormatTargeting> textureCompressionFormatTargetingOptions, ImmutableSet<DeviceTierTargeting> deviceTierTargetingOptions) {
Map<SizeConfiguration, Long> minSizeByConfiguration = new HashMap<>();
Map<SizeConfiguration, Long> maxSizeByConfiguration = new HashMap<>();
for (SdkVersionTargeting sdkVersionTargeting : sdkTargetingOptions) {
for (AbiTargeting abiTargeting : abiTargetingOptions) {
for (ScreenDensityTargeting screenDensityTargeting : screenDensityTargetingOptions) {
for (LanguageTargeting languageTargeting : languageTargetingOptions) {
for (TextureCompressionFormatTargeting textureCompressionFormatTargeting : textureCompressionFormatTargetingOptions) {
for (DeviceTierTargeting deviceTierTargeting : deviceTierTargetingOptions) {
SizeConfiguration configuration = mergeWithDeviceSpec(getSizeConfiguration(sdkVersionTargeting, abiTargeting, screenDensityTargeting, languageTargeting, textureCompressionFormatTargeting, deviceTierTargeting), getSizeRequest.getDeviceSpec());
long compressedSize = getCompressedSize(getMatchingApks(sdkVersionTargeting, abiTargeting, screenDensityTargeting, languageTargeting, textureCompressionFormatTargeting, deviceTierTargeting));
minSizeByConfiguration.merge(configuration, compressedSize, Math::min);
maxSizeByConfiguration.merge(configuration, compressedSize, Math::max);
}
}
}
}
}
}
return ConfigurationSizes.create(/* minSizeConfigurationMap= */
ImmutableMap.copyOf(minSizeByConfiguration), /* maxSizeConfigurationMap= */
ImmutableMap.copyOf(maxSizeByConfiguration));
}
use of com.android.bundle.Targeting.SdkVersionTargeting in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_apkNotificationMessageKeyApexBundle_previewTargetSdk.
@Test
public void buildApksCommand_apkNotificationMessageKeyApexBundle_previewTargetSdk() throws Exception {
ApexImages apexConfig = apexImages(targetedApexImage("apex/x86_64.img", apexImageTargeting("x86_64")), targetedApexImage("apex/x86.img", apexImageTargeting("x86")), targetedApexImage("apex/arm64-v8a.img", apexImageTargeting("arm64-v8a")), targetedApexImage("apex/armeabi-v7a.img", apexImageTargeting("armeabi-v7a")));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile(APEX_MANIFEST_PATH, APEX_MANIFEST).addFile("apex/x86_64.img").addFile("apex/x86.img").addFile("apex/arm64-v8a.img").addFile("apex/armeabi-v7a.img").setApexConfig(apexConfig).setManifest(androidManifest("com.test.app", withTargetSdkVersion("Q.fingerprint"), withMinSdkVersion("Q.fingerprint")))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).build());
buildApksManager.execute();
ImmutableSet<AbiAlias> x64Set = ImmutableSet.of(X86_64);
ImmutableSet<AbiAlias> x86Set = ImmutableSet.of(X86);
ImmutableSet<AbiAlias> arm8Set = ImmutableSet.of(ARM64_V8A);
ImmutableSet<AbiAlias> arm7Set = ImmutableSet.of(ARMEABI_V7A);
ImmutableSet<ImmutableSet<AbiAlias>> allTargeting = ImmutableSet.of(arm7Set, arm8Set, x86Set, x64Set);
ApkTargeting x64Targeting = apkMultiAbiTargetingFromAllTargeting(x64Set, allTargeting);
ApkTargeting x86Targeting = apkMultiAbiTargetingFromAllTargeting(x86Set, allTargeting);
ApkTargeting arm8Targeting = apkMultiAbiTargetingFromAllTargeting(arm8Set, allTargeting);
ApkTargeting arm7Targeting = apkMultiAbiTargetingFromAllTargeting(arm7Set, allTargeting);
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
ImmutableMap<ApkTargeting, Variant> apexVariantsByAbi = extractApexVariantsByTargeting(result);
assertThat(apexVariantsByAbi.keySet()).containsExactly(x64Targeting, x86Targeting, arm8Targeting, arm7Targeting);
assertThat(apexVariantsByAbi.values().stream().map(variant -> variant.getTargeting().getSdkVersionTargeting()).collect(toImmutableSet())).containsExactly(sdkVersionTargeting(sdkVersionFrom(DEVELOPMENT_SDK_VERSION), ImmutableSet.of()));
}
Aggregations