public ImmutableList processBundle()

in analyzer/src/main/java/com/android/tools/sizereduction/analyzer/suggesters/bundles/BundleSplitSuggester.java [75:135]


  public ImmutableList<Suggestion> processBundle(
      BundleContext context, AppBundle bundle, ZipFile bundleZip) {
    ImmutableSet<SplitDimension.Value> splitDimensionsNotUsed =
        bundle.getBundleConfig().getOptimizations().getSplitsConfig().getSplitDimensionList()
            .stream()
            .filter(SplitDimension::getNegate)
            .map(SplitDimension::getValue)
            .collect(toImmutableSet());
    ImmutableList.Builder<Suggestion> suggestions = ImmutableList.builder();

    if (splitDimensionsNotUsed.contains(SplitDimension.Value.ABI)) {
      // Set of ABIs that native libraries in the bundle target.
      ImmutableSet<AbiAlias> abis =
          bundle.getModules().values().stream()
              .map(BundleModule::getNativeConfig)
              .filter(Optional::isPresent)
              .map(Optional::get)
              .flatMap(BundleSplitSuggester::getUsedAbis)
              .collect(toImmutableSet());

      if (!abis.isEmpty()) {
        suggestions.add(
            Suggestion.create(
                IssueType.BUNDLES_NO_ABI_SPLITTING,
                Category.BUNDLE_CONFIG,
                Payload.newBuilder()
                    .setBundleSplittingData(
                        BundleSplittingData.newBuilder()
                            .addAllAbis(
                                abis.stream().map(AbiAlias::toString).collect(toImmutableList())))
                    .build(),
                NO_ABI_SPLITTING_MESSAGE,
                /* estimatedBytesSaved= */ null,
                /* autoFix= */ null));
      }
    }

    if (splitDimensionsNotUsed.contains(SplitDimension.Value.SCREEN_DENSITY)) {
      suggestions.add(
          Suggestion.create(
              IssueType.BUNDLES_NO_DENSITY_SPLITTING,
              Category.BUNDLE_CONFIG,
              Payload.getDefaultInstance(),
              NO_DISPLAY_DENSITY_SPLITTING_MESSAGE,
              /* estimatedBytesSaved= */ null,
              /* autoFix= */ null));
    }

    if (splitDimensionsNotUsed.contains(SplitDimension.Value.LANGUAGE)) {
      suggestions.add(
          Suggestion.create(
              IssueType.BUNDLES_NO_LANGUAGE_SPLITTING,
              Category.BUNDLE_CONFIG,
              Payload.getDefaultInstance(),
              NO_LANGUAGE_SPLITTING_MESSAGE,
              /* estimatedBytesSaved= */ null,
              /* autoFix= */ null));
    }

    return suggestions.build();
  }