Skip to content

Commit 3f4ef99

Browse files
committed
Prepare for release 1.17.0.
1 parent 9a4a1c9 commit 3f4ef99

23 files changed

+489
-37
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ https://developer.android.com/studio/command-line/bundletool
4646

4747
## Releases
4848

49-
Latest release: [1.16.0](https://github.com/google/bundletool/releases)
49+
Latest release: [1.17.0](https://github.com/google/bundletool/releases)

‎gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
release_version = 1.16.0
1+
release_version = 1.17.0

‎src/main/java/com/android/tools/build/bundletool/commands/BuildApksManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private void setEnableUncompressedDexOptimization(
383383
uncompressedDexFiles.getUncompressedDexTargetSdk());
384384
return;
385385
}
386-
// Otherwise we rely on default for bundletool version used to build this AAB:
386+
// Depending on bundletool version used to build this AAB:
387387
// * no uncompressed dex for bundletool < 1.12.0;
388388
// * uncompressed dex for Android S+ for bundletool [1.12.0, 1.16.0);
389389
// * uncompressed dex for Android Q+ for bundletool >= 1.16.0.

‎src/main/java/com/android/tools/build/bundletool/device/DeviceTargetingConfigEvaluator.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ private static boolean devicePropertiesMatchDeviceTier(
119119
private static boolean devicePropertiesMatchDeviceSelector(
120120
DeviceProperties deviceProperties, DeviceSelector deviceSelector) {
121121
return devicePropertiesMatchRamRule(deviceProperties, deviceSelector.getDeviceRam())
122-
&& deviceIdInList(deviceProperties.getDeviceId(), deviceSelector.getIncludedDeviceIdsList())
123-
&& !deviceSelector.getExcludedDeviceIdsList().contains(deviceProperties.getDeviceId())
122+
&& deviceIdIncluded(
123+
deviceProperties.getDeviceId(), deviceSelector.getIncludedDeviceIdsList())
124+
&& !deviceIdExcluded(
125+
deviceProperties.getDeviceId(), deviceSelector.getExcludedDeviceIdsList())
124126
&& deviceProperties
125127
.getSystemFeaturesList()
126128
.containsAll(deviceSelector.getRequiredSystemFeaturesList())
@@ -135,13 +137,21 @@ private static boolean devicePropertiesMatchRamRule(
135137
return minBytes <= deviceProperties.getRam() && deviceProperties.getRam() < maxBytes;
136138
}
137139

138-
private static boolean deviceIdInList(DeviceId deviceId, List<DeviceId> deviceIdList) {
140+
private static boolean deviceIdExcluded(DeviceId deviceId, List<DeviceId> deviceIdList) {
141+
DeviceId deviceOnlyBrand =
142+
DeviceId.newBuilder().setBuildBrand(deviceId.getBuildBrand()).build();
143+
return deviceIdList.contains(deviceId) || deviceIdList.contains(deviceOnlyBrand);
144+
}
145+
146+
private static boolean deviceIdIncluded(DeviceId deviceId, List<DeviceId> deviceIdList) {
139147
// If the deviceIdList is empty, it means that the targeting configuration is not specifying any
140148
// DeviceId in particular. This means that any DeviceId provided satisfies the
141149
// included_device_ids rule in the DeviceSelector. Hence, we return true in this case.
142150
if (deviceIdList.isEmpty()) {
143151
return true;
144152
}
145-
return deviceIdList.contains(deviceId);
153+
DeviceId deviceOnlyBrand =
154+
DeviceId.newBuilder().setBuildBrand(deviceId.getBuildBrand()).build();
155+
return deviceIdList.contains(deviceId) || deviceIdList.contains(deviceOnlyBrand);
146156
}
147157
}

‎src/main/java/com/android/tools/build/bundletool/io/ApkSerializerManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package com.android.tools.build.bundletool.io;
1717

1818
import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.SYSTEM;
19+
import static com.android.tools.build.bundletool.model.AndroidManifest.MODULE_TYPE_AI_VALUE;
20+
import static com.android.tools.build.bundletool.model.AndroidManifest.MODULE_TYPE_ASSET_VALUE;
1921
import static com.android.tools.build.bundletool.model.BundleModule.DEX_DIRECTORY;
2022
import static com.android.tools.build.bundletool.model.utils.CollectorUtils.groupingByDeterministic;
2123
import static com.android.tools.build.bundletool.model.utils.CollectorUtils.groupingBySortedKeys;
@@ -31,6 +33,7 @@
3133
import com.android.bundle.Commands.ApkDescription;
3234
import com.android.bundle.Commands.ApkSet;
3335
import com.android.bundle.Commands.AssetModuleMetadata;
36+
import com.android.bundle.Commands.AssetModuleType;
3437
import com.android.bundle.Commands.AssetModulesInfo;
3538
import com.android.bundle.Commands.AssetSliceSet;
3639
import com.android.bundle.Commands.BuildApksResult;
@@ -393,6 +396,11 @@ private AssetModuleMetadata getAssetModuleMetadata(BundleModule module) {
393396
AndroidManifest manifest = module.getAndroidManifest();
394397
AssetModuleMetadata.Builder metadataBuilder =
395398
AssetModuleMetadata.newBuilder().setName(module.getName().getName());
399+
metadataBuilder.setAssetModuleType(
400+
manifest
401+
.getOptionalModuleTypeAttributeValue()
402+
.map(ApkSerializerManager::getAssetModuleType)
403+
.orElse(AssetModuleType.UNKNOWN_ASSET_TYPE));
396404
Optional<ManifestDeliveryElement> persistentDelivery = manifest.getManifestDeliveryElement();
397405
metadataBuilder.setDeliveryType(
398406
persistentDelivery
@@ -419,6 +427,17 @@ private AssetModuleMetadata getAssetModuleMetadata(BundleModule module) {
419427
return metadataBuilder.build();
420428
}
421429

430+
private static AssetModuleType getAssetModuleType(String value) {
431+
switch (value) {
432+
case MODULE_TYPE_ASSET_VALUE:
433+
return AssetModuleType.DEFAULT_ASSET_TYPE;
434+
case MODULE_TYPE_AI_VALUE:
435+
return AssetModuleType.AI_PACK_TYPE;
436+
default:
437+
return AssetModuleType.UNKNOWN_ASSET_TYPE;
438+
}
439+
}
440+
422441
private static void validateInput(GeneratedApks generatedApks, ApkBuildMode apkBuildMode) {
423442
switch (apkBuildMode) {
424443
case DEFAULT:

‎src/main/java/com/android/tools/build/bundletool/io/ApkSerializerModule.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import static java.lang.annotation.RetentionPolicy.RUNTIME;
1919

20-
import com.android.bundle.Config.BundleConfig;
20+
import com.android.tools.build.bundletool.optimizations.ApkOptimizations;
2121
import dagger.Binds;
2222
import dagger.Module;
2323
import dagger.Provides;
@@ -33,8 +33,8 @@ public abstract class ApkSerializerModule {
3333

3434
@Provides
3535
@NativeLibrariesAlignmentInBytes
36-
static int provideNativeLibrariesAlignmentInBytes(BundleConfig bundleConfig) {
37-
switch (bundleConfig.getOptimizations().getUncompressNativeLibraries().getAlignment()) {
36+
static int provideNativeLibrariesAlignmentInBytes(ApkOptimizations apkOptimizations) {
37+
switch (apkOptimizations.getPageAlignment()) {
3838
case PAGE_ALIGNMENT_16K:
3939
return 16384;
4040
case PAGE_ALIGNMENT_64K:

‎src/main/java/com/android/tools/build/bundletool/model/AndroidManifest.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ public abstract class AndroidManifest {
183183

184184
public static final String MODULE_TYPE_FEATURE_VALUE = "feature";
185185
public static final String MODULE_TYPE_ASSET_VALUE = "asset-pack";
186+
// A feature module that contains ML models. This is the legacy way to package ML models.
186187
public static final String MODULE_TYPE_ML_VALUE = "ml-pack";
188+
// An asset pack that contains ML models. This is the preferred way to package ML models.
189+
public static final String MODULE_TYPE_AI_VALUE = "ai-pack";
187190
public static final String MODULE_TYPE_SDK_VALUE = "sdk";
188191

189192
/** <meta-data> name that specifies native library for native activity */
@@ -503,6 +506,7 @@ private static ModuleType getModuleTypeFromAttributeValue(String value) {
503506
case MODULE_TYPE_FEATURE_VALUE:
504507
return ModuleType.FEATURE_MODULE;
505508
case MODULE_TYPE_ASSET_VALUE:
509+
case MODULE_TYPE_AI_VALUE:
506510
return ModuleType.ASSET_MODULE;
507511
case MODULE_TYPE_ML_VALUE:
508512
return ModuleType.ML_MODULE;
@@ -516,14 +520,17 @@ private static ModuleType getModuleTypeFromAttributeValue(String value) {
516520
}
517521

518522
public Optional<ModuleType> getOptionalModuleType() {
519-
Optional<String> typeAttributeValue =
520-
getManifestElement()
521-
.getOptionalChildElement(DISTRIBUTION_NAMESPACE_URI, "module")
522-
.flatMap(module -> module.getAttribute(DISTRIBUTION_NAMESPACE_URI, "type"))
523-
.map(XmlProtoAttribute::getValueAsString);
523+
Optional<String> typeAttributeValue = getOptionalModuleTypeAttributeValue();
524524
return typeAttributeValue.map(AndroidManifest::getModuleTypeFromAttributeValue);
525525
}
526526

527+
public Optional<String> getOptionalModuleTypeAttributeValue() {
528+
return getManifestElement()
529+
.getOptionalChildElement(DISTRIBUTION_NAMESPACE_URI, "module")
530+
.flatMap(module -> module.getAttribute(DISTRIBUTION_NAMESPACE_URI, "type"))
531+
.map(XmlProtoAttribute::getValueAsString);
532+
}
533+
527534
public ModuleType getModuleType() {
528535
// If the module type is not defined in the manifest, default to feature module for backwards
529536
// compatibility.
@@ -1111,12 +1118,14 @@ public ImmutableList<XmlProtoElement> getUsesSdkLibraryElements() {
11111118
return getApplicationElementChildElements(USES_SDK_LIBRARY_ELEMENT_NAME);
11121119
}
11131120

1121+
public ImmutableList<XmlProtoElement> getAllContentProviders() {
1122+
return getApplicationElementChildElements(PROVIDER_ELEMENT_NAME);
1123+
}
1124+
11141125
private ImmutableList<XmlProtoElement> getApplicationElementChildElements(
11151126
String childElementName) {
1116-
return getManifestRoot()
1117-
.getElement()
1118-
.getChildElement(APPLICATION_ELEMENT_NAME)
1119-
.getChildrenElements()
1127+
return stream(getManifestRoot().getElement().getOptionalChildElement(APPLICATION_ELEMENT_NAME))
1128+
.flatMap(app -> app.getChildrenElements())
11201129
.filter(element -> element.getName().equals(childElementName))
11211130
.collect(toImmutableList());
11221131
}

‎src/main/java/com/android/tools/build/bundletool/model/version/BundleToolVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public final class BundleToolVersion {
2828

29-
private static final String CURRENT_VERSION = "1.16.0";
29+
private static final String CURRENT_VERSION = "1.17.0";
3030

3131

3232
/** Returns the version of BundleTool being run. */

‎src/main/java/com/android/tools/build/bundletool/optimizations/ApkOptimizations.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import com.android.bundle.Config.SuffixStripping;
2727
import com.android.bundle.Config.UncompressDexFiles.UncompressedDexTargetSdk;
28+
import com.android.bundle.Config.UncompressNativeLibraries.PageAlignment;
2829
import com.android.tools.build.bundletool.model.OptimizationDimension;
2930
import com.android.tools.build.bundletool.model.version.Version;
3031
import com.google.auto.value.AutoValue;
@@ -131,6 +132,24 @@ public abstract class ApkOptimizations {
131132
// UNSPECIFIED here means SDK 29+ (Android Q+)
132133
.setUncompressedDexTargetSdk(UncompressedDexTargetSdk.UNSPECIFIED)
133134
.build())
135+
.put(
136+
Version.of("1.17.0"),
137+
ApkOptimizations.builder()
138+
.setSplitDimensions(
139+
ImmutableSet.of(
140+
ABI,
141+
SCREEN_DENSITY,
142+
TEXTURE_COMPRESSION_FORMAT,
143+
LANGUAGE,
144+
DEVICE_TIER,
145+
COUNTRY_SET))
146+
.setUncompressNativeLibraries(true)
147+
.setPageAlignment(PageAlignment.PAGE_ALIGNMENT_16K)
148+
.setStandaloneDimensions(ImmutableSet.of(ABI, SCREEN_DENSITY))
149+
.setUncompressDexFiles(true)
150+
// UNSPECIFIED here means SDK 29+ (Android Q+)
151+
.setUncompressedDexTargetSdk(UncompressedDexTargetSdk.UNSPECIFIED)
152+
.build())
134153
.buildOrThrow();
135154

136155
/** List of dimensions supported by asset modules. */
@@ -146,6 +165,8 @@ public ImmutableSet<OptimizationDimension> getSplitDimensionsForAssetModules() {
146165

147166
public abstract boolean getUncompressNativeLibraries();
148167

168+
public abstract PageAlignment getPageAlignment();
169+
149170
public abstract boolean getUncompressDexFiles();
150171

151172
public abstract UncompressedDexTargetSdk getUncompressedDexTargetSdk();
@@ -161,6 +182,7 @@ public static Builder builder() {
161182
.setUncompressNativeLibraries(false)
162183
.setUncompressDexFiles(false)
163184
.setUncompressedDexTargetSdk(UncompressedDexTargetSdk.UNSPECIFIED)
185+
.setPageAlignment(PageAlignment.PAGE_ALIGNMENT_UNSPECIFIED)
164186
.setSuffixStrippings(ImmutableMap.of());
165187
}
166188

@@ -171,6 +193,8 @@ public abstract static class Builder {
171193

172194
public abstract Builder setUncompressNativeLibraries(boolean enable);
173195

196+
public abstract Builder setPageAlignment(PageAlignment pageAlignment);
197+
174198
public abstract Builder setUncompressDexFiles(boolean enable);
175199

176200
public abstract Builder setUncompressedDexTargetSdk(

‎src/main/java/com/android/tools/build/bundletool/optimizations/OptimizationsMerger.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.android.bundle.Config.SplitDimension.Value;
2525
import com.android.bundle.Config.SuffixStripping;
2626
import com.android.bundle.Config.UncompressDexFiles.UncompressedDexTargetSdk;
27+
import com.android.bundle.Config.UncompressNativeLibraries.PageAlignment;
2728
import com.android.tools.build.bundletool.model.OptimizationDimension;
2829
import com.android.tools.build.bundletool.model.utils.EnumMapper;
2930
import com.android.tools.build.bundletool.model.version.BundleToolVersion;
@@ -104,6 +105,12 @@ public ApkOptimizations mergeWithDefaults(
104105
? requestedOptimizations.getUncompressNativeLibraries().getEnabled()
105106
: defaultOptimizations.getUncompressNativeLibraries();
106107

108+
PageAlignment pageAlignment =
109+
requestedOptimizations.getUncompressNativeLibraries().getAlignment()
110+
!= PageAlignment.PAGE_ALIGNMENT_UNSPECIFIED
111+
? requestedOptimizations.getUncompressNativeLibraries().getAlignment()
112+
: defaultOptimizations.getPageAlignment();
113+
107114
boolean uncompressDexFiles;
108115
UncompressedDexTargetSdk uncompressedDexTargetSdk;
109116

@@ -123,6 +130,7 @@ public ApkOptimizations mergeWithDefaults(
123130
return ApkOptimizations.builder()
124131
.setSplitDimensions(splitDimensions)
125132
.setUncompressNativeLibraries(uncompressNativeLibraries)
133+
.setPageAlignment(pageAlignment)
126134
.setUncompressDexFiles(uncompressDexFiles)
127135
.setUncompressedDexTargetSdk(uncompressedDexTargetSdk)
128136
.setStandaloneDimensions(standaloneDimensions)

0 commit comments

Comments
 (0)