public ImmutableList<ModuleSplit> generateApexSplits(ImmutableList<BundleModule> modules) { BundleSharder bundleSharder = new BundleSharder(tempDir, bundleVersion, generate64BitShards); ImmutableList<ModuleSplit> shardedApexApks = bundleSharder.shardApexBundle(getOnlyElement(modules)); return setVariantTargetingAndSplitType(shardedApexApks, splitType); }
private ImmutableList<ModuleSplit> generateSplitsInternal( ImmutableList<BundleModule> modules, BundleMetadata bundleMetadata, ApkOptimizations apkOptimizations, Optional<DeviceSpec> deviceSpec) { BundleSharder bundleSharder = new BundleSharder(tempDir, bundleVersion, generate64BitShards, deviceSpec); ImmutableList<ModuleSplit> shardedApks = bundleSharder.shardBundle(modules, apkOptimizations.getSplitDimensions(), bundleMetadata); return setVariantTargetingAndSplitType(shardedApks, splitType); }
@Before public void setUp() { tmpDir = Paths.get("real/directory/not/needed/in/this/test"); bundleSharder = new BundleSharder(tmpDir, BundleToolVersion.getCurrentVersion()); }
@Test @Theory public void shardByAbiAndDensity_havingNoAbiAndNoResources_producesOneApk( @FromDataPoints("deviceSpecs") Optional<DeviceSpec> deviceSpec) throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(), /* generate64BitShards= */ true, deviceSpec); BundleModule bundleModule = new BundleModuleBuilder("base") .addFile("assets/file.txt") .addFile("dex/classes.dex") .addFile("root/license.dat") .setManifest(androidManifest("com.test.app")) .build(); ImmutableList<ModuleSplit> shards = bundleSharder.shardBundle( ImmutableList.of(bundleModule), ImmutableSet.of(OptimizationDimension.ABI, OptimizationDimension.SCREEN_DENSITY), DEFAULT_METADATA); assertThat(shards).hasSize(1); ModuleSplit fatShard = shards.get(0); assertThat(fatShard.getApkTargeting()).isEqualToDefaultInstance(); assertThat(fatShard.getVariantTargeting()).isEqualToDefaultInstance(); assertThat(fatShard.getSplitType()).isEqualTo(SplitType.STANDALONE); assertThat(extractPaths(fatShard.getEntries())) .containsExactly("assets/file.txt", "dex/classes.dex", "root/license.dat"); }
@Test public void shardByAbi_64BitAbisDisabled_filteredOut() throws Exception { BundleModule bundleModule = new BundleModuleBuilder("base") .addFile("dex/classes.dex") .addFile("lib/x86/libtest.so") .addFile("lib/x86_64/libtest.so") .setManifest(androidManifest("com.test.app")) .setNativeConfig( nativeLibraries( targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)))) .build(); BundleSharder bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(), /* generate64BitShards= */ false); ImmutableList<ModuleSplit> shards = bundleSharder.shardBundle( ImmutableList.of(bundleModule), ImmutableSet.of(OptimizationDimension.ABI), DEFAULT_METADATA); assertThat(shards).hasSize(1); ModuleSplit shard = shards.get(0); assertThat(shard.getSplitType()).isEqualTo(SplitType.STANDALONE); assertThat(shard.getVariantTargeting()).isEqualToDefaultInstance(); assertThat(extractPaths(shard.getEntries())) .containsAllOf("dex/classes.dex", "lib/x86/libtest.so"); assertThat(shard.getApkTargeting()).isEqualTo(apkAbiTargeting(X86)); }
throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(),
@FromDataPoints("deviceSpecs") Optional<DeviceSpec> deviceSpec) throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(),
throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(),
@FromDataPoints("deviceSpecs") Optional<DeviceSpec> deviceSpec) throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(),
new BundleSharder(tmpDir, BundleToolVersion.getCurrentVersion(), generate64BitShards);
@Test public void shardByAbi_havingManyAbisWithDeviceSpec_producesSingleApk() throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(),
@FromDataPoints("deviceSpecs") Optional<DeviceSpec> deviceSpec) throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(),
@FromDataPoints("deviceSpecs") Optional<DeviceSpec> deviceSpec) throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(),