use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class ArchivedApksGenerator method generateArchivedApk.
public ModuleSplit generateArchivedApk(AppBundle appBundle) throws IOException {
validateRequest(appBundle);
BundleModule baseModule = appBundle.getBaseModule();
AndroidManifest archivedManifest = ArchivedAndroidManifestUtils.createArchivedManifest(baseModule.getAndroidManifest());
Optional<ResourceTable> archivedResourceTable = getArchivedResourceTable(appBundle, baseModule, archivedManifest);
Path archivedClassesDexFile = getArchivedClassesDexFile();
return ModuleSplit.forArchive(baseModule, archivedManifest, archivedResourceTable, archivedClassesDexFile);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class ManifestProtoUtilsTest method splitNameAttributeAddedToActivity.
@Test
public void splitNameAttributeAddedToActivity() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "foo")));
ImmutableList<XmlElement> activities = manifest.getManifestRoot().getElement().getChildElement("application").getChildrenElements(ACTIVITY_ELEMENT_NAME).map(XmlProtoElement::getProto).collect(toImmutableList());
assertThat(activities).hasSize(2);
XmlElement activityElement = activities.get(1);
assertThat(activityElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID, "FooActivity"), xmlAttribute(ANDROID_NAMESPACE_URI, SPLIT_NAME_ATTRIBUTE_NAME, SPLIT_NAME_RESOURCE_ID, "foo"));
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class ManifestProtoUtilsTest method splitNameAttributeAddedToService.
@Test
public void splitNameAttributeAddedToService() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withSplitNameService("FooService", "foo")));
ImmutableList<XmlElement> services = manifest.getManifestRoot().getElement().getChildElement("application").getChildrenElements(SERVICE_ELEMENT_NAME).map(XmlProtoElement::getProto).collect(toImmutableList());
assertThat(services).hasSize(1);
XmlElement serviceElement = Iterables.getOnlyElement(services);
assertThat(serviceElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID, "FooService"), xmlAttribute(ANDROID_NAMESPACE_URI, SPLIT_NAME_ATTRIBUTE_NAME, SPLIT_NAME_RESOURCE_ID, "foo"));
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_splitApks_twoModulesOneOnDemand.
@Test
public void buildApksCommand_splitApks_twoModulesOneOnDemand() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("dex/classes.dex").setManifest(androidManifest("com.test.app")).setResourceTable(resourceTableWithTestLabel("Test feature"))).addModule("onDemand", builder -> builder.setManifest(androidManifest("com.test.app", withOnDemandAttribute(true), withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID), withFusingAttribute(true)))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
assertThat(splitApkVariants(result)).hasSize(1);
Variant splitApkVariant = splitApkVariants(result).get(0);
ImmutableMap<String, ApkSet> splitApkSetByModuleName = Maps.uniqueIndex(splitApkVariant.getApkSetList(), apkSet -> apkSet.getModuleMetadata().getName());
assertThat(splitApkSetByModuleName).hasSize(2);
ApkSet baseSplits = splitApkSetByModuleName.get("base");
assertThat(baseSplits.getModuleMetadata().getName()).isEqualTo("base");
assertThat(baseSplits.getModuleMetadata().getDeliveryType()).isEqualTo(DeliveryType.INSTALL_TIME);
assertThat(baseSplits.getApkDescriptionList()).hasSize(1);
assertThat(apkSetFile).hasFile(baseSplits.getApkDescription(0).getPath());
ApkSet onDemandSplits = splitApkSetByModuleName.get("onDemand");
assertThat(onDemandSplits.getModuleMetadata().getName()).isEqualTo("onDemand");
assertThat(onDemandSplits.getModuleMetadata().getDeliveryType()).isEqualTo(DeliveryType.ON_DEMAND);
assertThat(onDemandSplits.getApkDescriptionList()).hasSize(1);
assertThat(apkSetFile).hasFile(onDemandSplits.getApkDescription(0).getPath());
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_standalone_mixedTextureTargetingWithFallbackAsDefault.
@Test
public void buildApksCommand_standalone_mixedTextureTargetingWithFallbackAsDefault() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.test.app"))).addModule("feature_tcf_assets", builder -> builder.addFile("assets/textures/untargeted_texture.dat").addFile("assets/textures#tcf_etc1/etc1_texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures", assetsDirectoryTargeting(alternativeTextureCompressionTargeting(ETC1_RGB8))), targetedAssetsDirectory("assets/textures#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(ETC1_RGB8))))).setManifest(androidManifest("com.test.app", withDelivery(DeliveryType.INSTALL_TIME), withFusingAttribute(true)))).setBundleConfig(BundleConfigBuilder.create().addSplitDimension(Value.TEXTURE_COMPRESSION_FORMAT, /* negate= */
false, /* stripSuffix= */
true, /* defaultSuffix= */
"").build()).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withOptimizationDimensions(TEXTURE_COMPRESSION_FORMAT).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
assertThat(standaloneApkVariants(result)).hasSize(1);
assertThat(apkDescriptions(standaloneApkVariants(result))).hasSize(1);
ApkDescription shard = apkDescriptions(standaloneApkVariants(result)).get(0);
// Check APK content.
assertThat(apkSetFile).hasFile(shard.getPath());
try (ZipFile shardZip = new ZipFile(extractFromApkSetFile(apkSetFile, shard.getPath(), outputDir))) {
assertThat(shardZip).hasFile("assets/textures/untargeted_texture.dat");
assertThat(shardZip).doesNotHaveFile("assets/textures#tcf_etc1/etc1_texture.dat");
}
// Check that no targeting was applied.
assertThat(Iterables.getOnlyElement(standaloneApkVariants(result)).getTargeting().hasTextureCompressionFormatTargeting()).isFalse();
assertThat(shard.getTargeting().hasTextureCompressionFormatTargeting()).isFalse();
}
Aggregations