in analyzer/src/main/java/com/android/tools/sizereduction/analyzer/suggesters/bundles/UncompressedNativeLibsSuggester.java [49:85]
public ImmutableList<Suggestion> processBundle(
BundleContext context, AppBundle bundle, ZipFile bundleZip) {
boolean oldBundletool =
Version.of(bundle.getBundleConfig().getBundletool().getVersion())
.isOlderThan(Version.of("0.6.0"));
boolean uncompressedNativeLibsEnabled =
bundle.getBundleConfig().getOptimizations().getUncompressNativeLibraries().getEnabled();
boolean hasNativeLibs =
bundle.getModules().values().stream()
.map(BundleModule::getNativeConfig)
.filter(Optional::isPresent)
.map(Optional::get)
.anyMatch(
libs ->
libs.getDirectoryList().stream()
.anyMatch(directory -> directory.getTargeting().hasAbi()));
if (!hasNativeLibs) {
// If there are no native libraries in the bundle it makes no sense to suggest anything.
return ImmutableList.of();
}
if (oldBundletool) {
return ImmutableList.of(
uncompressedNativeLibsSuggestion(
OLD_BUNDLETOOL_USE_NEW_FOR_UNCOMPRESSED_NATIVE_LIBS_MESSAGE, Status.OLD_BUNDLETOOL));
} else if (!uncompressedNativeLibsEnabled) {
return ImmutableList.of(
uncompressedNativeLibsSuggestion(
NO_UNCOMPRESSED_NATIVE_LIBS_MESSAGE, Status.UNCOMPRESSED_NATIVE_LIBS_NOT_ENABLED));
}
return ImmutableList.of();
}