use of com.android.bundle.Commands.AssetModuleMetadata in project bundletool by google.
the class ApkSerializerManager method getAssetModuleMetadata.
private AssetModuleMetadata getAssetModuleMetadata(BundleModule module) {
AndroidManifest manifest = module.getAndroidManifest();
AssetModuleMetadata.Builder metadataBuilder = AssetModuleMetadata.newBuilder().setName(module.getName().getName());
Optional<ManifestDeliveryElement> persistentDelivery = manifest.getManifestDeliveryElement();
metadataBuilder.setDeliveryType(persistentDelivery.map(delivery -> getDeliveryType(delivery)).orElse(DeliveryType.INSTALL_TIME));
// The module is instant if either the dist:instant attribute is true or the
// dist:instant-delivery element is present.
boolean isInstantModule = module.isInstantModule();
InstantMetadata.Builder instantMetadataBuilder = InstantMetadata.newBuilder().setIsInstant(isInstantModule);
// The ManifestDeliveryElement is present if the dist:instant-delivery element is used.
Optional<ManifestDeliveryElement> instantDelivery = manifest.getInstantManifestDeliveryElement();
if (isInstantModule) {
// If it's an instant-enabled module, the instant delivery is on-demand if the dist:instant
// attribute was set to true or if the dist:instant-delivery element was used without an
// install-time element.
instantMetadataBuilder.setDeliveryType(instantDelivery.map(delivery -> getDeliveryType(delivery)).orElse(DeliveryType.ON_DEMAND));
}
metadataBuilder.setInstantMetadata(instantMetadataBuilder.build());
return metadataBuilder.build();
}
Aggregations