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();
}
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();
}
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);
}
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();
}
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();
}
Aggregations