From 2c0d9ba4c38091a32557a56b5316d7d20fdcf71b Mon Sep 17 00:00:00 2001 From: ibaker Date: Mon, 18 Sep 2023 04:08:04 -0700 Subject: [PATCH] Rollback of https://github.com/androidx/media/commit/d58f5fdf7d9421850d4059dda4d3777f5fe03b85 PiperOrigin-RevId: 566258299 --- constants.gradle | 2 +- .../java/androidx/media3/common/util/Util.java | 15 +++++++++++++++ .../UtilScaleLargeValueParameterizedTest.java | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/constants.gradle b/constants.gradle index ae76379841..4eefd7e70d 100644 --- a/constants.gradle +++ b/constants.gradle @@ -24,7 +24,7 @@ project.ext { junitVersion = '4.13.2' // Use the same Guava version as the Android repo: // https://cs.android.com/android/platform/superproject/+/master:external/guava/METADATA - guavaVersion = '32.1.2-android' + guavaVersion = '31.1-android' mockitoVersion = '3.12.4' robolectricVersion = '4.10.3' // Keep this in sync with Google's internal Checker Framework version. diff --git a/libraries/common/src/main/java/androidx/media3/common/util/Util.java b/libraries/common/src/main/java/androidx/media3/common/util/Util.java index 5e1201f32e..a77b09985d 100644 --- a/libraries/common/src/main/java/androidx/media3/common/util/Util.java +++ b/libraries/common/src/main/java/androidx/media3/common/util/Util.java @@ -1661,6 +1661,11 @@ public final class Util { * @param roundingMode The rounding mode to use if the result of the division is not an integer. * @return The scaled value. */ + // LongMath.saturatedMultiply is @Beta in the version of Guava we currently depend on (31.1) + // but it is no longer @Beta from 32.0.0. This suppression is therefore safe because there's + // no version of Guava after 31.1 that doesn't contain this symbol. + // TODO(b/290045069): Remove this suppression when we depend on Guava 32+. + @SuppressWarnings("UnstableApiUsage") @UnstableApi public static long scaleLargeValue( long value, long multiplier, long divisor, RoundingMode roundingMode) { @@ -1693,6 +1698,11 @@ public final class Util { * @param roundingMode The rounding mode to use if the result of the division is not an integer. * @return The scaled values. */ + // LongMath.saturatedMultiply is @Beta in the version of Guava we currently depend on (31.1) + // but it is no longer @Beta from 32.0.0. This suppression is therefore safe because there's + // no version of Guava after 31.1 that doesn't contain this symbol. + // TODO(b/290045069): Remove this suppression when we depend on Guava 32+. + @SuppressWarnings("UnstableApiUsage") @UnstableApi public static long[] scaleLargeValues( List values, long multiplier, long divisor, RoundingMode roundingMode) { @@ -1792,6 +1802,11 @@ public final class Util { *

This implementation should be used after simpler simplifying efforts have failed (such as * checking if {@code value} or {@code multiplier} are exact multiples of {@code divisor}). */ + // LongMath.saturatedMultiply is @Beta in the version of Guava we currently depend on (31.1) + // but it is no longer @Beta from 32.0.0. This suppression is therefore safe because there's + // no version of Guava after 31.1 that doesn't contain this symbol. + // TODO(b/290045069): Remove this suppression when we depend on Guava 32+. + @SuppressWarnings("UnstableApiUsage") private static long scaleLargeValueFallback( long value, long multiplier, long divisor, RoundingMode roundingMode) { long numerator = LongMath.saturatedMultiply(value, multiplier); diff --git a/libraries/common/src/test/java/androidx/media3/common/util/UtilScaleLargeValueParameterizedTest.java b/libraries/common/src/test/java/androidx/media3/common/util/UtilScaleLargeValueParameterizedTest.java index a57b1c10ad..65be0c828a 100644 --- a/libraries/common/src/test/java/androidx/media3/common/util/UtilScaleLargeValueParameterizedTest.java +++ b/libraries/common/src/test/java/androidx/media3/common/util/UtilScaleLargeValueParameterizedTest.java @@ -231,6 +231,8 @@ public class UtilScaleLargeValueParameterizedTest { * floating-point branch (which will cause this test to fail because passing * RoundingMode.UNNECESSARY won't be allowed). */ + // TODO(b/290045069): Remove this suppression when we depend on Guava 32+. + @SuppressWarnings("UnstableApiUsage") @Test public void cancelsRatherThanFallThroughToFloatingPoint() { long value = 24960; @@ -245,6 +247,8 @@ public class UtilScaleLargeValueParameterizedTest { assertThat(result).isEqualTo(520000); } + // TODO(b/290045069): Remove this suppression when we depend on Guava 32+. + @SuppressWarnings("UnstableApiUsage") @Test public void numeratorOverflowsAndCantBeCancelled() { // Use three Mersenne primes so nothing can cancel, and the numerator will (just) overflow 64