in analyzer/src/main/java/com/android/tools/sizereduction/analyzer/suggesters/libraries/LibraryEligibleForFeatureSplitSuggester.java [164:194]
private static ImmutableList<Suggestion> suggestionsFromLibraryUsages(
ImmutableMap<Library, ImmutableList<String>> libraryUsage) {
ImmutableList<LibraryEligibleForFeatureSplit> libraryUsages =
libraryUsage.entrySet().stream()
.map(
singleLibraryUsage ->
LibraryEligibleForFeatureSplit.newBuilder()
.setLibrary(singleLibraryUsage.getKey())
.setUsage(
getLibraryUsageStatusFromModuleList(singleLibraryUsage.getValue()))
.build())
.collect(toImmutableList());
if (libraryUsages.stream()
.map(LibraryEligibleForFeatureSplit::getUsage)
.allMatch(Predicate.isEqual(LibraryUsage.LIBRARY_NOT_USED))) {
return ImmutableList.of();
}
return ImmutableList.of(
Suggestion.create(
IssueType.LIBRARY_SHOULD_BE_EXTRACTED_TO_FEATURE_SPLITS,
Category.LIBRARIES,
Payload.newBuilder()
.setLibraryForFeatureSplitUsage(
LibraryForFeatureSplitUsage.newBuilder().addAllLibraryUsage(libraryUsages))
.build(),
LIBRARIES_IN_FEATURE_MODULES,
/* estimatedBytesSaved= */ null,
/* autoFix= */ null));
}