Use -Othroughput within ValidateAndLinkResourcesAction

Since linkStatically is used exclusively in ValidateAndLinkResourcesAction, this change adds the -Othroughput flag directly to the linkStatically method in ResourceLinker.java. This enables the benefits of -Othroughput's decreased runtime for LinkResourcesAction.

ValidateAndLinkResourcesAction is only used for intermediate resource validation, so a lower compression level will not impact release APKs.

PiperOrigin-RevId: 949238225
Change-Id: Id965bb3456e4f1ca3035950c150dded8874c58b0
diff --git a/src/tools/java/com/google/devtools/build/android/aapt2/ResourceLinker.java b/src/tools/java/com/google/devtools/build/android/aapt2/ResourceLinker.java
index 6a342d4..5126f30 100644
--- a/src/tools/java/com/google/devtools/build/android/aapt2/ResourceLinker.java
+++ b/src/tools/java/com/google/devtools/build/android/aapt2/ResourceLinker.java
@@ -306,6 +306,8 @@
               .add("--no-static-lib-packages")
               .add("--custom-package", customPackage)
               .add("--feature-flags", featureFlags)
+              .when(getCompatFlag("aapt2_othroughput_supported"))
+              .thenAdd("-Othroughput")
               .whenVersionIsAtLeast(new Revision(23))
               .thenAdd("--no-version-vectors")
               .addParameterableRepeated(