Search in sources :

Example 1 with ManifestDeliveryElement

use of com.android.tools.build.bundletool.model.ManifestDeliveryElement 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();
}
Also used : ManifestDeliveryElement(com.android.tools.build.bundletool.model.ManifestDeliveryElement) InstantMetadata(com.android.bundle.Commands.InstantMetadata) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) AssetModuleMetadata(com.android.bundle.Commands.AssetModuleMetadata)

Aggregations

AssetModuleMetadata (com.android.bundle.Commands.AssetModuleMetadata)1 InstantMetadata (com.android.bundle.Commands.InstantMetadata)1 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)1 ManifestDeliveryElement (com.android.tools.build.bundletool.model.ManifestDeliveryElement)1