Skip to content

Commit e797a1f

Browse files
icbakercopybara-github
authored andcommitted
Remove MediaLibraryInfo.ASSERTIONS_ENABLED
This is a step towards migrating from our `Assertions.checkXXX` methods to Guava's equivalents in `Preconditions`. PiperOrigin-RevId: 791151418
1 parent 6cb0d7a commit e797a1f

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

libraries/common/src/main/java/androidx/media3/common/MediaLibraryInfo.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package androidx.media3.common;
1717

18-
import androidx.media3.common.util.Assertions;
1918
import androidx.media3.common.util.TraceUtil;
2019
import androidx.media3.common.util.UnstableApi;
2120
import java.util.HashSet;
@@ -49,9 +48,6 @@ public final class MediaLibraryInfo {
4948
// Intentionally hardcoded. Do not derive from other constants (e.g. VERSION) or vice versa.
5049
public static final int VERSION_INT = 1_008_000_3_00;
5150

52-
/** Whether the library was compiled with {@link Assertions} checks enabled. */
53-
public static final boolean ASSERTIONS_ENABLED = true;
54-
5551
/** Whether the library was compiled with {@link TraceUtil} trace enabled. */
5652
public static final boolean TRACE_ENABLED = true;
5753

libraries/common/src/main/java/androidx/media3/common/util/Assertions.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import android.os.Looper;
1919
import android.text.TextUtils;
2020
import androidx.annotation.Nullable;
21-
import androidx.media3.common.MediaLibraryInfo;
2221
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
2322
import org.checkerframework.dataflow.qual.Pure;
2423

@@ -36,7 +35,7 @@ private Assertions() {}
3635
*/
3736
@Pure
3837
public static void checkArgument(boolean expression) {
39-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && !expression) {
38+
if (!expression) {
4039
throw new IllegalArgumentException();
4140
}
4241
}
@@ -51,7 +50,7 @@ public static void checkArgument(boolean expression) {
5150
*/
5251
@Pure
5352
public static void checkArgument(boolean expression, Object errorMessage) {
54-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && !expression) {
53+
if (!expression) {
5554
throw new IllegalArgumentException(String.valueOf(errorMessage));
5655
}
5756
}
@@ -81,7 +80,7 @@ public static int checkIndex(int index, int start, int limit) {
8180
*/
8281
@Pure
8382
public static void checkState(boolean expression) {
84-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && !expression) {
83+
if (!expression) {
8584
throw new IllegalStateException();
8685
}
8786
}
@@ -96,7 +95,7 @@ public static void checkState(boolean expression) {
9695
*/
9796
@Pure
9897
public static void checkState(boolean expression, Object errorMessage) {
99-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && !expression) {
98+
if (!expression) {
10099
throw new IllegalStateException(String.valueOf(errorMessage));
101100
}
102101
}
@@ -113,7 +112,7 @@ public static void checkState(boolean expression, Object errorMessage) {
113112
@EnsuresNonNull({"#1"})
114113
@Pure
115114
public static <T> T checkStateNotNull(@Nullable T reference) {
116-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
115+
if (reference == null) {
117116
throw new IllegalStateException();
118117
}
119118
return reference;
@@ -133,7 +132,7 @@ public static <T> T checkStateNotNull(@Nullable T reference) {
133132
@EnsuresNonNull({"#1"})
134133
@Pure
135134
public static <T> T checkStateNotNull(@Nullable T reference, Object errorMessage) {
136-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
135+
if (reference == null) {
137136
throw new IllegalStateException(String.valueOf(errorMessage));
138137
}
139138
return reference;
@@ -151,7 +150,7 @@ public static <T> T checkStateNotNull(@Nullable T reference, Object errorMessage
151150
@EnsuresNonNull({"#1"})
152151
@Pure
153152
public static <T> T checkNotNull(@Nullable T reference) {
154-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
153+
if (reference == null) {
155154
throw new NullPointerException();
156155
}
157156
return reference;
@@ -171,7 +170,7 @@ public static <T> T checkNotNull(@Nullable T reference) {
171170
@EnsuresNonNull({"#1"})
172171
@Pure
173172
public static <T> T checkNotNull(@Nullable T reference, Object errorMessage) {
174-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
173+
if (reference == null) {
175174
throw new NullPointerException(String.valueOf(errorMessage));
176175
}
177176
return reference;
@@ -188,7 +187,7 @@ public static <T> T checkNotNull(@Nullable T reference, Object errorMessage) {
188187
@EnsuresNonNull({"#1"})
189188
@Pure
190189
public static String checkNotEmpty(@Nullable String string) {
191-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
190+
if (TextUtils.isEmpty(string)) {
192191
throw new IllegalArgumentException();
193192
}
194193
return string;
@@ -207,7 +206,7 @@ public static String checkNotEmpty(@Nullable String string) {
207206
@EnsuresNonNull({"#1"})
208207
@Pure
209208
public static String checkNotEmpty(@Nullable String string, Object errorMessage) {
210-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
209+
if (TextUtils.isEmpty(string)) {
211210
throw new IllegalArgumentException(String.valueOf(errorMessage));
212211
}
213212
return string;
@@ -221,7 +220,7 @@ public static String checkNotEmpty(@Nullable String string, Object errorMessage)
221220
*/
222221
@Pure
223222
public static void checkMainThread() {
224-
if (MediaLibraryInfo.ASSERTIONS_ENABLED && Looper.myLooper() != Looper.getMainLooper()) {
223+
if (Looper.myLooper() != Looper.getMainLooper()) {
225224
throw new IllegalStateException("Not in applications main thread");
226225
}
227226
}

0 commit comments

Comments
 (0)