Search in sources :

Example 31 with AndroidManifest

use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.

the class SystemApksGenerator method processSplitsOfSystemShard.

private ImmutableList<ModuleSplit> processSplitsOfSystemShard(ImmutableList<ModuleSplit> splits, ImmutableSet<BundleModuleName> modulesToFuse) {
    ImmutableSet<ModuleSplit> splitsOfFusedModules = splits.stream().filter(module -> modulesToFuse.contains(module.getModuleName())).collect(toImmutableSet());
    ImmutableSet<ModuleSplit> splitsOfNonFusedModules = Sets.difference(ImmutableSet.copyOf(splits), splitsOfFusedModules).immutableCopy();
    ImmutableSet<ModuleSplit> splitsWithOnlyDeviceLanguages = filterOutUnusedLanguageSplits(splitsOfFusedModules);
    ModuleSplit systemSplit = mergeSplitsToSystemApk(splitsWithOnlyDeviceLanguages);
    AndroidManifest systemSplitManifest = systemSplit.getAndroidManifest();
    // Groups all the unmatched language splits for fused modules by language and fuse them to
    // generate a single split for each language.
    ImmutableSet<ModuleSplit> additionalLanguageSplits = Sets.difference(splitsOfFusedModules, splitsWithOnlyDeviceLanguages).stream().collect(groupingByDeterministic(ModuleSplit::getApkTargeting)).values().stream().map(splitsPerLanguage -> mergeLanguageSplitsIntoOne(splitsPerLanguage, systemSplitManifest)).collect(toImmutableSet());
    // Write split id and variant targeting for splits that are not fused.
    ImmutableList<ModuleSplit> additionalSplits = Sets.union(additionalLanguageSplits, splitsOfNonFusedModules).stream().collect(groupingByDeterministic(ModuleSplit::getModuleName)).values().stream().flatMap(SystemApksGenerator::writeSplitIdInManifestHavingSameModule).map(module -> writeSplitTargetingAndSplitTypeToAdditionalSplit(module, systemSplit.getVariantTargeting())).collect(toImmutableList());
    return ImmutableList.<ModuleSplit>builder().add(systemSplit).addAll(additionalSplits).build();
}
Also used : Iterables(com.google.common.collect.Iterables) AndroidManifestMerger.manifestOverride(com.android.tools.build.bundletool.mergers.AndroidManifestMerger.manifestOverride) BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) SuffixManager(com.android.tools.build.bundletool.model.SuffixManager) ZipPath(com.android.tools.build.bundletool.model.ZipPath) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) HashMap(java.util.HashMap) DeviceSpec(com.android.bundle.Devices.DeviceSpec) CollectorUtils.groupingByDeterministic(com.android.tools.build.bundletool.model.utils.CollectorUtils.groupingByDeterministic) CodeTransparencyInjector(com.android.tools.build.bundletool.splitters.CodeTransparencyInjector) Inject(javax.inject.Inject) ImmutableList(com.google.common.collect.ImmutableList) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ApkMatcher(com.android.tools.build.bundletool.device.ApkMatcher) TargetingUtils.standaloneApkVariantTargeting(com.android.tools.build.bundletool.model.targeting.TargetingUtils.standaloneApkVariantTargeting) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ApkOptimizations(com.android.tools.build.bundletool.optimizations.ApkOptimizations) SplitType(com.android.tools.build.bundletool.model.ModuleSplit.SplitType) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) ModuleSplitsToShardMerger(com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger) Stream(java.util.stream.Stream) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) Optional(java.util.Optional) AppBundle(com.android.tools.build.bundletool.model.AppBundle) BundleModule(com.android.tools.build.bundletool.model.BundleModule) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest)

Example 32 with AndroidManifest

use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.

the class ModuleSplitter method makeInstantManifestChanges.

/**
 * Updates the split to insert instant app specific manifest changes:
 *
 * <ul>
 *   <li>Sets the targetSandboxVersion to 2.
 *   <li>Sets the minSdkVersion to 21 if it the minSdkVersion is lower than 21.
 *   <li>Removes any known splits from the base manifest, which may contain on demand split
 *       information.
 * </ul>
 */
public ModuleSplit makeInstantManifestChanges(ModuleSplit moduleSplit) {
    AndroidManifest manifest = moduleSplit.getAndroidManifest();
    ManifestEditor editor = manifest.toEditor();
    editor.setTargetSandboxVersion(2);
    if (manifest.getEffectiveMinSdkVersion() < 21) {
        editor.setMinSdkVersion(21);
    }
    editor.removeUnknownSplitComponents(allModuleNames);
    return moduleSplit.toBuilder().setAndroidManifest(editor.save()).build();
}
Also used : ManifestEditor(com.android.tools.build.bundletool.model.ManifestEditor) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest)

Example 33 with AndroidManifest

use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.

the class ModuleSplitterTest method pinSpecIsCopied.

@Test
public void pinSpecIsCopied() {
    NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting("x86")));
    BundleModule testModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeConfig).addFile("lib/x86/liba.so").addFile("assets/com.android.hints.pins.txt").build();
    ImmutableList<ModuleSplit> splits = createAbiAndDensitySplitter(testModule).splitModule();
    assertThat(splits).hasSize(2);
    assertThat(splits.stream().map((s) -> s.getEntries().stream().filter((e) -> e.getPath().endsWith(PinSpecInjector.PIN_SPEC_NAME)).count()).distinct()).containsExactly(1L);
}
Also used : ManifestProtoUtils.withSplitNameActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameActivity) ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ResourcesTableFactory.locale(com.android.tools.build.bundletool.testing.ResourcesTableFactory.locale) TargetingUtils.textureCompressionTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.textureCompressionTargeting) TargetingUtils.alternativeLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.alternativeLanguageTargeting) SCREEN_DENSITY(com.android.tools.build.bundletool.model.OptimizationDimension.SCREEN_DENSITY) Predicates.not(com.google.common.base.Predicates.not) ResourceId(com.android.tools.build.bundletool.model.ResourceId) Map(java.util.Map) DEVICE_TIER(com.android.tools.build.bundletool.model.OptimizationDimension.DEVICE_TIER) TargetingUtils.lPlusVariantTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.lPlusVariantTargeting) ManifestMutator.withExtractNativeLibs(com.android.tools.build.bundletool.model.ManifestMutator.withExtractNativeLibs) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) Version(com.android.tools.build.bundletool.model.version.Version) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) ResourceTable(com.android.aapt.Resources.ResourceTable) SPLIT_NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SPLIT_NAME_RESOURCE_ID) ModuleSplitUtils.applyManifestMutators(com.android.tools.build.bundletool.testing.ModuleSplitUtils.applyManifestMutators) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) ConfigValue(com.android.aapt.Resources.ConfigValue) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) StampType(com.android.tools.build.bundletool.model.SourceStamp.StampType) ManifestProtoUtils.withMinSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMinSdkVersion) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) Assets(com.android.bundle.Files.Assets) TargetingUtils.assetsDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.assetsDirectoryTargeting) STAMP_TYPE_METADATA_KEY(com.android.tools.build.bundletool.model.SourceStamp.STAMP_TYPE_METADATA_KEY) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Iterables(com.google.common.collect.Iterables) STAMP_SOURCE_METADATA_KEY(com.android.tools.build.bundletool.model.SourceStamp.STAMP_SOURCE_METADATA_KEY) TargetingUtils.variantMinSdkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.variantMinSdkTargeting) ZipPath(com.android.tools.build.bundletool.model.ZipPath) OptimizationDimension(com.android.tools.build.bundletool.model.OptimizationDimension) ATC(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ATC) RunWith(org.junit.runner.RunWith) TargetingUtils.apkMinSdkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkMinSdkTargeting) TEXTURE_COMPRESSION_FORMAT(com.android.tools.build.bundletool.model.OptimizationDimension.TEXTURE_COMPRESSION_FORMAT) TargetingUtils.getSplitsWithTargetingEqualTo(com.android.tools.build.bundletool.testing.TargetingUtils.getSplitsWithTargetingEqualTo) TruthResourceTable.assertThat(com.android.tools.build.bundletool.testing.truth.resources.TruthResourceTable.assertThat) ANDROID_R_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_R_API_VERSION) LANGUAGE(com.android.tools.build.bundletool.model.OptimizationDimension.LANGUAGE) ManifestProtoUtils.withMetadataResource(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMetadataResource) ResourcesTableFactory.mergeConfigs(com.android.tools.build.bundletool.testing.ResourcesTableFactory.mergeConfigs) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) XmlProtoElement(com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoElement) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) ANDROID_Q_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_Q_API_VERSION) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) SuffixStripping(com.android.bundle.Config.SuffixStripping) ManifestProtoUtils.clearApplication(com.android.tools.build.bundletool.testing.ManifestProtoUtils.clearApplication) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) HDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) TestCase.fail(junit.framework.TestCase.fail) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) Test(org.junit.Test) ANDROID_L_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_L_API_VERSION) ANDROID_M_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_M_API_VERSION) TargetingUtils.assets(com.android.tools.build.bundletool.testing.TargetingUtils.assets) TargetingUtils.apkDensityTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDensityTargeting) XmlNode(com.android.aapt.Resources.XmlNode) TargetingUtils.mergeApkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting) ManifestProtoUtils.withMainActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMainActivity) ModuleSplitUtils.createModuleSplitBuilder(com.android.tools.build.bundletool.testing.ModuleSplitUtils.createModuleSplitBuilder) AppBundle(com.android.tools.build.bundletool.model.AppBundle) BundleModule(com.android.tools.build.bundletool.model.BundleModule) TargetingUtils.apkDeviceTierTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDeviceTierTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) ManifestProtoUtils.xmlAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlAttribute) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ANDROID_NAMESPACE_URI(com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI) TargetingUtils.deviceTierTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.deviceTierTargeting) TargetingUtils.targetedAssetsDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedAssetsDirectory) NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.NAME_RESOURCE_ID) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) TargetingUtils.languageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.languageTargeting) ImmutableSet(com.google.common.collect.ImmutableSet) ResourcesTableFactory.value(com.android.tools.build.bundletool.testing.ResourcesTableFactory.value) TargetingUtils.apkTextureTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkTextureTargeting) ImmutableMap(com.google.common.collect.ImmutableMap) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) SplitType(com.android.tools.build.bundletool.model.ModuleSplit.SplitType) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) NativeLibraries(com.android.bundle.Files.NativeLibraries) List(java.util.List) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) Optional(java.util.Optional) ABI(com.android.tools.build.bundletool.model.OptimizationDimension.ABI) TargetingUtils.apkLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkLanguageTargeting) ManifestProtoUtils.withMaxSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMaxSdkVersion) TargetingUtils.apkAbiTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkAbiTargeting) BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) TestUtils.extractPaths(com.android.tools.build.bundletool.testing.TestUtils.extractPaths) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) ACTIVITY_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ACTIVITY_ELEMENT_NAME) S3TC(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.S3TC) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ManifestProtoUtils.withInstant(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstant) APPLICATION_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.APPLICATION_ELEMENT_NAME) JUnit4(org.junit.runners.JUnit4) XHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XHDPI) Truth.assertThat(com.google.common.truth.Truth.assertThat) ETC1_RGB8(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ETC1_RGB8) Maps(com.google.common.collect.Maps) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) Ignore(org.junit.Ignore) TargetingUtils.apkAlternativeLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkAlternativeLanguageTargeting) XmlElement(com.android.aapt.Resources.XmlElement) Versions(com.android.tools.build.bundletool.model.utils.Versions) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 34 with AndroidManifest

use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.

the class ModuleSplitterTest method nativeSplits_lPlusTargeting_withAbiAndUncompressNativeLibsSplitter.

@Test
public void nativeSplits_lPlusTargeting_withAbiAndUncompressNativeLibsSplitter() throws Exception {
    NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting("x86")));
    BundleModule testModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeConfig).addFile("lib/x86/liba.so").build();
    ModuleSplitter moduleSplitter = ModuleSplitter.createNoStamp(testModule, BUNDLETOOL_VERSION, APP_BUNDLE, ApkGenerationConfiguration.builder().setOptimizationDimensions(ImmutableSet.of(ABI)).setEnableUncompressedNativeLibraries(true).build(), lPlusVariantTargeting(), ImmutableSet.of("testModule"));
    List<ModuleSplit> splits = moduleSplitter.splitModule();
    // Base + X86 Split
    assertThat(splits).hasSize(2);
    assertThat(splits.stream().map(ModuleSplit::getSplitType).distinct().collect(toImmutableSet())).containsExactly(SplitType.SPLIT);
    assertThat(splits.stream().map(split -> split.getVariantTargeting()).collect(toImmutableSet())).containsExactly(variantMinSdkTargeting(ANDROID_L_API_VERSION));
    ModuleSplit master = splits.stream().filter(ModuleSplit::isMasterSplit).collect(onlyElement());
    ModuleSplit abi = splits.stream().filter(not(ModuleSplit::isMasterSplit)).collect(onlyElement());
    assertThat(master.getAndroidManifest().getExtractNativeLibsValue()).hasValue(true);
    assertThat(abi.findEntry("lib/x86/liba.so").get().getForceUncompressed()).isFalse();
}
Also used : ManifestProtoUtils.withSplitNameActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameActivity) ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ResourcesTableFactory.locale(com.android.tools.build.bundletool.testing.ResourcesTableFactory.locale) TargetingUtils.textureCompressionTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.textureCompressionTargeting) TargetingUtils.alternativeLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.alternativeLanguageTargeting) SCREEN_DENSITY(com.android.tools.build.bundletool.model.OptimizationDimension.SCREEN_DENSITY) Predicates.not(com.google.common.base.Predicates.not) ResourceId(com.android.tools.build.bundletool.model.ResourceId) Map(java.util.Map) DEVICE_TIER(com.android.tools.build.bundletool.model.OptimizationDimension.DEVICE_TIER) TargetingUtils.lPlusVariantTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.lPlusVariantTargeting) ManifestMutator.withExtractNativeLibs(com.android.tools.build.bundletool.model.ManifestMutator.withExtractNativeLibs) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) Version(com.android.tools.build.bundletool.model.version.Version) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) ResourceTable(com.android.aapt.Resources.ResourceTable) SPLIT_NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SPLIT_NAME_RESOURCE_ID) ModuleSplitUtils.applyManifestMutators(com.android.tools.build.bundletool.testing.ModuleSplitUtils.applyManifestMutators) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) ConfigValue(com.android.aapt.Resources.ConfigValue) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) StampType(com.android.tools.build.bundletool.model.SourceStamp.StampType) ManifestProtoUtils.withMinSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMinSdkVersion) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) Assets(com.android.bundle.Files.Assets) TargetingUtils.assetsDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.assetsDirectoryTargeting) STAMP_TYPE_METADATA_KEY(com.android.tools.build.bundletool.model.SourceStamp.STAMP_TYPE_METADATA_KEY) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Iterables(com.google.common.collect.Iterables) STAMP_SOURCE_METADATA_KEY(com.android.tools.build.bundletool.model.SourceStamp.STAMP_SOURCE_METADATA_KEY) TargetingUtils.variantMinSdkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.variantMinSdkTargeting) ZipPath(com.android.tools.build.bundletool.model.ZipPath) OptimizationDimension(com.android.tools.build.bundletool.model.OptimizationDimension) ATC(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ATC) RunWith(org.junit.runner.RunWith) TargetingUtils.apkMinSdkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkMinSdkTargeting) TEXTURE_COMPRESSION_FORMAT(com.android.tools.build.bundletool.model.OptimizationDimension.TEXTURE_COMPRESSION_FORMAT) TargetingUtils.getSplitsWithTargetingEqualTo(com.android.tools.build.bundletool.testing.TargetingUtils.getSplitsWithTargetingEqualTo) TruthResourceTable.assertThat(com.android.tools.build.bundletool.testing.truth.resources.TruthResourceTable.assertThat) ANDROID_R_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_R_API_VERSION) LANGUAGE(com.android.tools.build.bundletool.model.OptimizationDimension.LANGUAGE) ManifestProtoUtils.withMetadataResource(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMetadataResource) ResourcesTableFactory.mergeConfigs(com.android.tools.build.bundletool.testing.ResourcesTableFactory.mergeConfigs) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) XmlProtoElement(com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoElement) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) ANDROID_Q_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_Q_API_VERSION) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) SuffixStripping(com.android.bundle.Config.SuffixStripping) ManifestProtoUtils.clearApplication(com.android.tools.build.bundletool.testing.ManifestProtoUtils.clearApplication) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) HDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) TestCase.fail(junit.framework.TestCase.fail) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) Test(org.junit.Test) ANDROID_L_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_L_API_VERSION) ANDROID_M_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_M_API_VERSION) TargetingUtils.assets(com.android.tools.build.bundletool.testing.TargetingUtils.assets) TargetingUtils.apkDensityTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDensityTargeting) XmlNode(com.android.aapt.Resources.XmlNode) TargetingUtils.mergeApkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting) ManifestProtoUtils.withMainActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMainActivity) ModuleSplitUtils.createModuleSplitBuilder(com.android.tools.build.bundletool.testing.ModuleSplitUtils.createModuleSplitBuilder) AppBundle(com.android.tools.build.bundletool.model.AppBundle) BundleModule(com.android.tools.build.bundletool.model.BundleModule) TargetingUtils.apkDeviceTierTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDeviceTierTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) ManifestProtoUtils.xmlAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlAttribute) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ANDROID_NAMESPACE_URI(com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI) TargetingUtils.deviceTierTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.deviceTierTargeting) TargetingUtils.targetedAssetsDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedAssetsDirectory) NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.NAME_RESOURCE_ID) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) TargetingUtils.languageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.languageTargeting) ImmutableSet(com.google.common.collect.ImmutableSet) ResourcesTableFactory.value(com.android.tools.build.bundletool.testing.ResourcesTableFactory.value) TargetingUtils.apkTextureTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkTextureTargeting) ImmutableMap(com.google.common.collect.ImmutableMap) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) SplitType(com.android.tools.build.bundletool.model.ModuleSplit.SplitType) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) NativeLibraries(com.android.bundle.Files.NativeLibraries) List(java.util.List) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) Optional(java.util.Optional) ABI(com.android.tools.build.bundletool.model.OptimizationDimension.ABI) TargetingUtils.apkLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkLanguageTargeting) ManifestProtoUtils.withMaxSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMaxSdkVersion) TargetingUtils.apkAbiTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkAbiTargeting) BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) TestUtils.extractPaths(com.android.tools.build.bundletool.testing.TestUtils.extractPaths) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) ACTIVITY_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ACTIVITY_ELEMENT_NAME) S3TC(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.S3TC) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ManifestProtoUtils.withInstant(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstant) APPLICATION_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.APPLICATION_ELEMENT_NAME) JUnit4(org.junit.runners.JUnit4) XHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XHDPI) Truth.assertThat(com.google.common.truth.Truth.assertThat) ETC1_RGB8(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ETC1_RGB8) Maps(com.google.common.collect.Maps) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) Ignore(org.junit.Ignore) TargetingUtils.apkAlternativeLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkAlternativeLanguageTargeting) XmlElement(com.android.aapt.Resources.XmlElement) Versions(com.android.tools.build.bundletool.model.utils.Versions) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 35 with AndroidManifest

use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.

the class ModuleSplitterTest method nativeSplits_mPlusTargeting_withAbiAndUncompressNativeLibsSplitter.

@Test
public void nativeSplits_mPlusTargeting_withAbiAndUncompressNativeLibsSplitter() throws Exception {
    NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting("x86")));
    BundleModule testModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeConfig).addFile("lib/x86/liba.so").build();
    ModuleSplitter moduleSplitter = ModuleSplitter.createNoStamp(testModule, BUNDLETOOL_VERSION, APP_BUNDLE, ApkGenerationConfiguration.builder().setOptimizationDimensions(ImmutableSet.of(ABI)).setEnableUncompressedNativeLibraries(true).build(), variantMinSdkTargeting(ANDROID_M_API_VERSION), ImmutableSet.of("testModule"));
    List<ModuleSplit> splits = moduleSplitter.splitModule();
    // Base + X86 Split
    assertThat(splits).hasSize(2);
    assertThat(splits.stream().map(ModuleSplit::getSplitType).distinct().collect(toImmutableSet())).containsExactly(SplitType.SPLIT);
    assertThat(splits.stream().map(split -> split.getVariantTargeting()).collect(toImmutableSet())).containsExactly(variantMinSdkTargeting(ANDROID_M_API_VERSION));
    ModuleSplit master = splits.stream().filter(ModuleSplit::isMasterSplit).collect(onlyElement());
    ModuleSplit abi = splits.stream().filter(not(ModuleSplit::isMasterSplit)).collect(onlyElement());
    assertThat(master.getAndroidManifest().getExtractNativeLibsValue()).hasValue(false);
    assertThat(abi.findEntry("lib/x86/liba.so").get().getForceUncompressed()).isTrue();
}
Also used : ManifestProtoUtils.withSplitNameActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameActivity) ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ResourcesTableFactory.locale(com.android.tools.build.bundletool.testing.ResourcesTableFactory.locale) TargetingUtils.textureCompressionTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.textureCompressionTargeting) TargetingUtils.alternativeLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.alternativeLanguageTargeting) SCREEN_DENSITY(com.android.tools.build.bundletool.model.OptimizationDimension.SCREEN_DENSITY) Predicates.not(com.google.common.base.Predicates.not) ResourceId(com.android.tools.build.bundletool.model.ResourceId) Map(java.util.Map) DEVICE_TIER(com.android.tools.build.bundletool.model.OptimizationDimension.DEVICE_TIER) TargetingUtils.lPlusVariantTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.lPlusVariantTargeting) ManifestMutator.withExtractNativeLibs(com.android.tools.build.bundletool.model.ManifestMutator.withExtractNativeLibs) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) Version(com.android.tools.build.bundletool.model.version.Version) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) ResourceTable(com.android.aapt.Resources.ResourceTable) SPLIT_NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SPLIT_NAME_RESOURCE_ID) ModuleSplitUtils.applyManifestMutators(com.android.tools.build.bundletool.testing.ModuleSplitUtils.applyManifestMutators) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) ConfigValue(com.android.aapt.Resources.ConfigValue) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) StampType(com.android.tools.build.bundletool.model.SourceStamp.StampType) ManifestProtoUtils.withMinSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMinSdkVersion) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) Assets(com.android.bundle.Files.Assets) TargetingUtils.assetsDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.assetsDirectoryTargeting) STAMP_TYPE_METADATA_KEY(com.android.tools.build.bundletool.model.SourceStamp.STAMP_TYPE_METADATA_KEY) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Iterables(com.google.common.collect.Iterables) STAMP_SOURCE_METADATA_KEY(com.android.tools.build.bundletool.model.SourceStamp.STAMP_SOURCE_METADATA_KEY) TargetingUtils.variantMinSdkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.variantMinSdkTargeting) ZipPath(com.android.tools.build.bundletool.model.ZipPath) OptimizationDimension(com.android.tools.build.bundletool.model.OptimizationDimension) ATC(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ATC) RunWith(org.junit.runner.RunWith) TargetingUtils.apkMinSdkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkMinSdkTargeting) TEXTURE_COMPRESSION_FORMAT(com.android.tools.build.bundletool.model.OptimizationDimension.TEXTURE_COMPRESSION_FORMAT) TargetingUtils.getSplitsWithTargetingEqualTo(com.android.tools.build.bundletool.testing.TargetingUtils.getSplitsWithTargetingEqualTo) TruthResourceTable.assertThat(com.android.tools.build.bundletool.testing.truth.resources.TruthResourceTable.assertThat) ANDROID_R_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_R_API_VERSION) LANGUAGE(com.android.tools.build.bundletool.model.OptimizationDimension.LANGUAGE) ManifestProtoUtils.withMetadataResource(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMetadataResource) ResourcesTableFactory.mergeConfigs(com.android.tools.build.bundletool.testing.ResourcesTableFactory.mergeConfigs) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) XmlProtoElement(com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoElement) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) ANDROID_Q_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_Q_API_VERSION) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) SuffixStripping(com.android.bundle.Config.SuffixStripping) ManifestProtoUtils.clearApplication(com.android.tools.build.bundletool.testing.ManifestProtoUtils.clearApplication) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) HDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) TestCase.fail(junit.framework.TestCase.fail) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) Test(org.junit.Test) ANDROID_L_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_L_API_VERSION) ANDROID_M_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_M_API_VERSION) TargetingUtils.assets(com.android.tools.build.bundletool.testing.TargetingUtils.assets) TargetingUtils.apkDensityTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDensityTargeting) XmlNode(com.android.aapt.Resources.XmlNode) TargetingUtils.mergeApkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting) ManifestProtoUtils.withMainActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMainActivity) ModuleSplitUtils.createModuleSplitBuilder(com.android.tools.build.bundletool.testing.ModuleSplitUtils.createModuleSplitBuilder) AppBundle(com.android.tools.build.bundletool.model.AppBundle) BundleModule(com.android.tools.build.bundletool.model.BundleModule) TargetingUtils.apkDeviceTierTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDeviceTierTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) ManifestProtoUtils.xmlAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlAttribute) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ANDROID_NAMESPACE_URI(com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI) TargetingUtils.deviceTierTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.deviceTierTargeting) TargetingUtils.targetedAssetsDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedAssetsDirectory) NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.NAME_RESOURCE_ID) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) TargetingUtils.languageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.languageTargeting) ImmutableSet(com.google.common.collect.ImmutableSet) ResourcesTableFactory.value(com.android.tools.build.bundletool.testing.ResourcesTableFactory.value) TargetingUtils.apkTextureTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkTextureTargeting) ImmutableMap(com.google.common.collect.ImmutableMap) CommandExecutionException(com.android.tools.build.bundletool.model.exceptions.CommandExecutionException) SplitType(com.android.tools.build.bundletool.model.ModuleSplit.SplitType) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) NativeLibraries(com.android.bundle.Files.NativeLibraries) List(java.util.List) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) Optional(java.util.Optional) ABI(com.android.tools.build.bundletool.model.OptimizationDimension.ABI) TargetingUtils.apkLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkLanguageTargeting) ManifestProtoUtils.withMaxSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMaxSdkVersion) TargetingUtils.apkAbiTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkAbiTargeting) BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) TestUtils.extractPaths(com.android.tools.build.bundletool.testing.TestUtils.extractPaths) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) ACTIVITY_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ACTIVITY_ELEMENT_NAME) S3TC(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.S3TC) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ManifestProtoUtils.withInstant(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstant) APPLICATION_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.APPLICATION_ELEMENT_NAME) JUnit4(org.junit.runners.JUnit4) XHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XHDPI) Truth.assertThat(com.google.common.truth.Truth.assertThat) ETC1_RGB8(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ETC1_RGB8) Maps(com.google.common.collect.Maps) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) Ignore(org.junit.Ignore) TargetingUtils.apkAlternativeLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkAlternativeLanguageTargeting) XmlElement(com.android.aapt.Resources.XmlElement) Versions(com.android.tools.build.bundletool.model.utils.Versions) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Aggregations

AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)130 Test (org.junit.Test)115 ImmutableList (com.google.common.collect.ImmutableList)94 AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)90 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)89 Truth.assertThat (com.google.common.truth.Truth.assertThat)89 RunWith (org.junit.runner.RunWith)89 ImmutableSet (com.google.common.collect.ImmutableSet)87 AppBundle (com.android.tools.build.bundletool.model.AppBundle)84 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)82 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)81 VariantTargeting (com.android.bundle.Targeting.VariantTargeting)80 ZipPath (com.android.tools.build.bundletool.model.ZipPath)80 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)79 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)79 Path (java.nio.file.Path)79 AppBundleSerializer (com.android.tools.build.bundletool.io.AppBundleSerializer)78 Files (java.nio.file.Files)78 Before (org.junit.Before)78 Rule (org.junit.Rule)78