mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
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())
|
? Assertions.checkNotNull(intent.getData())
|
||||||
: Uri.parse(DEFAULT_MEDIA_URI);
|
: Uri.parse(DEFAULT_MEDIA_URI);
|
||||||
DrmSessionManager drmSessionManager;
|
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 drmScheme = Assertions.checkNotNull(intent.getStringExtra(DRM_SCHEME_EXTRA));
|
||||||
String drmLicenseUrl = Assertions.checkNotNull(intent.getStringExtra(DRM_LICENSE_URL_EXTRA));
|
String drmLicenseUrl = Assertions.checkNotNull(intent.getStringExtra(DRM_LICENSE_URL_EXTRA));
|
||||||
UUID drmSchemeUuid = Assertions.checkNotNull(Util.getDrmUuid(drmScheme));
|
UUID drmSchemeUuid = Assertions.checkNotNull(Util.getDrmUuid(drmScheme));
|
||||||
|
@ -200,13 +200,6 @@ public class DownloadTracker {
|
|||||||
return;
|
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.
|
// TODO(internal b/163107948): Support cases where DrmInitData are not in the manifest.
|
||||||
if (!hasNonNullWidevineSchemaData(format.drmInitData)) {
|
if (!hasNonNullWidevineSchemaData(format.drmInitData)) {
|
||||||
Toast.makeText(context, R.string.download_start_error_offline_license, Toast.LENGTH_LONG)
|
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;
|
MediaItem.DrmConfiguration drmConfiguration = mediaItem.localConfiguration.drmConfiguration;
|
||||||
if (drmConfiguration != null) {
|
if (drmConfiguration != null) {
|
||||||
if (Build.VERSION.SDK_INT < 18) {
|
if (!FrameworkMediaDrm.isCryptoSchemeSupported(drmConfiguration.scheme)) {
|
||||||
showToast(R.string.error_drm_unsupported_before_api_18);
|
|
||||||
finish();
|
|
||||||
return Collections.emptyList();
|
|
||||||
} else if (!FrameworkMediaDrm.isCryptoSchemeSupported(drmConfiguration.scheme)) {
|
|
||||||
showToast(R.string.error_drm_unsupported_scheme);
|
showToast(R.string.error_drm_unsupported_scheme);
|
||||||
finish();
|
finish();
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
<string name="error_generic">Playback failed</string>
|
<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_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>
|
<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.annotation.Nullable;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.BundleCollectionUtil;
|
import androidx.media3.common.util.BundleCollectionUtil;
|
||||||
import androidx.media3.common.util.BundleUtil;
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
@ -1453,8 +1452,8 @@ public abstract class Timeline implements Bundleable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
BundleUtil.putBinder(bundle, FIELD_WINDOWS, new BundleListRetriever(windowBundles));
|
bundle.putBinder(FIELD_WINDOWS, new BundleListRetriever(windowBundles));
|
||||||
BundleUtil.putBinder(bundle, FIELD_PERIODS, new BundleListRetriever(periodBundles));
|
bundle.putBinder(FIELD_PERIODS, new BundleListRetriever(periodBundles));
|
||||||
bundle.putIntArray(FIELD_SHUFFLED_WINDOW_INDICES, shuffledWindowIndices);
|
bundle.putIntArray(FIELD_SHUFFLED_WINDOW_INDICES, shuffledWindowIndices);
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
@ -1503,9 +1502,9 @@ public abstract class Timeline implements Bundleable {
|
|||||||
@UnstableApi
|
@UnstableApi
|
||||||
public static Timeline fromBundle(Bundle bundle) {
|
public static Timeline fromBundle(Bundle bundle) {
|
||||||
ImmutableList<Window> windows =
|
ImmutableList<Window> windows =
|
||||||
fromBundleListRetriever(Window::fromBundle, BundleUtil.getBinder(bundle, FIELD_WINDOWS));
|
fromBundleListRetriever(Window::fromBundle, bundle.getBinder(FIELD_WINDOWS));
|
||||||
ImmutableList<Period> periods =
|
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);
|
@Nullable int[] shuffledWindowIndices = bundle.getIntArray(FIELD_SHUFFLED_WINDOW_INDICES);
|
||||||
return new RemotableTimeline(
|
return new RemotableTimeline(
|
||||||
windows,
|
windows,
|
||||||
|
@ -623,7 +623,7 @@ public class TrackSelectionParameters implements Bundleable {
|
|||||||
* Sets the preferred language and role flags for text tracks based on the accessibility
|
* Sets the preferred language and role flags for text tracks based on the accessibility
|
||||||
* settings of {@link CaptioningManager}.
|
* 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}.
|
* @param context A {@link Context}.
|
||||||
* @return This builder.
|
* @return This builder.
|
||||||
@ -631,9 +631,7 @@ public class TrackSelectionParameters implements Bundleable {
|
|||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
|
public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
|
||||||
Context context) {
|
Context context) {
|
||||||
if (Util.SDK_INT >= 19) {
|
|
||||||
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(context);
|
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(context);
|
||||||
}
|
|
||||||
return this;
|
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) {
|
if (context != null) {
|
||||||
EGL14.eglDestroyContext(display, context);
|
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)) {
|
if (display != null && !display.equals(EGL14.EGL_NO_DISPLAY)) {
|
||||||
// Android is unusual in that it uses a reference-counted EGLDisplay. So for
|
// Android is unusual in that it uses a reference-counted EGLDisplay. So for
|
||||||
// every eglInitialize() we need an eglTerminate().
|
// every eglInitialize() we need an eglTerminate().
|
||||||
|
@ -192,7 +192,7 @@ public final class GlUtil {
|
|||||||
* EGLContext)}.
|
* EGLContext)}.
|
||||||
*/
|
*/
|
||||||
public static boolean isSurfacelessContextExtensionSupported() {
|
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.
|
* for HDR input.
|
||||||
*/
|
*/
|
||||||
public static boolean isYuvTargetExtensionSupported() {
|
public static boolean isYuvTargetExtensionSupported() {
|
||||||
if (Util.SDK_INT < 17) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Nullable String glExtensions;
|
@Nullable String glExtensions;
|
||||||
if (Util.areEqual(Api17.getCurrentContext(), EGL14.EGL_NO_CONTEXT)) {
|
if (Util.areEqual(Api17.getCurrentContext(), EGL14.EGL_NO_CONTEXT)) {
|
||||||
// Create a placeholder context and make it current to allow calling GLES20.glGetString().
|
// 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. */
|
/** Returns whether {@link #EXTENSION_COLORSPACE_BT2020_PQ} is supported. */
|
||||||
public static boolean isBt2020PqExtensionSupported() {
|
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}. */
|
/** Returns an initialized default {@link EGLDisplay}. */
|
||||||
@ -396,15 +393,11 @@ public final class GlUtil {
|
|||||||
* <p>The {@code syncObject} must not be used after deletion.
|
* <p>The {@code syncObject} must not be used after deletion.
|
||||||
*/
|
*/
|
||||||
public static void deleteSyncObject(long syncObject) throws GlException {
|
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. */
|
/** Releases the GL sync object if set, suppressing any error. */
|
||||||
public static void deleteSyncObjectQuietly(long syncObject) {
|
public static void deleteSyncObjectQuietly(long syncObject) {
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
try {
|
try {
|
||||||
// glDeleteSync ignores a 0-valued sync object.
|
// glDeleteSync ignores a 0-valued sync object.
|
||||||
Api18.deleteSyncObject(syncObject);
|
Api18.deleteSyncObject(syncObject);
|
||||||
@ -412,7 +405,6 @@ public final class GlUtil {
|
|||||||
// Suppress exceptions.
|
// Suppress exceptions.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that following commands on the current OpenGL context will not be executed until the
|
* Ensures that following commands on the current OpenGL context will not be executed until the
|
||||||
@ -614,7 +606,6 @@ public final class GlUtil {
|
|||||||
// TODO(b/227624622): Implement a pixel test that confirms 16f has less posterization.
|
// 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.
|
// TODO - b/309459038: Consider renaming the method, as the created textures are uninitialized.
|
||||||
if (useHighPrecisionColorComponents) {
|
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, GLES30.GL_RGBA16F, GLES30.GL_HALF_FLOAT);
|
||||||
}
|
}
|
||||||
return createTextureUninitialized(width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE);
|
return createTextureUninitialized(width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE);
|
||||||
|
@ -32,7 +32,7 @@ public final class TraceUtil {
|
|||||||
* Unicode code units long.
|
* Unicode code units long.
|
||||||
*/
|
*/
|
||||||
public static void beginSection(String sectionName) {
|
public static void beginSection(String sectionName) {
|
||||||
if (MediaLibraryInfo.TRACE_ENABLED && Util.SDK_INT >= 18) {
|
if (MediaLibraryInfo.TRACE_ENABLED) {
|
||||||
beginSectionV18(sectionName);
|
beginSectionV18(sectionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ public final class TraceUtil {
|
|||||||
* @see android.os.Trace#endSection()
|
* @see android.os.Trace#endSection()
|
||||||
*/
|
*/
|
||||||
public static void endSection() {
|
public static void endSection() {
|
||||||
if (MediaLibraryInfo.TRACE_ENABLED && Util.SDK_INT >= 18) {
|
if (MediaLibraryInfo.TRACE_ENABLED) {
|
||||||
endSectionV18();
|
endSectionV18();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3134,16 +3134,13 @@ public final class Util {
|
|||||||
@UnstableApi
|
@UnstableApi
|
||||||
public static Point getCurrentDisplayModeSize(Context context) {
|
public static Point getCurrentDisplayModeSize(Context context) {
|
||||||
@Nullable Display defaultDisplay = null;
|
@Nullable Display defaultDisplay = null;
|
||||||
if (SDK_INT >= 17) {
|
|
||||||
@Nullable
|
@Nullable
|
||||||
DisplayManager displayManager =
|
DisplayManager displayManager =
|
||||||
(DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
(DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
||||||
// We don't expect displayManager to ever be null, so this check is just precautionary.
|
// 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) {
|
if (displayManager != null) {
|
||||||
defaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
|
defaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (defaultDisplay == null) {
|
if (defaultDisplay == null) {
|
||||||
WindowManager windowManager =
|
WindowManager windowManager =
|
||||||
checkNotNull((WindowManager) context.getSystemService(Context.WINDOW_SERVICE));
|
checkNotNull((WindowManager) context.getSystemService(Context.WINDOW_SERVICE));
|
||||||
@ -3214,10 +3211,8 @@ public final class Util {
|
|||||||
Point displaySize = new Point();
|
Point displaySize = new Point();
|
||||||
if (SDK_INT >= 23) {
|
if (SDK_INT >= 23) {
|
||||||
getDisplaySizeV23(display, displaySize);
|
getDisplaySizeV23(display, displaySize);
|
||||||
} else if (SDK_INT >= 17) {
|
|
||||||
getDisplaySizeV17(display, displaySize);
|
|
||||||
} else {
|
} else {
|
||||||
getDisplaySizeV16(display, displaySize);
|
getDisplaySizeV17(display, displaySize);
|
||||||
}
|
}
|
||||||
return displaySize;
|
return displaySize;
|
||||||
}
|
}
|
||||||
@ -3708,10 +3703,6 @@ public final class Util {
|
|||||||
display.getRealSize(outSize);
|
display.getRealSize(outSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void getDisplaySizeV16(Display display, Point outSize) {
|
|
||||||
display.getSize(outSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String[] getSystemLocales() {
|
private static String[] getSystemLocales() {
|
||||||
Configuration config = Resources.getSystem().getConfiguration();
|
Configuration config = Resources.getSystem().getConfiguration();
|
||||||
return SDK_INT >= 24
|
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(
|
private static void maybeTerminateInputStream(
|
||||||
@Nullable HttpURLConnection connection, long bytesRemaining) {
|
@Nullable HttpURLConnection connection, long bytesRemaining) {
|
||||||
if (connection == null || Util.SDK_INT < 19 || Util.SDK_INT > 20) {
|
if (connection == null || Util.SDK_INT > 20) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import static androidx.media3.common.util.Assertions.checkState;
|
|||||||
import static androidx.media3.common.util.Util.castNonNull;
|
import static androidx.media3.common.util.Util.castNonNull;
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
@ -347,19 +346,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
return cachedContent;
|
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
|
* 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
|
* 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) {
|
if (secretKey != null) {
|
||||||
Assertions.checkArgument(secretKey.length == 16);
|
Assertions.checkArgument(secretKey.length == 16);
|
||||||
try {
|
try {
|
||||||
cipher = getCipher();
|
cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||||
secretKeySpec = new SecretKeySpec(secretKey, "AES");
|
secretKeySpec = new SecretKeySpec(secretKey, "AES");
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||||
throw new IllegalStateException(e); // Should never happen.
|
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.getBitmapAveragePixelAbsoluteDifferenceArgb8888;
|
||||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.junit.Assume.assumeTrue;
|
|
||||||
|
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@ -103,8 +102,6 @@ public class EffectPlaybackTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void exoplayerEffectsPreviewTest_ensuresFirstFrameRendered() throws Exception {
|
public void exoplayerEffectsPreviewTest_ensuresFirstFrameRendered() throws Exception {
|
||||||
assumeTrue(Util.SDK_INT >= 18);
|
|
||||||
|
|
||||||
String testId =
|
String testId =
|
||||||
Util.formatInvariant(
|
Util.formatInvariant(
|
||||||
"exoplayerEffectsPreviewTest_withPlayWhenReady[%b]_ensuresFirstFrameRendered",
|
"exoplayerEffectsPreviewTest_withPlayWhenReady[%b]_ensuresFirstFrameRendered",
|
||||||
|
@ -374,11 +374,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
// audio recording or speech recognition'.
|
// audio recording or speech recognition'.
|
||||||
// Assistant is considered as both recording and notifying developer
|
// Assistant is considered as both recording and notifying developer
|
||||||
case C.USAGE_ASSISTANT:
|
case C.USAGE_ASSISTANT:
|
||||||
if (Util.SDK_INT >= 19) {
|
|
||||||
return AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE;
|
return AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE;
|
||||||
} else {
|
|
||||||
return AUDIOFOCUS_GAIN_TRANSIENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special usages:
|
// Special usages:
|
||||||
case C.USAGE_ASSISTANCE_ACCESSIBILITY:
|
case C.USAGE_ASSISTANCE_ACCESSIBILITY:
|
||||||
|
@ -754,10 +754,10 @@ public final class MediaMetricsListener
|
|||||||
return new ErrorInfo(errorCode, subErrorCode);
|
return new ErrorInfo(errorCode, subErrorCode);
|
||||||
} else if (Util.SDK_INT >= 23 && cause instanceof MediaDrmResetException) {
|
} else if (Util.SDK_INT >= 23 && cause instanceof MediaDrmResetException) {
|
||||||
return new ErrorInfo(PlaybackErrorEvent.ERROR_DRM_SYSTEM_ERROR, /* subErrorCode= */ 0);
|
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(
|
return new ErrorInfo(
|
||||||
PlaybackErrorEvent.ERROR_DRM_PROVISIONING_FAILED, /* subErrorCode= */ 0);
|
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);
|
return new ErrorInfo(PlaybackErrorEvent.ERROR_DRM_DEVICE_REVOKED, /* subErrorCode= */ 0);
|
||||||
} else if (cause instanceof UnsupportedDrmException) {
|
} else if (cause instanceof UnsupportedDrmException) {
|
||||||
return new ErrorInfo(
|
return new ErrorInfo(
|
||||||
@ -810,7 +810,7 @@ public final class MediaMetricsListener
|
|||||||
} else if (cause instanceof AudioSink.WriteException) {
|
} else if (cause instanceof AudioSink.WriteException) {
|
||||||
int subErrorCode = ((AudioSink.WriteException) cause).errorCode;
|
int subErrorCode = ((AudioSink.WriteException) cause).errorCode;
|
||||||
return new ErrorInfo(PlaybackErrorEvent.ERROR_AUDIO_TRACK_WRITE_FAILED, subErrorCode);
|
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 subErrorCode = ((MediaCodec.CryptoException) cause).getErrorCode();
|
||||||
int errorCode = getDrmErrorCode(subErrorCode);
|
int errorCode = getDrmErrorCode(subErrorCode);
|
||||||
return new ErrorInfo(errorCode, subErrorCode);
|
return new ErrorInfo(errorCode, subErrorCode);
|
||||||
|
@ -354,8 +354,7 @@ public final class AudioCapabilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean deviceMaySetExternalSurroundSoundGlobalSetting() {
|
private static boolean deviceMaySetExternalSurroundSoundGlobalSetting() {
|
||||||
return Util.SDK_INT >= 17
|
return "Amazon".equals(Util.MANUFACTURER) || "Xiaomi".equals(Util.MANUFACTURER);
|
||||||
&& ("Amazon".equals(Util.MANUFACTURER) || "Xiaomi".equals(Util.MANUFACTURER));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getChannelConfigForPassthrough(int channelCount) {
|
private static int getChannelConfigForPassthrough(int channelCount) {
|
||||||
|
@ -24,7 +24,6 @@ import androidx.annotation.IntDef;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@ -105,16 +104,11 @@ import java.lang.annotation.Target;
|
|||||||
/**
|
/**
|
||||||
* Creates a new audio timestamp poller.
|
* 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) {
|
public AudioTimestampPoller(AudioTrack audioTrack) {
|
||||||
if (Util.SDK_INT >= 19) {
|
|
||||||
audioTimestamp = new AudioTimestampV19(audioTrack);
|
audioTimestamp = new AudioTimestampV19(audioTrack);
|
||||||
reset();
|
reset();
|
||||||
} else {
|
|
||||||
audioTimestamp = null;
|
|
||||||
updateState(STATE_NO_TIMESTAMP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,13 +224,11 @@ import java.lang.reflect.Method;
|
|||||||
*/
|
*/
|
||||||
public AudioTrackPositionTracker(Listener listener) {
|
public AudioTrackPositionTracker(Listener listener) {
|
||||||
this.listener = checkNotNull(listener);
|
this.listener = checkNotNull(listener);
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
try {
|
try {
|
||||||
getLatencyMethod = AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
|
getLatencyMethod = AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
// There's no guarantee this method exists. Do nothing.
|
// There's no guarantee this method exists. Do nothing.
|
||||||
}
|
}
|
||||||
}
|
|
||||||
playheadOffsets = new long[MAX_PLAYHEAD_OFFSET_COUNT];
|
playheadOffsets = new long[MAX_PLAYHEAD_OFFSET_COUNT];
|
||||||
clock = Clock.DEFAULT;
|
clock = Clock.DEFAULT;
|
||||||
}
|
}
|
||||||
|
@ -657,11 +657,8 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean acquisitionFailedIndicatingResourceShortage(DrmSession session) {
|
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
|
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);
|
checkNotNull(mediaItem.localConfiguration);
|
||||||
@Nullable
|
@Nullable
|
||||||
MediaItem.DrmConfiguration drmConfiguration = mediaItem.localConfiguration.drmConfiguration;
|
MediaItem.DrmConfiguration drmConfiguration = mediaItem.localConfiguration.drmConfiguration;
|
||||||
if (drmConfiguration == null || Util.SDK_INT < 18) {
|
if (drmConfiguration == null) {
|
||||||
return DrmSessionManager.DRM_UNSUPPORTED;
|
return DrmSessionManager.DRM_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,13 +80,13 @@ public final class DrmUtil {
|
|||||||
return Api21.mediaDrmStateExceptionToErrorCode(exception);
|
return Api21.mediaDrmStateExceptionToErrorCode(exception);
|
||||||
} else if (Util.SDK_INT >= 23 && Api23.isMediaDrmResetException(exception)) {
|
} else if (Util.SDK_INT >= 23 && Api23.isMediaDrmResetException(exception)) {
|
||||||
return PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR;
|
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;
|
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;
|
return PlaybackException.ERROR_CODE_DRM_DEVICE_REVOKED;
|
||||||
} else if (exception instanceof UnsupportedDrmException) {
|
} else if (exception instanceof UnsupportedDrmException) {
|
||||||
return PlaybackException.ERROR_CODE_DRM_SCHEME_UNSUPPORTED;
|
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;
|
return PlaybackException.ERROR_CODE_DRM_CONTENT_ERROR;
|
||||||
} else if (exception instanceof KeysExpiredException) {
|
} else if (exception instanceof KeysExpiredException) {
|
||||||
return PlaybackException.ERROR_CODE_DRM_LICENSE_EXPIRED;
|
return PlaybackException.ERROR_CODE_DRM_LICENSE_EXPIRED;
|
||||||
|
@ -695,7 +695,7 @@ public final class MediaCodecInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAdaptive(CodecCapabilities capabilities) {
|
private static boolean isAdaptive(CodecCapabilities capabilities) {
|
||||||
return Util.SDK_INT >= 19 && isAdaptiveV19(capabilities);
|
return isAdaptiveV19(capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(19)
|
@RequiresApi(19)
|
||||||
|
@ -1217,8 +1217,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
|
codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
|
||||||
codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName);
|
codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName);
|
||||||
codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecName);
|
codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecName);
|
||||||
codecNeedsMonoChannelCountWorkaround =
|
codecNeedsMonoChannelCountWorkaround = false;
|
||||||
codecNeedsMonoChannelCountWorkaround(codecName, checkNotNull(codecInputFormat));
|
|
||||||
codecNeedsEosPropagation =
|
codecNeedsEosPropagation =
|
||||||
codecNeedsEosPropagationWorkaround(codecInfo) || getCodecNeedsEosPropagation();
|
codecNeedsEosPropagationWorkaround(codecInfo) || getCodecNeedsEosPropagation();
|
||||||
if (checkNotNull(codec).needsReconfiguration()) {
|
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.
|
* @return True if the decoder is known to fail when flushed.
|
||||||
*/
|
*/
|
||||||
private static boolean codecNeedsFlushWorkaround(String name) {
|
private static boolean codecNeedsFlushWorkaround(String name) {
|
||||||
return Util.SDK_INT < 18
|
return Util.SDK_INT == 19
|
||||||
|| (Util.SDK_INT == 18
|
|
||||||
&& ("OMX.SEC.avc.dec".equals(name) || "OMX.SEC.avc.dec.secure".equals(name)))
|
|
||||||
|| (Util.SDK_INT == 19
|
|
||||||
&& Util.MODEL.startsWith("SM-G800")
|
&& 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) {
|
private static boolean codecNeedsEosPropagationWorkaround(MediaCodecInfo codecInfo) {
|
||||||
String name = codecInfo.name;
|
String name = codecInfo.name;
|
||||||
return (Util.SDK_INT <= 25 && "OMX.rk.video_decoder.avc".equals(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
|
|| (Util.SDK_INT <= 29
|
||||||
&& ("OMX.broadcom.video_decoder.tunnel".equals(name)
|
&& ("OMX.broadcom.video_decoder.tunnel".equals(name)
|
||||||
|| "OMX.broadcom.video_decoder.tunnel.secure".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) {
|
private static boolean codecNeedsEosFlushWorkaround(String name) {
|
||||||
return (Util.SDK_INT <= 23 && "OMX.google.vorbis.decoder".equals(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))
|
&& ("hb2000".equals(Util.DEVICE) || "stvm8".equals(Util.DEVICE))
|
||||||
&& ("OMX.amlogic.avc.decoder.awesome".equals(name)
|
&& ("OMX.amlogic.avc.decoder.awesome".equals(name)
|
||||||
|| "OMX.amlogic.avc.decoder.awesome.secure".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);
|
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 {
|
private static final class OutputStreamInfo {
|
||||||
|
|
||||||
public static final OutputStreamInfo UNSET =
|
public static final OutputStreamInfo UNSET =
|
||||||
|
@ -543,44 +543,6 @@ public final class MediaCodecUtil {
|
|||||||
return false;
|
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.
|
// Work around https://github.com/google/ExoPlayer/issues/3249.
|
||||||
if (Util.SDK_INT < 24
|
if (Util.SDK_INT < 24
|
||||||
&& ("OMX.SEC.aac.dec".equals(name) || "OMX.Exynos.AAC.Decoder".equals(name))
|
&& ("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.
|
// 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.
|
// 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)
|
&& "OMX.SEC.vp8.dec".equals(name)
|
||||||
&& "samsung".equals(Util.MANUFACTURER)
|
&& "samsung".equals(Util.MANUFACTURER)
|
||||||
&& (Util.DEVICE.startsWith("d2")
|
&& (Util.DEVICE.startsWith("d2")
|
||||||
@ -610,7 +572,7 @@ public final class MediaCodecUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VP8 decoder on Samsung Galaxy S4 cannot be queried.
|
// VP8 decoder on Samsung Galaxy S4 cannot be queried.
|
||||||
if (Util.SDK_INT <= 19
|
if (Util.SDK_INT == 19
|
||||||
&& Util.DEVICE.startsWith("jflte")
|
&& Util.DEVICE.startsWith("jflte")
|
||||||
&& "OMX.qcom.video.decoder.vp8".equals(name)) {
|
&& "OMX.qcom.video.decoder.vp8".equals(name)) {
|
||||||
return false;
|
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.
|
* @param surface The new {@link Surface}, or {@code null} if the renderer does not have one.
|
||||||
*/
|
*/
|
||||||
public void onSurfaceChanged(@Nullable Surface surface) {
|
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.
|
// We don't care about dummy surfaces for release timing, since they're not visible.
|
||||||
surface = null;
|
surface = null;
|
||||||
}
|
}
|
||||||
@ -422,9 +422,7 @@ public final class VideoFrameReleaseHelper {
|
|||||||
@Nullable DisplayHelper displayHelper = null;
|
@Nullable DisplayHelper displayHelper = null;
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
context = context.getApplicationContext();
|
context = context.getApplicationContext();
|
||||||
if (Util.SDK_INT >= 17) {
|
|
||||||
displayHelper = DisplayHelperV17.maybeBuildNewInstance(context);
|
displayHelper = DisplayHelperV17.maybeBuildNewInstance(context);
|
||||||
}
|
|
||||||
if (displayHelper == null) {
|
if (displayHelper == null) {
|
||||||
displayHelper = DisplayHelperV16.maybeBuildNewInstance(context);
|
displayHelper = DisplayHelperV16.maybeBuildNewInstance(context);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ import androidx.media3.common.C;
|
|||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.GlUtil;
|
import androidx.media3.common.util.GlUtil;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import androidx.media3.exoplayer.video.VideoFrameMetadataListener;
|
import androidx.media3.exoplayer.video.VideoFrameMetadataListener;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import javax.microedition.khronos.egl.EGLConfig;
|
import javax.microedition.khronos.egl.EGLConfig;
|
||||||
@ -103,14 +102,11 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
|
|||||||
// Configure sensors and touch.
|
// Configure sensors and touch.
|
||||||
sensorManager =
|
sensorManager =
|
||||||
(SensorManager) Assertions.checkNotNull(context.getSystemService(Context.SENSOR_SERVICE));
|
(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
|
// 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
|
// 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
|
// devices. When used indoors, the magnetometer can take some time to settle depending on the
|
||||||
// device and amount of metal in the environment.
|
// device and amount of metal in the environment.
|
||||||
orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
|
@Nullable Sensor orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
|
||||||
}
|
|
||||||
if (orientationSensor == null) {
|
if (orientationSensor == null) {
|
||||||
orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
|
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.Bundleable;
|
||||||
import androidx.media3.common.Player;
|
import androidx.media3.common.Player;
|
||||||
import androidx.media3.common.util.BundleCollectionUtil;
|
import androidx.media3.common.util.BundleCollectionUtil;
|
||||||
import androidx.media3.common.util.BundleUtil;
|
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -139,7 +138,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public Bundle toBundleInProcess() {
|
public Bundle toBundleInProcess() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
BundleUtil.putBinder(bundle, FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
bundle.putBinder(FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +151,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/** Restores a {@code ConnectionState} from a {@link Bundle}. */
|
/** Restores a {@code ConnectionState} from a {@link Bundle}. */
|
||||||
public static ConnectionState fromBundle(Bundle 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) {
|
if (inProcessBinder instanceof InProcessBinder) {
|
||||||
return ((InProcessBinder) inProcessBinder).getConnectionState();
|
return ((InProcessBinder) inProcessBinder).getConnectionState();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,6 @@ import androidx.media3.common.Tracks;
|
|||||||
import androidx.media3.common.VideoSize;
|
import androidx.media3.common.VideoSize;
|
||||||
import androidx.media3.common.text.CueGroup;
|
import androidx.media3.common.text.CueGroup;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.BundleUtil;
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
@ -901,7 +900,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
|||||||
*/
|
*/
|
||||||
public Bundle toBundleInProcess() {
|
public Bundle toBundleInProcess() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
BundleUtil.putBinder(bundle, FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
bundle.putBinder(FIELD_IN_PROCESS_BINDER, new InProcessBinder());
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1025,7 +1024,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
|||||||
|
|
||||||
/** Restores a {@code PlayerInfo} from a {@link Bundle}. */
|
/** Restores a {@code PlayerInfo} from a {@link Bundle}. */
|
||||||
public static PlayerInfo fromBundle(Bundle 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) {
|
if (inProcessBinder instanceof InProcessBinder) {
|
||||||
return ((InProcessBinder) inProcessBinder).getPlayerInfo();
|
return ((InProcessBinder) inProcessBinder).getPlayerInfo();
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,6 @@ import java.util.List;
|
|||||||
|
|
||||||
@SuppressWarnings("ResourceType")
|
@SuppressWarnings("ResourceType")
|
||||||
public static boolean isL1WidevineAvailable(String mimeType) {
|
public static boolean isL1WidevineAvailable(String mimeType) {
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
try {
|
try {
|
||||||
// Force L3 if secure decoder is not available.
|
// Force L3 if secure decoder is not available.
|
||||||
if (MediaCodecUtil.getDecoderInfo(mimeType, /* secure= */ true, /* tunneling= */ false)
|
if (MediaCodecUtil.getDecoderInfo(mimeType, /* secure= */ true, /* tunneling= */ false)
|
||||||
@ -121,8 +120,6 @@ import java.util.List;
|
|||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DashTestRunner(@Size(max = 23) String tag, HostActivity activity) {
|
public DashTestRunner(@Size(max = 23) String tag, HostActivity activity) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
|
@ -135,8 +135,7 @@ public class EnumerateDecodersTest {
|
|||||||
appendAudioCapabilities(codecCapabilities.getAudioCapabilities(), result);
|
appendAudioCapabilities(codecCapabilities.getAudioCapabilities(), result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Util.SDK_INT >= 19
|
if (isVideo
|
||||||
&& isVideo
|
|
||||||
&& codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback)) {
|
&& codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback)) {
|
||||||
result.append(", 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.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.media.MediaDrm;
|
import android.media.MediaDrm;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
|
|
||||||
/** Utility methods for GTS tests. */
|
/** Utility methods for GTS tests. */
|
||||||
public final class GtsTestUtil {
|
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. */
|
/** Returns true if the device doesn't support Widevine and this is permitted. */
|
||||||
public static boolean shouldSkipWidevineTest(Context context) {
|
public static boolean shouldSkipWidevineTest(Context context) {
|
||||||
if (Util.SDK_INT < 18) {
|
|
||||||
// MediaDrm isn't present until API 18
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (isGmsInstalled(context)) {
|
if (isGmsInstalled(context)) {
|
||||||
// GMS devices are required to support Widevine.
|
// GMS devices are required to support Widevine.
|
||||||
return false;
|
return false;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
package androidx.media3.test.session.common;
|
package androidx.media3.test.session.common;
|
||||||
|
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import org.junit.rules.ExternalResource;
|
import org.junit.rules.ExternalResource;
|
||||||
|
|
||||||
/** TestRule for providing a handler and an executor for {@link HandlerThread}. */
|
/** TestRule for providing a handler and an executor for {@link HandlerThread}. */
|
||||||
@ -40,11 +39,7 @@ public final class HandlerThreadTestRule extends ExternalResource {
|
|||||||
@Override
|
@Override
|
||||||
protected void after() {
|
protected void after() {
|
||||||
try {
|
try {
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
handler.getLooper().quitSafely();
|
handler.getLooper().quitSafely();
|
||||||
} else {
|
|
||||||
handler.getLooper().quit();
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
handler = null;
|
handler = null;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ import androidx.media3.common.TrackSelectionOverride;
|
|||||||
import androidx.media3.common.TrackSelectionParameters;
|
import androidx.media3.common.TrackSelectionParameters;
|
||||||
import androidx.media3.common.Tracks;
|
import androidx.media3.common.Tracks;
|
||||||
import androidx.media3.common.VideoSize;
|
import androidx.media3.common.VideoSize;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import androidx.media3.test.session.R;
|
import androidx.media3.test.session.R;
|
||||||
import androidx.media3.test.session.common.HandlerThreadTestRule;
|
import androidx.media3.test.session.common.HandlerThreadTestRule;
|
||||||
import androidx.media3.test.session.common.MainLooperTestRule;
|
import androidx.media3.test.session.common.MainLooperTestRule;
|
||||||
@ -163,13 +162,10 @@ public class MediaControllerTest {
|
|||||||
MediaController controller = controllerTestRule.createController(session.getToken());
|
MediaController controller = controllerTestRule.createController(session.getToken());
|
||||||
PendingIntent sessionActivity = controller.getSessionActivity();
|
PendingIntent sessionActivity = controller.getSessionActivity();
|
||||||
assertThat(sessionActivity).isNotNull();
|
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.
|
// TODO: Add getPid/getUid in MediaControllerProviderService and compare them.
|
||||||
// assertThat(sessionActivity.getCreatorUid()).isEqualTo(remoteSession.getUid());
|
// assertThat(sessionActivity.getCreatorUid()).isEqualTo(remoteSession.getUid());
|
||||||
}
|
|
||||||
session.cleanUp();
|
session.cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,11 +71,7 @@ public class MediaControllerWithFrameworkMediaSessionTest {
|
|||||||
@After
|
@After
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
handler.getLooper().quitSafely();
|
handler.getLooper().quitSafely();
|
||||||
} else {
|
|
||||||
handler.getLooper().quit();
|
|
||||||
}
|
|
||||||
handler = null;
|
handler = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,11 +371,8 @@ public class MediaControllerWithMediaSessionCompatTest {
|
|||||||
MediaController controller = controllerTestRule.createController(session.getSessionToken());
|
MediaController controller = controllerTestRule.createController(session.getSessionToken());
|
||||||
PendingIntent sessionActivityOut = controller.getSessionActivity();
|
PendingIntent sessionActivityOut = controller.getSessionActivity();
|
||||||
assertThat(sessionActivityOut).isNotNull();
|
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
|
@Test
|
||||||
public void setRepeatMode_updatesAndNotifiesRepeatMode() throws Exception {
|
public void setRepeatMode_updatesAndNotifiesRepeatMode() throws Exception {
|
||||||
|
@ -299,11 +299,7 @@ public class MediaSessionTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
testThread.quitSafely();
|
testThread.quitSafely();
|
||||||
} else {
|
|
||||||
testThread.quit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,11 +186,7 @@ public class MockMediaLibraryService extends MediaLibraryService {
|
|||||||
expectedParams = null;
|
expectedParams = null;
|
||||||
}
|
}
|
||||||
TestServiceRegistry.getInstance().cleanUp();
|
TestServiceRegistry.getInstance().cleanUp();
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
handlerThread.quitSafely();
|
handlerThread.quitSafely();
|
||||||
} else {
|
|
||||||
handlerThread.quit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,6 @@ import android.os.IBinder;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.util.ConditionVariable;
|
import androidx.media3.common.util.ConditionVariable;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import androidx.media3.session.MediaSession.ControllerInfo;
|
import androidx.media3.session.MediaSession.ControllerInfo;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@ -91,11 +90,7 @@ public class MockMediaSessionService extends MediaSessionService {
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
TestServiceRegistry.getInstance().cleanUp();
|
TestServiceRegistry.getInstance().cleanUp();
|
||||||
if (Util.SDK_INT >= 18) {
|
|
||||||
handlerThread.quitSafely();
|
handlerThread.quitSafely();
|
||||||
} else {
|
|
||||||
handlerThread.quit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,8 +77,8 @@ public final class ShadowMediaCodecConfig extends ExternalResource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void before() throws Throwable {
|
protected void before() throws Throwable {
|
||||||
if (Util.SDK_INT <= 19) {
|
if (Util.SDK_INT == 19) {
|
||||||
// Codec config not supported with Robolectric on API <= 19. Skip rule set up step.
|
// Codec config not supported with Robolectric on API == 19. Skip rule set up step.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
configureCodecs(supportedMimeTypes);
|
configureCodecs(supportedMimeTypes);
|
||||||
@ -88,8 +88,8 @@ public final class ShadowMediaCodecConfig extends ExternalResource {
|
|||||||
protected void after() {
|
protected void after() {
|
||||||
supportedMimeTypes.clear();
|
supportedMimeTypes.clear();
|
||||||
MediaCodecUtil.clearDecoderInfoCache();
|
MediaCodecUtil.clearDecoderInfoCache();
|
||||||
if (Util.SDK_INT <= 19) {
|
if (Util.SDK_INT == 19) {
|
||||||
// Codec config not supported with Robolectric on API <= 19. Skip rule tear down step.
|
// Codec config not supported with Robolectric on API == 19. Skip rule tear down step.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ShadowMediaCodecList.reset();
|
ShadowMediaCodecList.reset();
|
||||||
|
@ -33,7 +33,6 @@ import androidx.annotation.IntDef;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.text.Cue;
|
import androidx.media3.common.text.Cue;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
@ -319,7 +318,7 @@ public final class SubtitleView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private float getUserCaptionFontScale() {
|
private float getUserCaptionFontScale() {
|
||||||
if (Util.SDK_INT < 19 || isInEditMode()) {
|
if (isInEditMode()) {
|
||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -331,7 +330,7 @@ public final class SubtitleView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CaptionStyleCompat getUserCaptionStyle() {
|
private CaptionStyleCompat getUserCaptionStyle() {
|
||||||
if (Util.SDK_INT < 19 || isInEditMode()) {
|
if (isInEditMode()) {
|
||||||
return CaptionStyleCompat.DEFAULT;
|
return CaptionStyleCompat.DEFAULT;
|
||||||
}
|
}
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user