use of com.android.bundle.Files.NativeLibraries 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.bundle.Files.NativeLibraries 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.bundle.Files.NativeLibraries in project bundletool by google.
the class ModuleSplitterTest method nativeSplits_mPlusTargeting_disabledUncompressedSplitter.
@Test
public void nativeSplits_mPlusTargeting_disabledUncompressedSplitter() {
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(false).build(), variantMinSdkTargeting(ANDROID_M_API_VERSION), ImmutableSet.of("testModule"));
List<ModuleSplit> splits = moduleSplitter.splitModule();
assertThat(splits).hasSize(2);
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.bundle.Files.NativeLibraries 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();
}
use of com.android.bundle.Files.NativeLibraries in project bundletool by google.
the class ModuleSplitterTest method testModuleSplitter_nativeSplit_addsNoStamp.
@Test
public void testModuleSplitter_nativeSplit_addsNoStamp() throws Exception {
String stampSource = "https://www.example.com";
StampType stampType = StampType.STAMP_TYPE_DISTRIBUTION_APK;
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.create(testModule, BUNDLETOOL_VERSION, APP_BUNDLE, ApkGenerationConfiguration.builder().setOptimizationDimensions(ImmutableSet.of(ABI)).setEnableUncompressedNativeLibraries(true).build(), lPlusVariantTargeting(), ImmutableSet.of("testModule"), Optional.of(stampSource), stampType);
List<ModuleSplit> splits = moduleSplitter.splitModule();
// Base + x86 splits
assertThat(splits).hasSize(2);
ModuleSplit x86Split = splits.stream().filter(split -> split.getApkTargeting().hasAbiTargeting()).findFirst().get();
assertThat(x86Split.getAndroidManifest().getMetadataValue(STAMP_TYPE_METADATA_KEY)).isEmpty();
assertThat(x86Split.getAndroidManifest().getMetadataValue(STAMP_SOURCE_METADATA_KEY)).isEmpty();
}
Aggregations