/** 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(); } }
Maps.uniqueIndex( baseModuleApks, apkDescription -> apkDescription.getSplitApkMetadata().getIsMasterSplit()); Maps.uniqueIndex( featureModuleApks, apkDescription -> apkDescription.getSplitApkMetadata().getIsMasterSplit());
public static ApkDescription createApkDescription( ApkTargeting apkTargeting, Path apkPath, boolean isMasterSplit) { return ApkDescription.newBuilder() .setPath(apkPath.toString()) .setTargeting(apkTargeting) .setSplitApkMetadata(SplitApkMetadata.newBuilder().setIsMasterSplit(isMasterSplit)) .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(); }
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(); }