Remove unnecessary SDK_INT
checks
This commit is contained in:
parent
2b473831c6
commit
973b717914
@ -143,7 +143,7 @@ public final class MainActivity extends Activity {
|
||||
? Assertions.checkNotNull(intent.getData())
|
||||
: Uri.parse(DEFAULT_MEDIA_URI);
|
||||
DrmSessionManager drmSessionManager;
|
||||
if (Util.SDK_INT >= 18 && intent.hasExtra(DRM_SCHEME_EXTRA)) {
|
||||
if (intent.hasExtra(DRM_SCHEME_EXTRA)) {
|
||||
String drmScheme = Assertions.checkNotNull(intent.getStringExtra(DRM_SCHEME_EXTRA));
|
||||
String drmLicenseUrl = Assertions.checkNotNull(intent.getStringExtra(DRM_LICENSE_URL_EXTRA));
|
||||
UUID drmSchemeUuid = Assertions.checkNotNull(Util.getDrmUuid(drmScheme));
|
||||
|
@ -200,13 +200,6 @@ public class DownloadTracker {
|
||||
return;
|
||||
}
|
||||
|
||||
// The content is DRM protected. We need to acquire an offline license.
|
||||
if (Util.SDK_INT < 18) {
|
||||
Toast.makeText(context, R.string.error_drm_unsupported_before_api_18, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
Log.e(TAG, "Downloading DRM protected content is not supported on API versions below 18");
|
||||
return;
|
||||
}
|
||||
// TODO(internal b/163107948): Support cases where DrmInitData are not in the manifest.
|
||||
if (!hasNonNullWidevineSchemaData(format.drmInitData)) {
|
||||
Toast.makeText(context, R.string.download_start_error_offline_license, Toast.LENGTH_LONG)
|
||||
|
@ -361,11 +361,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||
|
||||
MediaItem.DrmConfiguration drmConfiguration = mediaItem.localConfiguration.drmConfiguration;
|
||||
if (drmConfiguration != null) {
|
||||
if (Build.VERSION.SDK_INT < 18) {
|
||||
showToast(R.string.error_drm_unsupported_before_api_18);
|
||||
finish();
|
||||
return Collections.emptyList();
|
||||
} else if (!FrameworkMediaDrm.isCryptoSchemeSupported(drmConfiguration.scheme)) {
|
||||
if (!FrameworkMediaDrm.isCryptoSchemeSupported(drmConfiguration.scheme)) {
|
||||
showToast(R.string.error_drm_unsupported_scheme);
|
||||
finish();
|
||||
return Collections.emptyList();
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
<string name="error_generic">Playback failed</string>
|
||||
|
||||
<string name="error_drm_unsupported_before_api_18">DRM content not supported on API levels below 18</string>
|
||||
|
||||
<string name="error_drm_unsupported_scheme">This device does not support the required DRM scheme</string>
|
||||
|
||||
<string name="error_no_decoder">This device does not provide a decoder for <xliff:g id="mime_type">%1$s</xliff:g></string>
|
||||
|
@ -29,7 +29,6 @@ import android.util.Pair;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
import androidx.media3.common.util.BundleCollectionUtil;
|
||||
import androidx.media3.common.util.BundleUtil;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.common.util.Util;
|
||||
import com.google.common.base.Function;
|
||||
@ -1453,8 +1452,8 @@ public abstract class Timeline implements Bundleable {
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
BundleUtil.putBinder(bundle, FIELD_WINDOWS, new BundleListRetriever(windowBundles));
|
||||
BundleUtil.putBinder(bundle, FIELD_PERIODS, new BundleListRetriever(periodBundles));
|
||||
bundle.putBinder(FIELD_WINDOWS, new BundleListRetriever(windowBundles));
|
||||
bundle.putBinder(FIELD_PERIODS, new BundleListRetriever(periodBundles));
|
||||
bundle.putIntArray(FIELD_SHUFFLED_WINDOW_INDICES, shuffledWindowIndices);
|
||||
return bundle;
|
||||
}
|
||||
@ -1503,9 +1502,9 @@ public abstract class Timeline implements Bundleable {
|
||||
@UnstableApi
|
||||
public static Timeline fromBundle(Bundle bundle) {
|
||||
ImmutableList<Window> windows =
|
||||
fromBundleListRetriever(Window::fromBundle, BundleUtil.getBinder(bundle, FIELD_WINDOWS));
|
||||
fromBundleListRetriever(Window::fromBundle, bundle.getBinder(FIELD_WINDOWS));
|
||||
ImmutableList<Period> periods =
|
||||
fromBundleListRetriever(Period::fromBundle, BundleUtil.getBinder(bundle, FIELD_PERIODS));
|
||||
fromBundleListRetriever(Period::fromBundle, bundle.getBinder(FIELD_PERIODS));
|
||||
@Nullable int[] shuffledWindowIndices = bundle.getIntArray(FIELD_SHUFFLED_WINDOW_INDICES);
|
||||
return new RemotableTimeline(
|
||||
windows,
|
||||
|
@ -623,7 +623,7 @@ public class TrackSelectionParameters implements Bundleable {
|
||||
* Sets the preferred language and role flags for text tracks based on the accessibility
|
||||
* settings of {@link CaptioningManager}.
|
||||
*
|
||||
* <p>Does nothing for API levels < 19 or when the {@link CaptioningManager} is disabled.
|
||||
* <p>Does nothing when the {@link CaptioningManager} is disabled.
|
||||
*
|
||||
* @param context A {@link Context}.
|
||||
* @return This builder.
|
||||
@ -631,9 +631,7 @@ public class TrackSelectionParameters implements Bundleable {
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
|
||||
Context context) {
|
||||
if (Util.SDK_INT >= 19) {
|
||||
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(context);
|
||||
}
|
||||
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(context);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package androidx.media3.common.util;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import androidx.annotation.Nullable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/** Utilities for {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public final class BundleUtil {
|
||||
|
||||
private static final String TAG = "BundleUtil";
|
||||
|
||||
@Nullable private static Method getIBinderMethod;
|
||||
@Nullable private static Method putIBinderMethod;
|
||||
|
||||
/**
|
||||
* Gets an {@link IBinder} inside a {@link Bundle} for all Android versions.
|
||||
*
|
||||
* @param bundle The bundle to get the {@link IBinder}.
|
||||
* @param key The key to use while getting the {@link IBinder}.
|
||||
* @return The {@link IBinder} that was obtained.
|
||||
*/
|
||||
@Nullable
|
||||
public static IBinder getBinder(Bundle bundle, @Nullable String key) {
|
||||
if (Util.SDK_INT >= 18) {
|
||||
return bundle.getBinder(key);
|
||||
} else {
|
||||
return getBinderByReflection(bundle, key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an {@link IBinder} inside a {@link Bundle} for all Android versions.
|
||||
*
|
||||
* @param bundle The bundle to insert the {@link IBinder}.
|
||||
* @param key The key to use while putting the {@link IBinder}.
|
||||
* @param binder The {@link IBinder} to put.
|
||||
*/
|
||||
public static void putBinder(Bundle bundle, @Nullable String key, @Nullable IBinder binder) {
|
||||
if (Util.SDK_INT >= 18) {
|
||||
bundle.putBinder(key, binder);
|
||||
} else {
|
||||
putBinderByReflection(bundle, key, binder);
|
||||
}
|
||||
}
|
||||
|
||||
// Method.invoke may take null "key".
|
||||
@SuppressWarnings("nullness:argument")
|
||||
@Nullable
|
||||
private static IBinder getBinderByReflection(Bundle bundle, @Nullable String key) {
|
||||
@Nullable Method getIBinder = getIBinderMethod;
|
||||
if (getIBinder == null) {
|
||||
try {
|
||||
getIBinderMethod = Bundle.class.getMethod("getIBinder", String.class);
|
||||
getIBinderMethod.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i(TAG, "Failed to retrieve getIBinder method", e);
|
||||
return null;
|
||||
}
|
||||
getIBinder = getIBinderMethod;
|
||||
}
|
||||
|
||||
try {
|
||||
return (IBinder) getIBinder.invoke(bundle, key);
|
||||
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
|
||||
Log.i(TAG, "Failed to invoke getIBinder via reflection", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Method.invoke may take null "key" and "binder".
|
||||
@SuppressWarnings("nullness:argument")
|
||||
private static void putBinderByReflection(
|
||||
Bundle bundle, @Nullable String key, @Nullable IBinder binder) {
|
||||
@Nullable Method putIBinder = putIBinderMethod;
|
||||
if (putIBinder == null) {
|
||||
try {
|
||||
putIBinderMethod = Bundle.class.getMethod("putIBinder", String.class, IBinder.class);
|
||||
putIBinderMethod.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i(TAG, "Failed to retrieve putIBinder method", e);
|
||||
return;
|
||||
}
|
||||
putIBinder = putIBinderMethod;
|
||||
}
|
||||
|
||||
try {
|
||||
putIBinder.invoke(bundle, key, binder);
|
||||
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
|
||||
Log.i(TAG, "Failed to invoke putIBinder via reflection", e);
|
||||
}
|
||||
}
|
||||
|
||||
private BundleUtil() {}
|
||||
}
|
@ -150,10 +150,7 @@ public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableL
|
||||
if (context != null) {
|
||||
EGL14.eglDestroyContext(display, context);
|
||||
}
|
||||
// EGL14.eglReleaseThread could crash before Android K (see [internal: b/11327779]).
|
||||
if (Util.SDK_INT >= 19) {
|
||||
EGL14.eglReleaseThread();
|
||||
}
|
||||
EGL14.eglReleaseThread();
|
||||
if (display != null && !display.equals(EGL14.EGL_NO_DISPLAY)) {
|
||||
// Android is unusual in that it uses a reference-counted EGLDisplay. So for
|
||||
// every eglInitialize() we need an eglTerminate().
|
||||
|
@ -192,7 +192,7 @@ public final class GlUtil {
|
||||
* EGLContext)}.
|
||||
*/
|
||||
public static boolean isSurfacelessContextExtensionSupported() {
|
||||
return Util.SDK_INT >= 17 && Api17.isExtensionSupported(EXTENSION_SURFACELESS_CONTEXT);
|
||||
return Api17.isExtensionSupported(EXTENSION_SURFACELESS_CONTEXT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,9 +202,6 @@ public final class GlUtil {
|
||||
* for HDR input.
|
||||
*/
|
||||
public static boolean isYuvTargetExtensionSupported() {
|
||||
if (Util.SDK_INT < 17) {
|
||||
return false;
|
||||
}
|
||||
@Nullable String glExtensions;
|
||||
if (Util.areEqual(Api17.getCurrentContext(), EGL14.EGL_NO_CONTEXT)) {
|
||||
// Create a placeholder context and make it current to allow calling GLES20.glGetString().
|
||||
@ -226,7 +223,7 @@ public final class GlUtil {
|
||||
|
||||
/** Returns whether {@link #EXTENSION_COLORSPACE_BT2020_PQ} is supported. */
|
||||
public static boolean isBt2020PqExtensionSupported() {
|
||||
return Util.SDK_INT >= 17 && Api17.isExtensionSupported(EXTENSION_COLORSPACE_BT2020_PQ);
|
||||
return Api17.isExtensionSupported(EXTENSION_COLORSPACE_BT2020_PQ);
|
||||
}
|
||||
|
||||
/** Returns an initialized default {@link EGLDisplay}. */
|
||||
@ -396,21 +393,16 @@ public final class GlUtil {
|
||||
* <p>The {@code syncObject} must not be used after deletion.
|
||||
*/
|
||||
public static void deleteSyncObject(long syncObject) throws GlException {
|
||||
// If the sync object is set, we must be running API 18 or later.
|
||||
if (Util.SDK_INT >= 18) {
|
||||
Api18.deleteSyncObject(syncObject);
|
||||
}
|
||||
Api18.deleteSyncObject(syncObject);
|
||||
}
|
||||
|
||||
/** Releases the GL sync object if set, suppressing any error. */
|
||||
public static void deleteSyncObjectQuietly(long syncObject) {
|
||||
if (Util.SDK_INT >= 18) {
|
||||
try {
|
||||
// glDeleteSync ignores a 0-valued sync object.
|
||||
Api18.deleteSyncObject(syncObject);
|
||||
} catch (GlException unused) {
|
||||
// Suppress exceptions.
|
||||
}
|
||||
try {
|
||||
// glDeleteSync ignores a 0-valued sync object.
|
||||
Api18.deleteSyncObject(syncObject);
|
||||
} catch (GlException unused) {
|
||||
// Suppress exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,7 +606,6 @@ public final class GlUtil {
|
||||
// TODO(b/227624622): Implement a pixel test that confirms 16f has less posterization.
|
||||
// TODO - b/309459038: Consider renaming the method, as the created textures are uninitialized.
|
||||
if (useHighPrecisionColorComponents) {
|
||||
checkState(Util.SDK_INT >= 18, "GLES30 extensions are not supported below API 18.");
|
||||
return createTextureUninitialized(width, height, GLES30.GL_RGBA16F, GLES30.GL_HALF_FLOAT);
|
||||
}
|
||||
return createTextureUninitialized(width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE);
|
||||
|
@ -32,7 +32,7 @@ public final class TraceUtil {
|
||||
* Unicode code units long.
|
||||
*/
|
||||
public static void beginSection(String sectionName) {
|
||||
if (MediaLibraryInfo.TRACE_ENABLED && Util.SDK_INT >= 18) {
|
||||
if (MediaLibraryInfo.TRACE_ENABLED) {
|
||||
beginSectionV18(sectionName);
|
||||
}
|
||||
}
|
||||
@ -43,7 +43,7 @@ public final class TraceUtil {
|
||||
* @see android.os.Trace#endSection()
|
||||
*/
|
||||
public static void endSection() {
|
||||
if (MediaLibraryInfo.TRACE_ENABLED && Util.SDK_INT >= 18) {
|
||||
if (MediaLibraryInfo.TRACE_ENABLED) {
|
||||
endSectionV18();
|
||||
}
|
||||
}
|
||||
|
@ -3134,15 +3134,12 @@ public final class Util {
|
||||
@UnstableApi
|
||||
public static Point getCurrentDisplayModeSize(Context context) {
|
||||
@Nullable Display defaultDisplay = null;
|
||||
if (SDK_INT >= 17) {
|
||||
@Nullable
|
||||
DisplayManager displayManager =
|
||||
(DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
||||
// We don't expect displayManager to ever be null, so this check is just precautionary.
|
||||
// Consider removing it when the library minSdkVersion is increased to 17 or higher.
|
||||
if (displayManager != null) {
|
||||
defaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
|
||||
}
|
||||
@Nullable
|
||||
DisplayManager displayManager =
|
||||
(DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
||||
// We don't expect displayManager to ever be null, so this check is just precautionary.
|
||||
if (displayManager != null) {
|
||||
defaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
|
||||
}
|
||||
if (defaultDisplay == null) {
|
||||
WindowManager windowManager =
|
||||
@ -3214,10 +3211,8 @@ public final class Util {
|
||||
Point displaySize = new Point();
|
||||
if (SDK_INT >= 23) {
|
||||
getDisplaySizeV23(display, displaySize);
|
||||
} else if (SDK_INT >= 17) {
|
||||
getDisplaySizeV17(display, displaySize);
|
||||
} else {
|
||||
getDisplaySizeV16(display, displaySize);
|
||||
getDisplaySizeV17(display, displaySize);
|
||||
}
|
||||
return displaySize;
|
||||
}
|
||||
@ -3708,10 +3703,6 @@ public final class Util {
|
||||
display.getRealSize(outSize);
|
||||
}
|
||||
|
||||
private static void getDisplaySizeV16(Display display, Point outSize) {
|
||||
display.getSize(outSize);
|
||||
}
|
||||
|
||||
private static String[] getSystemLocales() {
|
||||
Configuration config = Resources.getSystem().getConfiguration();
|
||||
return SDK_INT >= 24
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package androidx.media3.common.util;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Unit tests for {@link BundleUtil}. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BundleUtilTest {
|
||||
|
||||
@Test
|
||||
public void getPutBinder() {
|
||||
String key = "key";
|
||||
IBinder binder = new Binder();
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
BundleUtil.putBinder(bundle, key, binder);
|
||||
IBinder returnedBinder = BundleUtil.getBinder(bundle, key);
|
||||
|
||||
assertThat(returnedBinder).isSameInstanceAs(binder);
|
||||
}
|
||||
}
|
@ -822,7 +822,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
|
||||
*/
|
||||
private static void maybeTerminateInputStream(
|
||||
@Nullable HttpURLConnection connection, long bytesRemaining) {
|
||||
if (connection == null || Util.SDK_INT < 19 || Util.SDK_INT > 20) {
|
||||
if (connection == null || Util.SDK_INT > 20) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ import static androidx.media3.common.util.Assertions.checkState;
|
||||
import static androidx.media3.common.util.Util.castNonNull;
|
||||
import static java.lang.Math.min;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
@ -347,19 +346,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
return cachedContent;
|
||||
}
|
||||
|
||||
@SuppressLint("GetInstance") // Suppress warning about specifying "BC" as an explicit provider.
|
||||
private static Cipher getCipher() throws NoSuchPaddingException, NoSuchAlgorithmException {
|
||||
// Workaround for https://issuetracker.google.com/issues/36976726
|
||||
if (Util.SDK_INT == 18) {
|
||||
try {
|
||||
return Cipher.getInstance("AES/CBC/PKCS5PADDING", "BC");
|
||||
} catch (Throwable ignored) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
return Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an id which isn't used in the given array. If the maximum id in the array is smaller
|
||||
* than {@link java.lang.Integer#MAX_VALUE} it just returns the next bigger integer. Otherwise it
|
||||
@ -526,7 +512,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
if (secretKey != null) {
|
||||
Assertions.checkArgument(secretKey.length == 16);
|
||||
try {
|
||||
cipher = getCipher();
|
||||
cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
secretKeySpec = new SecretKeySpec(secretKey, "AES");
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||
throw new IllegalStateException(e); // Should never happen.
|
||||
|
@ -24,7 +24,6 @@ import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888Bitma
|
||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888;
|
||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.graphics.Bitmap;
|
||||
@ -103,8 +102,6 @@ public class EffectPlaybackTest {
|
||||
|
||||
@Test
|
||||
public void exoplayerEffectsPreviewTest_ensuresFirstFrameRendered() throws Exception {
|
||||
assumeTrue(Util.SDK_INT >= 18);
|
||||
|
||||
String testId =
|
||||
Util.formatInvariant(
|
||||
"exoplayerEffectsPreviewTest_withPlayWhenReady[%b]_ensuresFirstFrameRendered",
|
||||
|
@ -374,11 +374,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
// audio recording or speech recognition'.
|
||||
// Assistant is considered as both recording and notifying developer
|
||||
case C.USAGE_ASSISTANT:
|
||||
if (Util.SDK_INT >= 19) {
|
||||
return AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE;
|
||||
} else {
|
||||
return AUDIOFOCUS_GAIN_TRANSIENT;
|
||||
}
|
||||
return AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE;
|
||||
|
||||
// Special usages:
|
||||
case C.USAGE_ASSISTANCE_ACCESSIBILITY:
|
||||
|
@ -754,10 +754,10 @@ public final class MediaMetricsListener
|
||||
return new ErrorInfo(errorCode, subErrorCode);
|
||||
} else if (Util.SDK_INT >= 23 && cause instanceof MediaDrmResetException) {
|
||||
return new ErrorInfo(PlaybackErrorEvent.ERROR_DRM_SYSTEM_ERROR, /* subErrorCode= */ 0);
|
||||
} else if (Util.SDK_INT >= 18 && cause instanceof NotProvisionedException) {
|
||||
} else if (cause instanceof NotProvisionedException) {
|
||||
return new ErrorInfo(
|
||||
PlaybackErrorEvent.ERROR_DRM_PROVISIONING_FAILED, /* subErrorCode= */ 0);
|
||||
} else if (Util.SDK_INT >= 18 && cause instanceof DeniedByServerException) {
|
||||
} else if (cause instanceof DeniedByServerException) {
|
||||
return new ErrorInfo(PlaybackErrorEvent.ERROR_DRM_DEVICE_REVOKED, /* subErrorCode= */ 0);
|
||||
} else if (cause instanceof UnsupportedDrmException) {
|
||||
return new ErrorInfo(
|
||||
@ -810,7 +810,7 @@ public final class MediaMetricsListener
|
||||
} else if (cause instanceof AudioSink.WriteException) {
|
||||
int subErrorCode = ((AudioSink.WriteException) cause).errorCode;
|
||||
return new ErrorInfo(PlaybackErrorEvent.ERROR_AUDIO_TRACK_WRITE_FAILED, subErrorCode);
|
||||
} else if (Util.SDK_INT >= 16 && cause instanceof MediaCodec.CryptoException) {
|
||||
} else if (cause instanceof MediaCodec.CryptoException) {
|
||||
int subErrorCode = ((MediaCodec.CryptoException) cause).getErrorCode();
|
||||
int errorCode = getDrmErrorCode(subErrorCode);
|
||||
return new ErrorInfo(errorCode, subErrorCode);
|
||||
|
@ -354,8 +354,7 @@ public final class AudioCapabilities {
|
||||
}
|
||||
|
||||
private static boolean deviceMaySetExternalSurroundSoundGlobalSetting() {
|
||||
return Util.SDK_INT >= 17
|
||||
&& ("Amazon".equals(Util.MANUFACTURER) || "Xiaomi".equals(Util.MANUFACTURER));
|
||||
return "Amazon".equals(Util.MANUFACTURER) || "Xiaomi".equals(Util.MANUFACTURER);
|
||||
}
|
||||
|
||||
private static int getChannelConfigForPassthrough(int channelCount) {
|
||||
|
@ -24,7 +24,6 @@ import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.util.Util;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -105,16 +104,11 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* Creates a new audio timestamp poller.
|
||||
*
|
||||
* @param audioTrack The audio track that will provide timestamps, if the platform supports it.
|
||||
* @param audioTrack The audio track that will provide timestamps.
|
||||
*/
|
||||
public AudioTimestampPoller(AudioTrack audioTrack) {
|
||||
if (Util.SDK_INT >= 19) {
|
||||
audioTimestamp = new AudioTimestampV19(audioTrack);
|
||||
reset();
|
||||
} else {
|
||||
audioTimestamp = null;
|
||||
updateState(STATE_NO_TIMESTAMP);
|
||||
}
|
||||
audioTimestamp = new AudioTimestampV19(audioTrack);
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,12 +224,10 @@ import java.lang.reflect.Method;
|
||||
*/
|
||||
public AudioTrackPositionTracker(Listener listener) {
|
||||
this.listener = checkNotNull(listener);
|
||||
if (Util.SDK_INT >= 18) {
|
||||
try {
|
||||
getLatencyMethod = AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// There's no guarantee this method exists. Do nothing.
|
||||
}
|
||||
try {
|
||||
getLatencyMethod = AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// There's no guarantee this method exists. Do nothing.
|
||||
}
|
||||
playheadOffsets = new long[MAX_PLAYHEAD_OFFSET_COUNT];
|
||||
clock = Clock.DEFAULT;
|
||||
|
@ -657,11 +657,8 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
|
||||
}
|
||||
|
||||
private static boolean acquisitionFailedIndicatingResourceShortage(DrmSession session) {
|
||||
// ResourceBusyException is only available at API 19, so on earlier versions we
|
||||
// assume any error indicates resource shortage (ensuring we retry).
|
||||
return session.getState() == DrmSession.STATE_ERROR
|
||||
&& (Util.SDK_INT < 19
|
||||
|| checkNotNull(session.getError()).getCause() instanceof ResourceBusyException);
|
||||
&& checkNotNull(session.getError()).getCause() instanceof ResourceBusyException;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +75,7 @@ public final class DefaultDrmSessionManagerProvider implements DrmSessionManager
|
||||
checkNotNull(mediaItem.localConfiguration);
|
||||
@Nullable
|
||||
MediaItem.DrmConfiguration drmConfiguration = mediaItem.localConfiguration.drmConfiguration;
|
||||
if (drmConfiguration == null || Util.SDK_INT < 18) {
|
||||
if (drmConfiguration == null) {
|
||||
return DrmSessionManager.DRM_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -80,13 +80,13 @@ public final class DrmUtil {
|
||||
return Api21.mediaDrmStateExceptionToErrorCode(exception);
|
||||
} else if (Util.SDK_INT >= 23 && Api23.isMediaDrmResetException(exception)) {
|
||||
return PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR;
|
||||
} else if (Util.SDK_INT >= 18 && Api18.isNotProvisionedException(exception)) {
|
||||
} else if (Api18.isNotProvisionedException(exception)) {
|
||||
return PlaybackException.ERROR_CODE_DRM_PROVISIONING_FAILED;
|
||||
} else if (Util.SDK_INT >= 18 && Api18.isDeniedByServerException(exception)) {
|
||||
} else if (Api18.isDeniedByServerException(exception)) {
|
||||
return PlaybackException.ERROR_CODE_DRM_DEVICE_REVOKED;
|
||||
} else if (exception instanceof UnsupportedDrmException) {
|
||||
return PlaybackException.ERROR_CODE_DRM_SCHEME_UNSUPPORTED;
|
||||
} else if (Util.SDK_INT >= 18 && Api18.isMissingSchemeDataException(exception)) {
|
||||
} else if (Api18.isMissingSchemeDataException(exception)) {
|
||||
return PlaybackException.ERROR_CODE_DRM_CONTENT_ERROR;
|
||||
} else if (exception instanceof KeysExpiredException) {
|
||||
return PlaybackException.ERROR_CODE_DRM_LICENSE_EXPIRED;
|
||||
|
@ -695,7 +695,7 @@ public final class MediaCodecInfo {
|
||||
}
|
||||
|
||||
private static boolean isAdaptive(CodecCapabilities capabilities) {
|
||||
return Util.SDK_INT >= 19 && isAdaptiveV19(capabilities);
|
||||
return isAdaptiveV19(capabilities);
|
||||
}
|
||||
|
||||
@RequiresApi(19)
|
||||
|
@ -1217,8 +1217,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
|
||||
codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName);
|
||||
codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecName);
|
||||
codecNeedsMonoChannelCountWorkaround =
|
||||
codecNeedsMonoChannelCountWorkaround(codecName, checkNotNull(codecInputFormat));
|
||||
codecNeedsMonoChannelCountWorkaround = false;
|
||||
codecNeedsEosPropagation =
|
||||
codecNeedsEosPropagationWorkaround(codecInfo) || getCodecNeedsEosPropagation();
|
||||
if (checkNotNull(codec).needsReconfiguration()) {
|
||||
@ -2499,12 +2498,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
* @return True if the decoder is known to fail when flushed.
|
||||
*/
|
||||
private static boolean codecNeedsFlushWorkaround(String name) {
|
||||
return Util.SDK_INT < 18
|
||||
|| (Util.SDK_INT == 18
|
||||
&& ("OMX.SEC.avc.dec".equals(name) || "OMX.SEC.avc.dec.secure".equals(name)))
|
||||
|| (Util.SDK_INT == 19
|
||||
return Util.SDK_INT == 19
|
||||
&& Util.MODEL.startsWith("SM-G800")
|
||||
&& ("OMX.Exynos.avc.dec".equals(name) || "OMX.Exynos.avc.dec.secure".equals(name)));
|
||||
&& ("OMX.Exynos.avc.dec".equals(name) || "OMX.Exynos.avc.dec.secure".equals(name));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2589,7 +2585,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
private static boolean codecNeedsEosPropagationWorkaround(MediaCodecInfo codecInfo) {
|
||||
String name = codecInfo.name;
|
||||
return (Util.SDK_INT <= 25 && "OMX.rk.video_decoder.avc".equals(name))
|
||||
|| (Util.SDK_INT <= 17 && "OMX.allwinner.video.decoder.avc".equals(name))
|
||||
|| (Util.SDK_INT <= 29
|
||||
&& ("OMX.broadcom.video_decoder.tunnel".equals(name)
|
||||
|| "OMX.broadcom.video_decoder.tunnel.secure".equals(name)
|
||||
@ -2615,7 +2610,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
*/
|
||||
private static boolean codecNeedsEosFlushWorkaround(String name) {
|
||||
return (Util.SDK_INT <= 23 && "OMX.google.vorbis.decoder".equals(name))
|
||||
|| (Util.SDK_INT <= 19
|
||||
|| (Util.SDK_INT == 19
|
||||
&& ("hb2000".equals(Util.DEVICE) || "stvm8".equals(Util.DEVICE))
|
||||
&& ("OMX.amlogic.avc.decoder.awesome".equals(name)
|
||||
|| "OMX.amlogic.avc.decoder.awesome.secure".equals(name)));
|
||||
@ -2654,26 +2649,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||
return Util.SDK_INT == 21 && "OMX.google.aac.decoder".equals(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the decoder is known to set the number of audio channels in the output {@link
|
||||
* Format} to 2 for the given input {@link Format}, whilst only actually outputting a single
|
||||
* channel.
|
||||
*
|
||||
* <p>If true is returned then we explicitly override the number of channels in the output {@link
|
||||
* Format}, setting it to 1.
|
||||
*
|
||||
* @param name The decoder name.
|
||||
* @param format The input {@link Format}.
|
||||
* @return True if the decoder is known to set the number of audio channels in the output {@link
|
||||
* Format} to 2 for the given input {@link Format}, whilst only actually outputting a single
|
||||
* channel. False otherwise.
|
||||
*/
|
||||
private static boolean codecNeedsMonoChannelCountWorkaround(String name, Format format) {
|
||||
return Util.SDK_INT <= 18
|
||||
&& format.channelCount == 1
|
||||
&& "OMX.MTK.AUDIO.DECODER.MP3".equals(name);
|
||||
}
|
||||
|
||||
private static final class OutputStreamInfo {
|
||||
|
||||
public static final OutputStreamInfo UNSET =
|
||||
|
@ -543,44 +543,6 @@ public final class MediaCodecUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Work around https://github.com/google/ExoPlayer/issues/1528 and
|
||||
// https://github.com/google/ExoPlayer/issues/3171.
|
||||
if (Util.SDK_INT < 18
|
||||
&& "OMX.MTK.AUDIO.DECODER.AAC".equals(name)
|
||||
&& ("a70".equals(Util.DEVICE)
|
||||
|| ("Xiaomi".equals(Util.MANUFACTURER) && Util.DEVICE.startsWith("HM")))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Work around an issue where querying/creating a particular MP3 decoder on some devices on
|
||||
// platform API version 16 fails.
|
||||
if (Util.SDK_INT == 16
|
||||
&& "OMX.qcom.audio.decoder.mp3".equals(name)
|
||||
&& ("dlxu".equals(Util.DEVICE) // HTC Butterfly
|
||||
|| "protou".equals(Util.DEVICE) // HTC Desire X
|
||||
|| "ville".equals(Util.DEVICE) // HTC One S
|
||||
|| "villeplus".equals(Util.DEVICE)
|
||||
|| "villec2".equals(Util.DEVICE)
|
||||
|| Util.DEVICE.startsWith("gee") // LGE Optimus G
|
||||
|| "C6602".equals(Util.DEVICE) // Sony Xperia Z
|
||||
|| "C6603".equals(Util.DEVICE)
|
||||
|| "C6606".equals(Util.DEVICE)
|
||||
|| "C6616".equals(Util.DEVICE)
|
||||
|| "L36h".equals(Util.DEVICE)
|
||||
|| "SO-02E".equals(Util.DEVICE))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Work around an issue where large timestamps are not propagated correctly.
|
||||
if (Util.SDK_INT == 16
|
||||
&& "OMX.qcom.audio.decoder.aac".equals(name)
|
||||
&& ("C1504".equals(Util.DEVICE) // Sony Xperia E
|
||||
|| "C1505".equals(Util.DEVICE)
|
||||
|| "C1604".equals(Util.DEVICE) // Sony Xperia E dual
|
||||
|| "C1605".equals(Util.DEVICE))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Work around https://github.com/google/ExoPlayer/issues/3249.
|
||||
if (Util.SDK_INT < 24
|
||||
&& ("OMX.SEC.aac.dec".equals(name) || "OMX.Exynos.AAC.Decoder".equals(name))
|
||||
@ -598,7 +560,7 @@ public final class MediaCodecUtil {
|
||||
|
||||
// Work around https://github.com/google/ExoPlayer/issues/548.
|
||||
// VP8 decoder on Samsung Galaxy S3/S4/S4 Mini/Tab 3/Note 2 does not render video.
|
||||
if (Util.SDK_INT <= 19
|
||||
if (Util.SDK_INT == 19
|
||||
&& "OMX.SEC.vp8.dec".equals(name)
|
||||
&& "samsung".equals(Util.MANUFACTURER)
|
||||
&& (Util.DEVICE.startsWith("d2")
|
||||
@ -610,7 +572,7 @@ public final class MediaCodecUtil {
|
||||
}
|
||||
|
||||
// VP8 decoder on Samsung Galaxy S4 cannot be queried.
|
||||
if (Util.SDK_INT <= 19
|
||||
if (Util.SDK_INT == 19
|
||||
&& Util.DEVICE.startsWith("jflte")
|
||||
&& "OMX.qcom.video.decoder.vp8".equals(name)) {
|
||||
return false;
|
||||
|
@ -172,7 +172,7 @@ public final class VideoFrameReleaseHelper {
|
||||
* @param surface The new {@link Surface}, or {@code null} if the renderer does not have one.
|
||||
*/
|
||||
public void onSurfaceChanged(@Nullable Surface surface) {
|
||||
if (Util.SDK_INT >= 17 && Api17.isPlaceholderSurface(surface)) {
|
||||
if (Api17.isPlaceholderSurface(surface)) {
|
||||
// We don't care about dummy surfaces for release timing, since they're not visible.
|
||||
surface = null;
|
||||
}
|
||||
@ -422,9 +422,7 @@ public final class VideoFrameReleaseHelper {
|
||||
@Nullable DisplayHelper displayHelper = null;
|
||||
if (context != null) {
|
||||
context = context.getApplicationContext();
|
||||
if (Util.SDK_INT >= 17) {
|
||||
displayHelper = DisplayHelperV17.maybeBuildNewInstance(context);
|
||||
}
|
||||
displayHelper = DisplayHelperV17.maybeBuildNewInstance(context);
|
||||
if (displayHelper == null) {
|
||||
displayHelper = DisplayHelperV16.maybeBuildNewInstance(context);
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import androidx.media3.common.C;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.exoplayer.video.VideoFrameMetadataListener;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
@ -103,14 +102,11 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
|
||||
// Configure sensors and touch.
|
||||
sensorManager =
|
||||
(SensorManager) Assertions.checkNotNull(context.getSystemService(Context.SENSOR_SERVICE));
|
||||
@Nullable Sensor orientationSensor = null;
|
||||
if (Util.SDK_INT >= 18) {
|
||||
// TYPE_GAME_ROTATION_VECTOR is the easiest sensor since it handles all the complex math for
|
||||
// fusion. It's used instead of TYPE_ROTATION_VECTOR since the latter uses the magnetometer on
|
||||
// devices. When used indoors, the magnetometer can take some time to settle depending on the
|
||||
// device and amount of metal in the environment.
|
||||
orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
|
||||
}
|
||||
// TYPE_GAME_ROTATION_VECTOR is the easiest sensor since it handles all the complex math for
|
||||
// fusion. It's used instead of TYPE_ROTATION_VECTOR since the latter uses the magnetometer on
|
||||
// devices. When used indoors, the magnetometer can take some time to settle depending on the
|
||||
// device and amount of metal in the environment.
|
||||
@Nullable Sensor orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
|
||||
if (orientationSensor == null) {
|
||||
orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import androidx.core.app.BundleCompat;
|
||||
import androidx.media3.common.Bundleable;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.util.BundleCollectionUtil;
|
||||
import androidx.media3.common.util.BundleUtil;
|
||||
import androidx.media3.common.util.Util;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
@ -139,7 +138,7 @@ import java.util.List;
|
||||
*/
|
||||
public Bundle toBundleInProcess() {
|
||||
Bundle bundle = new Bundle();
|
||||
BundleUtil.putBinder(bundle, FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
||||
bundle.putBinder(FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@ -152,7 +151,7 @@ import java.util.List;
|
||||
|
||||
/** Restores a {@code ConnectionState} from a {@link Bundle}. */
|
||||
public static ConnectionState fromBundle(Bundle bundle) {
|
||||
@Nullable IBinder inProcessBinder = BundleUtil.getBinder(bundle, FIELD_IN_PROCESS_BINDER);
|
||||
@Nullable IBinder inProcessBinder = bundle.getBinder(FIELD_IN_PROCESS_BINDER);
|
||||
if (inProcessBinder instanceof InProcessBinder) {
|
||||
return ((InProcessBinder) inProcessBinder).getConnectionState();
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ import androidx.media3.common.Tracks;
|
||||
import androidx.media3.common.VideoSize;
|
||||
import androidx.media3.common.text.CueGroup;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
import androidx.media3.common.util.BundleUtil;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.common.util.Util;
|
||||
import com.google.common.base.Objects;
|
||||
@ -901,7 +900,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
*/
|
||||
public Bundle toBundleInProcess() {
|
||||
Bundle bundle = new Bundle();
|
||||
BundleUtil.putBinder(bundle, FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
||||
bundle.putBinder(FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@ -1025,7 +1024,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
|
||||
/** Restores a {@code PlayerInfo} from a {@link Bundle}. */
|
||||
public static PlayerInfo fromBundle(Bundle bundle) {
|
||||
@Nullable IBinder inProcessBinder = BundleUtil.getBinder(bundle, FIELD_IN_PROCESS_BINDER);
|
||||
@Nullable IBinder inProcessBinder = bundle.getBinder(FIELD_IN_PROCESS_BINDER);
|
||||
if (inProcessBinder instanceof InProcessBinder) {
|
||||
return ((InProcessBinder) inProcessBinder).getPlayerInfo();
|
||||
}
|
||||
|
@ -106,22 +106,19 @@ import java.util.List;
|
||||
|
||||
@SuppressWarnings("ResourceType")
|
||||
public static boolean isL1WidevineAvailable(String mimeType) {
|
||||
if (Util.SDK_INT >= 18) {
|
||||
try {
|
||||
// Force L3 if secure decoder is not available.
|
||||
if (MediaCodecUtil.getDecoderInfo(mimeType, /* secure= */ true, /* tunneling= */ false)
|
||||
== null) {
|
||||
return false;
|
||||
}
|
||||
MediaDrm mediaDrm = MediaDrmBuilder.build();
|
||||
String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
|
||||
mediaDrm.release();
|
||||
return WIDEVINE_SECURITY_LEVEL_1.equals(securityProperty);
|
||||
} catch (MediaCodecUtil.DecoderQueryException e) {
|
||||
throw new IllegalStateException(e);
|
||||
try {
|
||||
// Force L3 if secure decoder is not available.
|
||||
if (MediaCodecUtil.getDecoderInfo(mimeType, /* secure= */ true, /* tunneling= */ false)
|
||||
== null) {
|
||||
return false;
|
||||
}
|
||||
MediaDrm mediaDrm = MediaDrmBuilder.build();
|
||||
String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
|
||||
mediaDrm.release();
|
||||
return WIDEVINE_SECURITY_LEVEL_1.equals(securityProperty);
|
||||
} catch (MediaCodecUtil.DecoderQueryException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public DashTestRunner(@Size(max = 23) String tag, HostActivity activity) {
|
||||
|
@ -135,8 +135,7 @@ public class EnumerateDecodersTest {
|
||||
appendAudioCapabilities(codecCapabilities.getAudioCapabilities(), result);
|
||||
}
|
||||
}
|
||||
if (Util.SDK_INT >= 19
|
||||
&& isVideo
|
||||
if (isVideo
|
||||
&& codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback)) {
|
||||
result.append(", FEATURE_AdaptivePlayback");
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import static androidx.media3.common.C.WIDEVINE_UUID;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.media.MediaDrm;
|
||||
import androidx.media3.common.util.Util;
|
||||
|
||||
/** Utility methods for GTS tests. */
|
||||
public final class GtsTestUtil {
|
||||
@ -30,10 +29,6 @@ public final class GtsTestUtil {
|
||||
|
||||
/** Returns true if the device doesn't support Widevine and this is permitted. */
|
||||
public static boolean shouldSkipWidevineTest(Context context) {
|
||||
if (Util.SDK_INT < 18) {
|
||||
// MediaDrm isn't present until API 18
|
||||
return true;
|
||||
}
|
||||
if (isGmsInstalled(context)) {
|
||||
// GMS devices are required to support Widevine.
|
||||
return false;
|
||||
|
@ -16,7 +16,6 @@
|
||||
package androidx.media3.test.session.common;
|
||||
|
||||
import android.os.HandlerThread;
|
||||
import androidx.media3.common.util.Util;
|
||||
import org.junit.rules.ExternalResource;
|
||||
|
||||
/** TestRule for providing a handler and an executor for {@link HandlerThread}. */
|
||||
@ -40,11 +39,7 @@ public final class HandlerThreadTestRule extends ExternalResource {
|
||||
@Override
|
||||
protected void after() {
|
||||
try {
|
||||
if (Util.SDK_INT >= 18) {
|
||||
handler.getLooper().quitSafely();
|
||||
} else {
|
||||
handler.getLooper().quit();
|
||||
}
|
||||
handler.getLooper().quitSafely();
|
||||
} finally {
|
||||
handler = null;
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ import androidx.media3.common.TrackSelectionOverride;
|
||||
import androidx.media3.common.TrackSelectionParameters;
|
||||
import androidx.media3.common.Tracks;
|
||||
import androidx.media3.common.VideoSize;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.test.session.R;
|
||||
import androidx.media3.test.session.common.HandlerThreadTestRule;
|
||||
import androidx.media3.test.session.common.MainLooperTestRule;
|
||||
@ -163,13 +162,10 @@ public class MediaControllerTest {
|
||||
MediaController controller = controllerTestRule.createController(session.getToken());
|
||||
PendingIntent sessionActivity = controller.getSessionActivity();
|
||||
assertThat(sessionActivity).isNotNull();
|
||||
if (Util.SDK_INT >= 17) {
|
||||
// PendingIntent#getCreatorPackage() is added in API 17.
|
||||
assertThat(sessionActivity.getCreatorPackage()).isEqualTo(SUPPORT_APP_PACKAGE_NAME);
|
||||
assertThat(sessionActivity.getCreatorPackage()).isEqualTo(SUPPORT_APP_PACKAGE_NAME);
|
||||
|
||||
// TODO: Add getPid/getUid in MediaControllerProviderService and compare them.
|
||||
// assertThat(sessionActivity.getCreatorUid()).isEqualTo(remoteSession.getUid());
|
||||
}
|
||||
// TODO: Add getPid/getUid in MediaControllerProviderService and compare them.
|
||||
// assertThat(sessionActivity.getCreatorUid()).isEqualTo(remoteSession.getUid());
|
||||
session.cleanUp();
|
||||
}
|
||||
|
||||
|
@ -71,11 +71,7 @@ public class MediaControllerWithFrameworkMediaSessionTest {
|
||||
@After
|
||||
public void cleanUp() {
|
||||
if (handler != null) {
|
||||
if (Util.SDK_INT >= 18) {
|
||||
handler.getLooper().quitSafely();
|
||||
} else {
|
||||
handler.getLooper().quit();
|
||||
}
|
||||
handler.getLooper().quitSafely();
|
||||
handler = null;
|
||||
}
|
||||
}
|
||||
|
@ -371,10 +371,7 @@ public class MediaControllerWithMediaSessionCompatTest {
|
||||
MediaController controller = controllerTestRule.createController(session.getSessionToken());
|
||||
PendingIntent sessionActivityOut = controller.getSessionActivity();
|
||||
assertThat(sessionActivityOut).isNotNull();
|
||||
if (Util.SDK_INT >= 17) {
|
||||
// PendingIntent#getCreatorPackage() is added in API 17.
|
||||
assertThat(sessionActivityOut.getCreatorPackage()).isEqualTo(context.getPackageName());
|
||||
}
|
||||
assertThat(sessionActivityOut.getCreatorPackage()).isEqualTo(context.getPackageName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -299,11 +299,7 @@ public class MediaSessionTest {
|
||||
});
|
||||
}
|
||||
|
||||
if (Util.SDK_INT >= 18) {
|
||||
testThread.quitSafely();
|
||||
} else {
|
||||
testThread.quit();
|
||||
}
|
||||
testThread.quitSafely();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,11 +186,7 @@ public class MockMediaLibraryService extends MediaLibraryService {
|
||||
expectedParams = null;
|
||||
}
|
||||
TestServiceRegistry.getInstance().cleanUp();
|
||||
if (Util.SDK_INT >= 18) {
|
||||
handlerThread.quitSafely();
|
||||
} else {
|
||||
handlerThread.quit();
|
||||
}
|
||||
handlerThread.quitSafely();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,6 @@ import android.os.IBinder;
|
||||
import android.text.TextUtils;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.util.ConditionVariable;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.session.MediaSession.ControllerInfo;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -91,11 +90,7 @@ public class MockMediaSessionService extends MediaSessionService {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
TestServiceRegistry.getInstance().cleanUp();
|
||||
if (Util.SDK_INT >= 18) {
|
||||
handlerThread.quitSafely();
|
||||
} else {
|
||||
handlerThread.quit();
|
||||
}
|
||||
handlerThread.quitSafely();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,8 +77,8 @@ public final class ShadowMediaCodecConfig extends ExternalResource {
|
||||
|
||||
@Override
|
||||
protected void before() throws Throwable {
|
||||
if (Util.SDK_INT <= 19) {
|
||||
// Codec config not supported with Robolectric on API <= 19. Skip rule set up step.
|
||||
if (Util.SDK_INT == 19) {
|
||||
// Codec config not supported with Robolectric on API == 19. Skip rule set up step.
|
||||
return;
|
||||
}
|
||||
configureCodecs(supportedMimeTypes);
|
||||
@ -88,8 +88,8 @@ public final class ShadowMediaCodecConfig extends ExternalResource {
|
||||
protected void after() {
|
||||
supportedMimeTypes.clear();
|
||||
MediaCodecUtil.clearDecoderInfoCache();
|
||||
if (Util.SDK_INT <= 19) {
|
||||
// Codec config not supported with Robolectric on API <= 19. Skip rule tear down step.
|
||||
if (Util.SDK_INT == 19) {
|
||||
// Codec config not supported with Robolectric on API == 19. Skip rule tear down step.
|
||||
return;
|
||||
}
|
||||
ShadowMediaCodecList.reset();
|
||||
|
@ -33,7 +33,6 @@ import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.text.Cue;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.common.util.Util;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
@ -319,7 +318,7 @@ public final class SubtitleView extends FrameLayout {
|
||||
}
|
||||
|
||||
private float getUserCaptionFontScale() {
|
||||
if (Util.SDK_INT < 19 || isInEditMode()) {
|
||||
if (isInEditMode()) {
|
||||
return 1f;
|
||||
}
|
||||
@Nullable
|
||||
@ -331,7 +330,7 @@ public final class SubtitleView extends FrameLayout {
|
||||
}
|
||||
|
||||
private CaptionStyleCompat getUserCaptionStyle() {
|
||||
if (Util.SDK_INT < 19 || isInEditMode()) {
|
||||
if (isInEditMode()) {
|
||||
return CaptionStyleCompat.DEFAULT;
|
||||
}
|
||||
@Nullable
|
||||
|
Loading…
x
Reference in New Issue
Block a user