/** Writes the given split to the path subdirectory in the APK Set. */ private ApkDescription writeToDisk( ModuleSplit split, Path outputDirectory, BiFunction<ApkDescription.Builder, SplitApkMetadata, ApkDescription.Builder> setApkMetadata) { checkState(isDirectory(outputDirectory), "Output directory does not exist."); ZipPath apkPath = apkPathManager.getApkPath(split); apkSerializerHelper.writeToZipFile(split, outputDirectory.resolve(apkPath.toString())); ApkDescription.Builder builder = ApkDescription.newBuilder() .setPath(apkPath.toString()) .setTargeting(split.getApkTargeting()); return setApkMetadata .apply( builder, SplitApkMetadata.newBuilder() .setSplitId(split.getAndroidManifest().getSplitId().orElse("")) .setIsMasterSplit(split.isMasterSplit()) .build()) .build(); } }
@VisibleForTesting ApkDescription writeToDiskInternal( ModuleSplit standaloneSplit, Path outputDirectory, ZipPath apkPath) { apkSerializerHelper.writeToZipFile( standaloneSplit, outputDirectory.resolve(apkPath.toString())); return ApkDescription.newBuilder() .setPath(apkPath.toString()) .setStandaloneApkMetadata( StandaloneApkMetadata.newBuilder() .addAllFusedModuleName(standaloneSplit.getAndroidManifest().getFusedModuleNames())) .setTargeting(standaloneSplit.getApkTargeting()) .build(); }
public static ApkDescription createApkDescription( ApkTargeting apkTargeting, Path apkPath, boolean isMasterSplit) { return ApkDescription.newBuilder() .setPath(apkPath.toString()) .setTargeting(apkTargeting) .setSplitApkMetadata(SplitApkMetadata.newBuilder().setIsMasterSplit(isMasterSplit)) .build(); }
assertThat(systemApks) .containsExactly( ApkDescription.newBuilder() .setPath("system/system.apk") .setTargeting(ApkTargeting.getDefaultInstance()) assertThat(systemApks) .containsExactly( ApkDescription.newBuilder() .setPath("system/system.apk") .setTargeting(ApkTargeting.getDefaultInstance()) .addAllFusedModuleName(ImmutableList.of("base", "fused"))) .build(), ApkDescription.newBuilder() .setPath("system/system.apk.gz") .setTargeting(ApkTargeting.getDefaultInstance())
public static ApkSet createSystemApkSet(ApkTargeting apkTargeting, Path apkPath) { // Note: System APK is represented as a module named "base". return ApkSet.newBuilder() .setModuleMetadata(ModuleMetadata.newBuilder().setName("base")) .addApkDescription( ApkDescription.newBuilder() .setPath(apkPath.toString()) .setTargeting(apkTargeting) .setSystemApkMetadata( SystemApkMetadata.newBuilder() .addFusedModuleName("base") .setSystemApkType(SystemApkType.SYSTEM))) .build(); } }
public static Variant standaloneVariant( VariantTargeting variantTargeting, ApkTargeting apkTargeting, ZipPath apkPath) { // A standalone variant has only a single APK with module named "base". return createVariant( variantTargeting, ApkSet.newBuilder() .setModuleMetadata(ModuleMetadata.newBuilder().setName("base")) .addApkDescription( ApkDescription.newBuilder() .setTargeting(apkTargeting) .setPath(apkPath.toString()) // Contents of the standalone APK metadata is not important for these tests // as long as the field is set. .setStandaloneApkMetadata(StandaloneApkMetadata.getDefaultInstance())) .build()); }
public static ApkSet createStandaloneApkSet(ApkTargeting apkTargeting, Path apkPath) { // Note: Standalone APK is represented as a module named "base". return ApkSet.newBuilder() .setModuleMetadata(ModuleMetadata.newBuilder().setName("base")) .addApkDescription( ApkDescription.newBuilder() .setPath(apkPath.toString()) .setTargeting(apkTargeting) .setStandaloneApkMetadata( StandaloneApkMetadata.newBuilder().addFusedModuleName("base"))) .build(); }
public static ApkDescription instantApkDescription(ApkTargeting apkTargeting, ZipPath apkPath) { return ApkDescription.newBuilder() .setTargeting(apkTargeting) .setPath(apkPath.toString()) // Contents of the instant APK metadata is not important for these tests as long as // the field is set. .setInstantApkMetadata(SplitApkMetadata.getDefaultInstance()) .build(); }
/** Creates an instant apk set with the given module name, ApkTargeting, and path for the apk. */ public static ApkSet createInstantApkSet( String moduleName, ApkTargeting apkTargeting, Path apkPath) { return ApkSet.newBuilder() .setModuleMetadata(ModuleMetadata.newBuilder().setName(moduleName).setIsInstant(true)) .addApkDescription( ApkDescription.newBuilder() .setPath(apkPath.toString()) .setTargeting(apkTargeting) .setInstantApkMetadata(SplitApkMetadata.newBuilder().setIsMasterSplit(true))) .build(); }
private static ApkDescription createSystemApkDescription( ModuleSplit systemSplit, ZipPath apkPath, SystemApkMetadata.SystemApkType apkType) { return ApkDescription.newBuilder() .setPath(apkPath.toString()) .setSystemApkMetadata( SystemApkMetadata.newBuilder() .addAllFusedModuleName(systemSplit.getAndroidManifest().getFusedModuleNames()) .setSystemApkType(apkType)) .setTargeting(systemSplit.getApkTargeting()) .build(); }
public static ApkDescription splitApkDescription(ApkTargeting apkTargeting, ZipPath apkPath) { return ApkDescription.newBuilder() .setTargeting(apkTargeting) .setPath(apkPath.toString()) // Contents of the split APK metadata is not important for these tests as long as // the field is set. .setSplitApkMetadata(SplitApkMetadata.getDefaultInstance()) .build(); }