提交 9831cec4 编写于 作者: I Iurii Makhno

Prepare for release 0.14.0.

上级 24e8e6ef
......@@ -26,4 +26,4 @@ https://developer.android.com/studio/command-line/bundletool
## Releases
Latest release: [0.13.4](https://github.com/google/bundletool/releases)
Latest release: [0.14.0](https://github.com/google/bundletool/releases)
release_version = 0.13.4
release_version = 0.14.0
......@@ -23,6 +23,7 @@ import com.android.tools.build.bundletool.commands.ExtractApksCommand;
import com.android.tools.build.bundletool.commands.GetDeviceSpecCommand;
import com.android.tools.build.bundletool.commands.GetSizeCommand;
import com.android.tools.build.bundletool.commands.InstallApksCommand;
import com.android.tools.build.bundletool.commands.InstallMultiApksCommand;
import com.android.tools.build.bundletool.commands.ValidateBundleCommand;
import com.android.tools.build.bundletool.commands.VersionCommand;
import com.android.tools.build.bundletool.device.AdbServer;
......@@ -88,6 +89,11 @@ public class BundleToolMain {
InstallApksCommand.fromFlags(flags, adbServer).execute();
}
break;
case InstallMultiApksCommand.COMMAND_NAME:
try (AdbServer adbServer = DdmlibAdbServer.getInstance()) {
InstallMultiApksCommand.fromFlags(flags, adbServer).execute();
}
break;
case ValidateBundleCommand.COMMAND_NAME:
ValidateBundleCommand.fromFlags(flags).execute();
break;
......@@ -134,6 +140,7 @@ public class BundleToolMain {
ExtractApksCommand.help(),
GetDeviceSpecCommand.help(),
InstallApksCommand.help(),
InstallMultiApksCommand.help(),
ValidateBundleCommand.help(),
DumpCommand.help(),
GetSizeCommand.help(),
......@@ -165,6 +172,9 @@ public class BundleToolMain {
case InstallApksCommand.COMMAND_NAME:
commandHelp = InstallApksCommand.help();
break;
case InstallMultiApksCommand.COMMAND_NAME:
commandHelp = InstallMultiApksCommand.help();
break;
case ValidateBundleCommand.COMMAND_NAME:
commandHelp = ValidateBundleCommand.help();
break;
......
......@@ -20,6 +20,7 @@ import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBu
import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.SYSTEM;
import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.SYSTEM_COMPRESSED;
import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.UNIVERSAL;
import static com.android.tools.build.bundletool.commands.CommandUtils.ANDROID_SERIAL_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.ANDROID_HOME_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.SYSTEM_PATH_VARIABLE;
import static com.google.common.base.Preconditions.checkArgument;
......@@ -42,7 +43,6 @@ import com.android.tools.build.bundletool.model.SourceStamp;
import com.android.tools.build.bundletool.model.exceptions.CommandExecutionException;
import com.android.tools.build.bundletool.model.exceptions.ValidationException;
import com.android.tools.build.bundletool.model.utils.DefaultSystemEnvironmentProvider;
import com.android.tools.build.bundletool.model.utils.SdkToolsLocator;
import com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider;
import com.android.tools.build.bundletool.splitters.DexCompressionSplitter;
import com.android.tools.build.bundletool.splitters.NativeLibrariesCompressionSplitter;
......@@ -113,7 +113,6 @@ public abstract class BuildApksCommand {
private static final Flag<Path> ADB_PATH_FLAG = Flag.path("adb");
private static final Flag<Boolean> CONNECTED_DEVICE_FLAG = Flag.booleanFlag("connected-device");
private static final Flag<String> DEVICE_ID_FLAG = Flag.string("device-id");
private static final String ANDROID_SERIAL_VARIABLE = "ANDROID_SERIAL";
private static final Flag<ImmutableSet<String>> MODULES_FLAG = Flag.stringSet("modules");
private static final Flag<Path> DEVICE_SPEC_FLAG = Flag.path("device-spec");
......@@ -492,19 +491,8 @@ public abstract class BuildApksCommand {
// Applied only when --connected-device flag is set, because we don't want to fail command
// if ADB cannot be found in a normal mode.
Optional<Path> adbPathFromFlag = ADB_PATH_FLAG.getValue(flags);
if (connectedDeviceMode) {
Path adbPath =
adbPathFromFlag.orElseGet(
() ->
new SdkToolsLocator()
.locateAdb(systemEnvironmentProvider)
.orElseThrow(
() ->
new CommandExecutionException(
"Unable to determine the location of ADB. Please set the --adb "
+ "flag or define ANDROID_HOME or PATH environment "
+ "variable.")));
Path adbPath = CommandUtils.getAdbPath(flags, ADB_PATH_FLAG, systemEnvironmentProvider);
buildApksCommand.setAdbPath(adbPath).setAdbServer(adbServer);
}
......@@ -531,22 +519,11 @@ public abstract class BuildApksCommand {
public Path execute() {
try (TempDirectory tempDir = new TempDirectory()) {
Aapt2Command aapt2 =
getAapt2Command().orElseGet(() -> extractAapt2FromJar(tempDir.getPath()));
getAapt2Command().orElseGet(() -> CommandUtils.extractAapt2FromJar(tempDir.getPath()));
return new BuildApksManager(this, aapt2, tempDir.getPath()).execute();
}
}
private static Aapt2Command extractAapt2FromJar(Path tempDir) {
return new SdkToolsLocator()
.extractAapt2(tempDir)
.map(Aapt2Command::createFromExecutablePath)
.orElseThrow(
() ->
new CommandExecutionException(
"Could not extract aapt2: consider updating bundletool to a more recent "
+ "version or providing the path to aapt2 using the flag --aapt2."));
}
/**
* Creates an internal executor service that uses at most the given number of threads.
*
......
......@@ -64,6 +64,7 @@ import com.android.tools.build.bundletool.model.version.Version;
import com.android.tools.build.bundletool.optimizations.ApkOptimizations;
import com.android.tools.build.bundletool.optimizations.OptimizationsMerger;
import com.android.tools.build.bundletool.preprocessors.AppBundle64BitNativeLibrariesPreprocessor;
import com.android.tools.build.bundletool.preprocessors.EmbeddedApkSigningPreprocessor;
import com.android.tools.build.bundletool.preprocessors.EntryCompressionPreprocessor;
import com.android.tools.build.bundletool.preprocessors.LocalTestingPreprocessor;
import com.android.tools.build.bundletool.splitters.ApkGenerationConfiguration;
......@@ -184,7 +185,7 @@ final class BuildApksManager {
// Note: Universal APK is a special type of standalone, with no optimization dimensions.
ImmutableList<BundleModule> modulesToFuse =
requestedModules.isEmpty()
? modulesToFuse(appBundle.getFeatureModules().values().asList())
? modulesToFuse(getModulesForStandaloneApks(appBundle))
: requestedModules.asList();
generatedApksBuilder.setStandaloneApks(
new ShardedApksGenerator(
......@@ -521,6 +522,7 @@ final class BuildApksManager {
bundle = new LocalTestingPreprocessor().preprocess(bundle);
}
bundle = new EntryCompressionPreprocessor().preprocess(bundle);
bundle = new EmbeddedApkSigningPreprocessor().preprocess(bundle);
return bundle;
}
......
......@@ -316,9 +316,7 @@ public abstract class BuildBundleCommand {
}
return Optional.of(
new TargetingGenerator()
.generateTargetingForApexImages(
module.getBundleConfig().getApexConfig(), apexImageFiles, hasBuildInfo));
new TargetingGenerator().generateTargetingForApexImages(apexImageFiles, hasBuildInfo));
}
private static BundleConfig parseBundleConfigJson(Path bundleConfigJsonPath) {
......
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.tools.build.bundletool.commands;
import com.android.tools.build.bundletool.flags.Flag;
import com.android.tools.build.bundletool.flags.ParsedFlags;
import com.android.tools.build.bundletool.model.Aapt2Command;
import com.android.tools.build.bundletool.model.exceptions.CommandExecutionException;
import com.android.tools.build.bundletool.model.utils.SdkToolsLocator;
import com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider;
import java.nio.file.Path;
import java.util.Optional;
final class CommandUtils {
static final String ANDROID_SERIAL_VARIABLE = "ANDROID_SERIAL";
private CommandUtils() {}
static Path getAdbPath(
ParsedFlags flags, Flag<Path> adbFlag, SystemEnvironmentProvider systemEnvironmentProvider) {
return adbFlag
.getValue(flags)
.orElseGet(
() ->
new SdkToolsLocator()
.locateAdb(systemEnvironmentProvider)
.orElseThrow(
() ->
new CommandExecutionException(
"Unable to determine the location of ADB. Please set the --adb "
+ "flag or define ANDROID_HOME or PATH environment "
+ "variable.")));
}
static Optional<String> getDeviceSerialName(
ParsedFlags flags,
Flag<String> deviceIdFlag,
SystemEnvironmentProvider systemEnvironmentProvider) {
Optional<String> deviceSerialName = deviceIdFlag.getValue(flags);
if (!deviceSerialName.isPresent()) {
deviceSerialName = systemEnvironmentProvider.getVariable(ANDROID_SERIAL_VARIABLE);
}
return deviceSerialName;
}
static Aapt2Command extractAapt2FromJar(Path tempDir) {
return new SdkToolsLocator()
.extractAapt2(tempDir)
.map(Aapt2Command::createFromExecutablePath)
.orElseThrow(
() ->
new CommandExecutionException(
"Could not extract aapt2: consider updating bundletool to a more recent "
+ "version or providing the path to aapt2 using the flag --aapt2."));
}
}
......@@ -16,6 +16,7 @@
package com.android.tools.build.bundletool.commands;
import static com.android.tools.build.bundletool.commands.CommandUtils.ANDROID_SERIAL_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.ANDROID_HOME_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.SYSTEM_PATH_VARIABLE;
import static java.nio.charset.StandardCharsets.UTF_8;
......@@ -27,10 +28,8 @@ import com.android.tools.build.bundletool.device.AdbServer;
import com.android.tools.build.bundletool.device.DeviceAnalyzer;
import com.android.tools.build.bundletool.flags.Flag;
import com.android.tools.build.bundletool.flags.ParsedFlags;
import com.android.tools.build.bundletool.model.exceptions.CommandExecutionException;
import com.android.tools.build.bundletool.model.exceptions.ValidationException;
import com.android.tools.build.bundletool.model.utils.DefaultSystemEnvironmentProvider;
import com.android.tools.build.bundletool.model.utils.SdkToolsLocator;
import com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider;
import com.android.tools.build.bundletool.model.utils.files.FilePreconditions;
import com.google.auto.value.AutoValue;
......@@ -56,8 +55,6 @@ public abstract class GetDeviceSpecCommand {
private static final Flag<Path> OUTPUT_FLAG = Flag.path("output");
private static final Flag<Boolean> OVERWRITE_OUTPUT_FLAG = Flag.booleanFlag("overwrite");
private static final String ANDROID_SERIAL_VARIABLE = "ANDROID_SERIAL";
private static final SystemEnvironmentProvider DEFAULT_PROVIDER =
new DefaultSystemEnvironmentProvider();
......@@ -123,25 +120,11 @@ public abstract class GetDeviceSpecCommand {
GetDeviceSpecCommand.Builder builder =
builder().setAdbServer(adbServer).setOutputPath(OUTPUT_FLAG.getRequiredValue(flags));
Optional<String> deviceSerialName = DEVICE_ID_FLAG.getValue(flags);
if (!deviceSerialName.isPresent()) {
deviceSerialName = systemEnvironmentProvider.getVariable(ANDROID_SERIAL_VARIABLE);
}
Optional<String> deviceSerialName =
CommandUtils.getDeviceSerialName(flags, DEVICE_ID_FLAG, systemEnvironmentProvider);
deviceSerialName.ifPresent(builder::setDeviceId);
Path adbPath =
ADB_PATH_FLAG
.getValue(flags)
.orElseGet(
() ->
new SdkToolsLocator()
.locateAdb(systemEnvironmentProvider)
.orElseThrow(
() ->
new CommandExecutionException(
"Unable to determine the location of ADB. Please set the --adb "
+ "flag or define ANDROID_HOME or PATH environment "
+ "variable.")));
Path adbPath = CommandUtils.getAdbPath(flags, ADB_PATH_FLAG, systemEnvironmentProvider);
builder.setAdbPath(adbPath);
OVERWRITE_OUTPUT_FLAG.getValue(flags).ifPresent(builder::setOverwriteOutput);
......
......@@ -19,17 +19,21 @@ package com.android.tools.build.bundletool.commands;
import static com.android.tools.build.bundletool.commands.GetSizeCommand.GetSizeSubcommand.STRING_TO_SUBCOMMAND;
import static com.android.tools.build.bundletool.commands.GetSizeCommand.GetSizeSubcommand.TOTAL;
import static com.android.tools.build.bundletool.model.utils.ApkSizeUtils.getCompressedSizeByApkPaths;
import static com.android.tools.build.bundletool.model.utils.ApkSizeUtils.getVariantCompressedSizeByApkPaths;
import static com.android.tools.build.bundletool.model.utils.CollectorUtils.combineMaps;
import static com.android.tools.build.bundletool.model.utils.GetSizeCsvUtils.getSizeTotalOutputInCsv;
import static com.android.tools.build.bundletool.model.utils.files.FilePreconditions.checkFileExistsAndReadable;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static java.util.function.Function.identity;
import com.android.bundle.Commands.ApkDescription;
import com.android.bundle.Commands.BuildApksResult;
import com.android.bundle.Commands.Variant;
import com.android.bundle.Devices.DeviceSpec;
import com.android.tools.build.bundletool.commands.CommandHelp.CommandDescription;
import com.android.tools.build.bundletool.commands.CommandHelp.FlagDescription;
import com.android.tools.build.bundletool.device.AssetModuleSizeAggregator;
import com.android.tools.build.bundletool.device.DeviceSpecParser;
import com.android.tools.build.bundletool.device.VariantMatcher;
import com.android.tools.build.bundletool.device.VariantTotalSizeAggregator;
......@@ -40,6 +44,7 @@ import com.android.tools.build.bundletool.model.GetSizeRequest;
import com.android.tools.build.bundletool.model.GetSizeRequest.Dimension;
import com.android.tools.build.bundletool.model.SizeConfiguration;
import com.android.tools.build.bundletool.model.exceptions.ValidationException;
import com.android.tools.build.bundletool.model.utils.ConfigurationSizesMerger;
import com.android.tools.build.bundletool.model.utils.ResultUtils;
import com.android.tools.build.bundletool.model.utils.files.FilePreconditions;
import com.android.tools.build.bundletool.model.version.Version;
......@@ -220,20 +225,37 @@ public abstract class GetSizeCommand implements GetSizeRequest {
ImmutableList<Variant> variants =
new VariantMatcher(getDeviceSpec(), getInstant()).getAllMatchingVariants(buildApksResult);
ImmutableMap<String, Long> compressedSizeByApkPaths =
getCompressedSizeByApkPaths(variants, getApksArchivePath());
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 configurationSizes =
ConfigurationSizes variantConfigurationSizes =
new VariantTotalSizeAggregator(
compressedSizeByApkPaths,
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);
......
......@@ -16,6 +16,7 @@
package com.android.tools.build.bundletool.commands;
import static com.android.tools.build.bundletool.commands.CommandUtils.ANDROID_SERIAL_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.ANDROID_HOME_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.SYSTEM_PATH_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.files.FilePreconditions.checkDirectoryExists;
......@@ -42,7 +43,6 @@ import com.android.tools.build.bundletool.io.TempDirectory;
import com.android.tools.build.bundletool.model.exceptions.CommandExecutionException;
import com.android.tools.build.bundletool.model.utils.DefaultSystemEnvironmentProvider;
import com.android.tools.build.bundletool.model.utils.ResultUtils;
import com.android.tools.build.bundletool.model.utils.SdkToolsLocator;
import com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
......@@ -65,8 +65,6 @@ public abstract class InstallApksCommand {
private static final Flag<Boolean> ALLOW_DOWNGRADE_FLAG = Flag.booleanFlag("allow-downgrade");
private static final Flag<Boolean> ALLOW_TEST_ONLY_FLAG = Flag.booleanFlag("allow-test-only");
private static final String ANDROID_SERIAL_VARIABLE = "ANDROID_SERIAL";
private static final SystemEnvironmentProvider DEFAULT_PROVIDER =
new DefaultSystemEnvironmentProvider();
......@@ -118,24 +116,10 @@ public abstract class InstallApksCommand {
public static InstallApksCommand fromFlags(
ParsedFlags flags, SystemEnvironmentProvider systemEnvironmentProvider, AdbServer adbServer) {
Path apksArchivePath = APKS_ARCHIVE_FILE_FLAG.getRequiredValue(flags);
Path adbPath =
ADB_PATH_FLAG
.getValue(flags)
.orElseGet(
() ->
new SdkToolsLocator()
.locateAdb(systemEnvironmentProvider)
.orElseThrow(
() ->
new CommandExecutionException(
"Unable to determine the location of ADB. Please set the --adb "
+ "flag or define ANDROID_HOME or PATH environment "
+ "variable.")));
Optional<String> deviceSerialName = DEVICE_ID_FLAG.getValue(flags);
if (!deviceSerialName.isPresent()) {
deviceSerialName = systemEnvironmentProvider.getVariable(ANDROID_SERIAL_VARIABLE);
}
Path adbPath = CommandUtils.getAdbPath(flags, ADB_PATH_FLAG, systemEnvironmentProvider);
Optional<String> deviceSerialName =
CommandUtils.getDeviceSerialName(flags, DEVICE_ID_FLAG, systemEnvironmentProvider);
Optional<ImmutableSet<String>> modules = MODULES_FLAG.getValue(flags);
Optional<Boolean> allowDowngrade = ALLOW_DOWNGRADE_FLAG.getValue(flags);
......
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.tools.build.bundletool.device;
import static com.android.tools.build.bundletool.device.DeviceSpecUtils.isAbiMissing;
import static com.android.tools.build.bundletool.device.DeviceSpecUtils.isLocalesMissing;
import static com.android.tools.build.bundletool.device.DeviceSpecUtils.isScreenDensityMissing;
import static com.android.tools.build.bundletool.device.DeviceSpecUtils.isSdkVersionMissing;
import static com.android.tools.build.bundletool.model.GetSizeRequest.Dimension.ABI;
import static com.android.tools.build.bundletool.model.GetSizeRequest.Dimension.LANGUAGE;
import static com.android.tools.build.bundletool.model.GetSizeRequest.Dimension.SCREEN_DENSITY;
import static com.android.tools.build.bundletool.model.GetSizeRequest.Dimension.SDK;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import com.android.bundle.Commands.ApkDescription;
import com.android.bundle.Devices.DeviceSpec;
import com.android.bundle.Targeting.AbiTargeting;
import com.android.bundle.Targeting.ApkTargeting;
import com.android.bundle.Targeting.LanguageTargeting;
import com.android.bundle.Targeting.ScreenDensityTargeting;
import com.android.bundle.Targeting.SdkVersionTargeting;
import com.android.tools.build.bundletool.commands.GetSizeCommand;
import com.android.tools.build.bundletool.device.DeviceSpecUtils.DeviceSpecFromTargetingBuilder;
import com.android.tools.build.bundletool.model.ConfigurationSizes;
import com.android.tools.build.bundletool.model.GetSizeRequest;
import com.android.tools.build.bundletool.model.GetSizeRequest.Dimension;
import com.android.tools.build.bundletool.model.SizeConfiguration;
import com.android.tools.build.bundletool.model.ZipPath;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.HashMap;
import java.util.Map;
/**
* Common class to generate {@link ConfigurationSizes} for sets of APKs based on the requested
* dimensions passed to {@link GetSizeCommand}.
*
* <p>Subclasses should implement the high level logic to get the total size ({@link getSize}) and
* the logic to get the matching apks from a particular combination of targetings ({@link
* getMatchingApks}).
*/
public abstract class AbstractSizeAggregator {
private static final Joiner COMMA_JOINER = Joiner.on(',');
protected final ImmutableMap<String, Long> sizeByApkPaths;
protected final GetSizeRequest getSizeRequest;
protected AbstractSizeAggregator(
ImmutableMap<String, Long> sizeByApkPaths, GetSizeRequest getSizeRequest) {
this.sizeByApkPaths = sizeByApkPaths;
this.getSizeRequest = getSizeRequest;
}
/** Aggregate the sizes of a set of APKs info a {@link ConfigurationSizes}. */
public abstract ConfigurationSizes getSize();
protected abstract ImmutableList<ZipPath> getMatchingApks(
SdkVersionTargeting sdkVersionTargeting,
AbiTargeting abiTargeting,
ScreenDensityTargeting screenDensityTargeting,
LanguageTargeting languageTargeting);
protected ImmutableSet<SdkVersionTargeting> getAllSdkVersionTargetings(
ImmutableList<ApkDescription> apkDescriptions) {
ImmutableSet.Builder<SdkVersionTargeting> sdkVersionTargetingOptions = ImmutableSet.builder();
if (isSdkVersionMissing(getSizeRequest.getDeviceSpec())) {
sdkVersionTargetingOptions.addAll(
apkDescriptions.stream()
.map(ApkDescription::getTargeting)
.filter(ApkTargeting::hasSdkVersionTargeting)
.map(ApkTargeting::getSdkVersionTargeting)
.collect(toImmutableSet()));
}
// Adding default targeting (if targetings are empty) to help computing the cartesian product
// across all targetings.
return sdkVersionTargetingOptions.build().isEmpty()
? ImmutableSet.of(SdkVersionTargeting.getDefaultInstance())
: sdkVersionTargetingOptions.build();
}
protected ImmutableSet<AbiTargeting> getAllAbiTargetings(
ImmutableList<ApkDescription> apkDescriptions) {
ImmutableSet.Builder<AbiTargeting> abiTargetingOptions = ImmutableSet.builder();
if (isAbiMissing(getSizeRequest.getDeviceSpec())) {
abiTargetingOptions.addAll(
apkDescriptions.stream()
.map(ApkDescription::getTargeting)
.filter(ApkTargeting::hasAbiTargeting)
.map(ApkTargeting::getAbiTargeting)
.collect(toImmutableSet()));
}
// Adding default targeting (if targetings are empty) to help computing the cartesian product
// across all targetings.
return abiTargetingOptions.build().isEmpty()
? ImmutableSet.of(AbiTargeting.getDefaultInstance())
: abiTargetingOptions.build();
}
protected ImmutableSet<ScreenDensityTargeting> getAllScreenDensityTargetings(
ImmutableList<ApkDescription> apkDescriptions) {
ImmutableSet.Builder<ScreenDensityTargeting> screenDensityTargetingOptions =
ImmutableSet.builder();
if (isScreenDensityMissing(getSizeRequest.getDeviceSpec())) {
screenDensityTargetingOptions.addAll(
apkDescriptions.stream()
.map(ApkDescription::getTargeting)
.filter(ApkTargeting::hasScreenDensityTargeting)
.map(ApkTargeting::getScreenDensityTargeting)
.collect(toImmutableSet()));
}
// Adding default targeting (if targetings are empty) to help computing the cartesian product
// across all targetings.
return screenDensityTargetingOptions.build().isEmpty()
? ImmutableSet.of(ScreenDensityTargeting.getDefaultInstance())
: screenDensityTargetingOptions.build();
}
protected ImmutableSet<LanguageTargeting> getAllLanguageTargetings(
ImmutableList<ApkDescription> apkDescriptions) {
ImmutableSet.Builder<LanguageTargeting> languageTargetingOptions = ImmutableSet.builder();
if (isLocalesMissing(getSizeRequest.getDeviceSpec())) {
languageTargetingOptions.addAll(
apkDescriptions.stream()
.map(ApkDescription::getTargeting)
.filter(ApkTargeting::hasLanguageTargeting)
.map(ApkTargeting::getLanguageTargeting)
.collect(toImmutableSet()));
}