Skip to content

Commit

Permalink
Prepare for release 1.17.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
gethughed committed Jul 23, 2024
1 parent 3f4ef99 commit 10fa41c
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ https://developer.android.com/studio/command-line/bundletool

## Releases

Latest release: [1.17.0](https://github.com/google/bundletool/releases)
Latest release: [1.17.1](https://github.com/google/bundletool/releases)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 1.17.0
release_version = 1.17.1
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public abstract class AndroidManifest {
public static final String MAIN_ACTION_ELEMENT_NAME = "action";
public static final String DATA_ELEMENT_NAME = "data";

public static final String APP_CATEGORY_ATTRIBUTE_NAME = "appCategory";
public static final String DEBUGGABLE_ATTRIBUTE_NAME = "debuggable";
public static final String EXTRACT_NATIVE_LIBS_ATTRIBUTE_NAME = "extractNativeLibs";
public static final String ICON_ATTRIBUTE_NAME = "icon";
Expand Down Expand Up @@ -192,6 +193,7 @@ public abstract class AndroidManifest {
/** <meta-data> name that specifies native library for native activity */
public static final String NATIVE_ACTIVITY_LIB_NAME = "android.app.lib_name";

public static final int APP_CATEGORY_RESOURCE_ID = 0x01010545;
public static final int DEBUGGABLE_RESOURCE_ID = 0x0101000f;
public static final int EXTRACT_NATIVE_LIBS_RESOURCE_ID = 0x10104ea;
public static final int REQUIRED_RESOURCE_ID = 0x0101028e;
Expand Down Expand Up @@ -373,6 +375,17 @@ public AndroidManifest applyMutators(ImmutableList<ManifestMutator> manifestMuta
return manifestEditor.save();
}

/**
* Extracts value of the {@code <application android:appCategory>} attribute.
*
* @return An optional containing the value of the {@code appCategory} attribute if set, or an
* empty optional if not set.
*/
public Optional<String> getApplicationAppCategory() {
return getApplicationAttribute(APP_CATEGORY_RESOURCE_ID)
.map(XmlProtoAttribute::getValueAsString);
}

/**
* Extracts value of the {@code <application android:debuggable>} attribute.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ public ManifestEditor setLocaleConfig(int resourceId) {
LOCALE_CONFIG_ATTRIBUTE_NAME, LOCALE_CONFIG_RESOURCE_ID, resourceId);
}

@CanIgnoreReturnValue
public ManifestEditor setAppCategory(String appCategory) {
manifestElement
.getOrCreateChildElement(APPLICATION_ELEMENT_NAME)
.getOrCreateAndroidAttribute(
AndroidManifest.APP_CATEGORY_ATTRIBUTE_NAME, AndroidManifest.APP_CATEGORY_RESOURCE_ID)
.setValueAsString(appCategory);
return this;
}

@CanIgnoreReturnValue
public ManifestEditor addMetaDataString(String key, String value) {
return addMetaDataValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ public enum OptimizationDimension {
LANGUAGE,
TEXTURE_COMPRESSION_FORMAT,
DEVICE_TIER,
COUNTRY_SET
COUNTRY_SET,
AI_MODEL_VERSION
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public final class BundleToolVersion {

private static final String CURRENT_VERSION = "1.17.0";
private static final String CURRENT_VERSION = "1.17.1";


/** Returns the version of BundleTool being run. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,13 @@ private static void validateNumberOfDistinctSplitIds(BundleModule module) {

private static void validateAssetModuleManifest(BundleModule module) {
ImmutableMultimap<String, String> allowedManifestElementChildren =
ImmutableMultimap.of(DISTRIBUTION_NAMESPACE_URI, "module", NO_NAMESPACE_URI, "uses-split");
ImmutableMultimap.of(
DISTRIBUTION_NAMESPACE_URI,
"module",
NO_NAMESPACE_URI,
"uses-split",
NO_NAMESPACE_URI,
"application");

AndroidManifest manifest = module.getAndroidManifest();
if (!manifest.getModuleType().equals(ModuleType.ASSET_MODULE)) {
Expand Down
1 change: 1 addition & 0 deletions src/main/proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ message SplitDimension {
TEXTURE_COMPRESSION_FORMAT = 4;
DEVICE_TIER = 6;
COUNTRY_SET = 7;
AI_MODEL_VERSION = 8;
}
Value value = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.android.tools.build.bundletool.model;

import static com.android.tools.build.bundletool.model.AndroidManifest.APP_CATEGORY_RESOURCE_ID;
import static com.android.tools.build.bundletool.model.AndroidManifest.APP_COMPONENT_FACTORY_ATTRIBUTE_NAME;
import static com.android.tools.build.bundletool.model.AndroidManifest.APP_COMPONENT_FACTORY_RESOURCE_ID;
import static com.android.tools.build.bundletool.model.AndroidManifest.AUTHORITIES_ATTRIBUTE_NAME;
Expand Down Expand Up @@ -149,6 +150,24 @@ public void hasMainActivity_definedAsActivityAlias_returnTrue() {
assertThat(androidManifest.hasMainActivity()).isTrue();
}

@Test
public void getApplicationAppCategory_equalsGame() {
AndroidManifest androidManifest =
AndroidManifest.create(
xmlNode(
xmlElement(
"manifest",
xmlNode(
xmlElement(
"application",
xmlAttribute(
ANDROID_NAMESPACE_URI,
"appCategory",
APP_CATEGORY_RESOURCE_ID,
"game"))))));
assertThat(androidManifest.getApplicationAppCategory()).hasValue("game");
}

@Test
public void getApplicationDebuggable_presentFalse() {
AndroidManifest androidManifest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_ATTRIBUTE_NAME;
import static com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_RESOURCE_ID;
import static com.android.tools.build.bundletool.model.AndroidManifest.APPLICATION_ELEMENT_NAME;
import static com.android.tools.build.bundletool.model.AndroidManifest.APP_CATEGORY_ATTRIBUTE_NAME;
import static com.android.tools.build.bundletool.model.AndroidManifest.APP_CATEGORY_RESOURCE_ID;
import static com.android.tools.build.bundletool.model.AndroidManifest.CATEGORY_ELEMENT_NAME;
import static com.android.tools.build.bundletool.model.AndroidManifest.CERTIFICATE_DIGEST_ATTRIBUTE_NAME;
import static com.android.tools.build.bundletool.model.AndroidManifest.DELIVERY_ELEMENT_NAME;
Expand Down Expand Up @@ -386,6 +388,21 @@ public void setVersionCode() {
ANDROID_NAMESPACE_URI, "versionCode", VERSION_CODE_RESOURCE_ID, 123));
}

@Test
public void setAppCategory() {
AndroidManifest androidManifest = createManifestWithApplicationElement();

AndroidManifest editedManifest = androidManifest.toEditor().setAppCategory("game").save();

assertThat(getApplicationElement(editedManifest).getAttributeList())
.containsExactly(
xmlAttribute(
ANDROID_NAMESPACE_URI,
APP_CATEGORY_ATTRIBUTE_NAME,
APP_CATEGORY_RESOURCE_ID,
"game"));
}

@Test
public void setConfigForSplit() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,21 +722,15 @@ public void assetModule_noApplication_ok() throws Exception {
}

@Test
public void assetModule_withApplication_throws() throws Exception {
public void assetModule_withApplication_ok() throws Exception {
BundleModule module =
new BundleModuleBuilder("asset_module")
.setManifest(
androidManifestForAssetModule(
"com.test.app", withOnDemandDelivery(), withApplication()))
.build();

Throwable exception =
assertThrows(
InvalidBundleException.class,
() -> new AndroidManifestValidator().validateModule(module));
assertThat(exception)
.hasMessageThat()
.matches("Unexpected element declaration in manifest of asset pack 'asset_module'.");
new AndroidManifestValidator().validateModule(module);
}

@DataPoints("sdkMutators")
Expand Down

0 comments on commit 10fa41c

Please sign in to comment.