use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method selectsRightModules_systemApks.
@Test
@Theory
public void selectsRightModules_systemApks() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.addFile("assets/base.txt").setManifest(androidManifest("com.app")).setResourceTable(resourceTableWithTestLabel("Test feature"))).addModule("fused", module -> module.addFile("assets/fused.txt").setManifest(androidManifestForFeature("com.app", withFusingAttribute(true), withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).addModule("not_fused", module -> module.addFile("assets/not_fused.txt").setManifest(androidManifestForFeature("com.app", withFusingAttribute(false), withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withApkBuildMode(SYSTEM).withDeviceSpec(mergeSpecs(sdkVersion(28), abis("x86"), density(DensityAlias.MDPI), locales("en-US"))).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
// System APKs: Only base and modules marked for fusing must be used.
assertThat(systemApkVariants(result)).hasSize(1);
ImmutableList<ApkDescription> systemApks = apkDescriptions(systemApkVariants(result));
assertThat(systemApks).containsExactly(ApkDescription.newBuilder().setPath("system/system.apk").setTargeting(ApkTargeting.getDefaultInstance()).setSystemApkMetadata(SystemApkMetadata.newBuilder().addAllFusedModuleName(ImmutableList.of("base", "fused"))).build(), ApkDescription.newBuilder().setPath("splits/not_fused-master.apk").setTargeting(ApkTargeting.getDefaultInstance()).setSplitApkMetadata(SplitApkMetadata.newBuilder().setSplitId("not_fused").setIsMasterSplit(true)).build());
File systemApkFile = extractFromApkSetFile(apkSetFile, "system/system.apk", outputDir);
// Validate that the system APK contains appropriate files.
ZipFile systemApkZip = openZipFile(systemApkFile);
assertThat(filesUnderPath(systemApkZip, ZipPath.create("assets"))).containsExactly("assets/base.txt", "assets/fused.txt");
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_apkNotificationMessageKeyApexBundle_hasRightSuffix.
@Test
public void buildApksCommand_apkNotificationMessageKeyApexBundle_hasRightSuffix() throws Exception {
ApexImages apexConfig = apexImages(targetedApexImage("apex/x86_64.img", apexImageTargeting("x86_64")), targetedApexImage("apex/x86.img", apexImageTargeting("x86")), targetedApexImage("apex/arm64-v8a.img", apexImageTargeting("arm64-v8a")), targetedApexImage("apex/armeabi-v7a.img", apexImageTargeting("armeabi-v7a")), targetedApexImage("apex/arm64-v8a.armeabi-v7a.img", apexImageTargeting("arm64-v8a", "armeabi-v7a")));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile(APEX_MANIFEST_PATH, APEX_MANIFEST).addFile("apex/x86_64.img").addFile("apex/x86.img").addFile("apex/arm64-v8a.img").addFile("apex/armeabi-v7a.img").addFile("apex/arm64-v8a.armeabi-v7a.img").setApexConfig(apexConfig).setManifest(androidManifest("com.test.app"))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).build());
buildApksManager.execute();
BuildApksResult result = extractTocFromApkSetFile(openZipFile(outputFilePath.toFile()), outputDir);
ImmutableList<Variant> variants = apexApkVariants(result);
ImmutableSet<String> apkPaths = variants.stream().map(variant -> getOnlyElement(getOnlyElement(variant.getApkSetList()).getApkDescriptionList()).getPath()).collect(toImmutableSet());
assertThat(apkPaths).containsExactly("standalones/standalone-x86_64.apex", "standalones/standalone-x86.apex", "standalones/standalone-arm64_v8a.apex", "standalones/standalone-armeabi_v7a.apex", "standalones/standalone-armeabi_v7a.arm64_v8a.apex");
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class SystemApksGeneratorTest method uncompressedNativeLibraries_enabled_multiApks.
@Test
public void uncompressedNativeLibraries_enabled_multiApks() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("lib/x86_64/libtest1.so").addFile("lib/x86/libtest1.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)))).setManifest(androidManifestForFeature("com.test.app")).build();
BundleModule featureModule = new BundleModuleBuilder("feature").addFile("lib/x86_64/libtest2.so").addFile("lib/x86/libtest2.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)))).setManifest(androidManifestForFeature("com.test.app.feature")).build();
ApkOptimizations apkOptimizations = splitOptimizations(OptimizationDimension.ABI).toBuilder().setUncompressNativeLibraries(true).build();
ImmutableList<ModuleSplit> shards = systemApksGenerator.generateSystemApks(/* modules= */
ImmutableList.of(baseModule, featureModule), /* modulesToFuse= */
ImmutableSet.of(BASE_MODULE_NAME), apkOptimizations);
assertThat(shards).hasSize(3);
ModuleSplit systemApk = getSystemImageSplit(shards);
assertThat(systemApk.getAndroidManifest().getExtractNativeLibsValue()).hasValue(false);
assertThat(systemApk.findEntry("lib/x86/libtest1.so").map(ModuleEntry::getForceUncompressed)).hasValue(true);
ModuleSplit additionalNativeSplit = getAdditionalSplits(shards).stream().filter(split -> split.getApkTargeting().hasAbiTargeting()).collect(onlyElement());
assertThat(additionalNativeSplit.findEntry("lib/x86/libtest2.so").map(ModuleEntry::getForceUncompressed)).hasValue(true);
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_standalone_oneModuleManyVariants.
@Test
public void buildApksCommand_standalone_oneModuleManyVariants() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("dex/classes.dex").addFile("lib/x86/libsome.so").addFile("lib/x86_64/libsome.so").addFile("lib/mips/libsome.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/mips", nativeDirectoryTargeting(MIPS)))).setManifest(androidManifest("com.test.app"))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withOptimizationDimensions(ABI).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
ImmutableMap<Abi, Variant> standaloneVariantsByAbi = Maps.uniqueIndex(standaloneApkVariants(result), variant -> {
ApkDescription apkDescription = getOnlyElement(apkDescriptions(variant));
return getOnlyElement(apkDescription.getTargeting().getAbiTargeting().getValueList());
});
assertThat(standaloneVariantsByAbi.keySet()).containsExactly(toAbi(X86), toAbi(X86_64), toAbi(MIPS));
assertThat(standaloneVariantsByAbi.get(toAbi(X86)).getTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeVariantTargeting(variantAbiTargeting(X86, ImmutableSet.of(X86_64, MIPS)), variantSdkTargeting(LOWEST_SDK_VERSION, ImmutableSet.of(L_SDK_VERSION, M_SDK_VERSION))));
assertThat(standaloneVariantsByAbi.get(toAbi(X86_64)).getTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeVariantTargeting(variantAbiTargeting(X86_64, ImmutableSet.of(X86, MIPS)), variantSdkTargeting(LOWEST_SDK_VERSION, ImmutableSet.of(L_SDK_VERSION, M_SDK_VERSION))));
assertThat(standaloneVariantsByAbi.get(toAbi(MIPS)).getTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeVariantTargeting(variantAbiTargeting(MIPS, ImmutableSet.of(X86, X86_64)), variantSdkTargeting(LOWEST_SDK_VERSION, ImmutableSet.of(L_SDK_VERSION, M_SDK_VERSION))));
for (Variant variant : standaloneVariantsByAbi.values()) {
assertThat(variant.getApkSetList()).hasSize(1);
ApkSet apkSet = variant.getApkSet(0);
assertThat(apkSet.getApkDescriptionList()).hasSize(1);
assertThat(apkSetFile).hasFile(apkSet.getApkDescription(0).getPath());
}
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method mergeInstallTimeModulesByDefault.
@Test
public void mergeInstallTimeModulesByDefault() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("dex/classes.dex").setManifest(androidManifest("com.test.app"))).addModule("abi_feature", builder -> builder.addFile("lib/x86/libsome.so").addFile("lib/x86_64/libsome.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)))).setManifest(androidManifest("com.test.app", withInstallTimeDelivery(), withFusingAttribute(true)))).setBundleConfig(BundleConfigBuilder.create().setVersion("1.0.0").build()).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
ImmutableList<Variant> splitApkVariants = splitApkVariants(result);
assertThat(splitApkVariants).isNotEmpty();
assertThat(result.getPermanentlyFusedModulesList()).containsExactly(PermanentlyFusedModule.newBuilder().setName("abi_feature").build());
for (Variant splitApkVariant : splitApkVariants(result)) {
assertThat(splitApkVariant.getApkSetList()).comparingElementsUsing(Correspondence.from((ApkSet apkSet, String moduleName) -> apkSet != null && apkSet.getModuleMetadata().getName().equals(moduleName), "equals")).containsExactly("base");
}
}
Aggregations