Skip to content

Commit

Permalink
Merge pull request #983 from MGaetan89:min_api_19
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 607319987
  • Loading branch information
copybara-github committed Feb 15, 2024
2 parents 4777d62 + b82f341 commit fb74383
Show file tree
Hide file tree
Showing 62 changed files with 279 additions and 903 deletions.
2 changes: 1 addition & 1 deletion api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ package androidx.media3.exoplayer.analytics {

package androidx.media3.exoplayer.drm {

@RequiresApi(18) public final class FrameworkMediaDrm {
public final class FrameworkMediaDrm {
method public static boolean isCryptoSchemeSupported(java.util.UUID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void initializePlayer() {
? 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.FragmentManager;
import androidx.media3.common.C;
import androidx.media3.common.DrmInitData;
Expand Down Expand Up @@ -202,12 +201,7 @@ public void onPrepared(DownloadHelper helper) {
}

// 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)
Expand Down Expand Up @@ -362,7 +356,6 @@ private DownloadRequest buildDownloadRequest() {
}

/** Downloads a Widevine offline license in a background thread. */
@RequiresApi(18)
private static final class WidevineOfflineLicenseFetchTask {

private final Format format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,7 @@ private List<MediaItem> createMediaItems(Intent intent) {

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();
Expand Down
2 changes: 0 additions & 2 deletions demos/main/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
import androidx.annotation.IntRange;
import androidx.annotation.RequiresApi;
import androidx.media3.common.util.GlUtil.GlException;
import androidx.media3.common.util.UnstableApi;

Expand All @@ -39,7 +38,6 @@ public interface GlObjectsProvider {
* @param configAttributes The attributes to configure EGL with.
* @throws GlException If an error occurs during creation.
*/
@RequiresApi(17)
EGLContext createEglContext(
EGLDisplay eglDisplay, @IntRange(from = 2, to = 3) int openGlVersion, int[] configAttributes)
throws GlException;
Expand All @@ -54,7 +52,6 @@ EGLContext createEglContext(
* @param isEncoderInputSurface Whether the {@code surface} is the input surface of an encoder.
* @throws GlException If an error occurs during creation.
*/
@RequiresApi(17)
EGLSurface createEglSurface(
EGLDisplay eglDisplay,
Object surface,
Expand All @@ -72,7 +69,6 @@ EGLSurface createEglSurface(
* surface.
* @throws GlException If an error occurs during creation.
*/
@RequiresApi(17)
EGLSurface createFocusedPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay)
throws GlException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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;
Expand Down Expand Up @@ -1453,8 +1452,8 @@ public final Bundle toBundle() {
}

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;
}
Expand Down Expand Up @@ -1503,9 +1502,9 @@ public final Timeline copyWithSingleWindow(int windowIndex) {
@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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import android.view.accessibility.CaptioningManager;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.media3.common.util.BundleCollectionUtil;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
Expand Down Expand Up @@ -623,16 +622,28 @@ public Builder setAudioOffloadPreferences(AudioOffloadPreferences audioOffloadPr
* Sets the preferred language and role flags for text tracks based on the accessibility
* settings of {@link CaptioningManager}.
*
* <p>Does nothing for API levels &lt; 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.
*/
@CanIgnoreReturnValue
public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
Context context) {
if (Util.SDK_INT >= 19) {
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(context);
if (Util.SDK_INT < 23 && Looper.myLooper() == null) {
// Android platform bug (pre-Marshmallow) that causes RuntimeExceptions when
// CaptioningService is instantiated from a non-Looper thread. See [internal: b/143779904].
return this;
}
CaptioningManager captioningManager =
(CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE);
if (captioningManager == null || !captioningManager.isEnabled()) {
return this;
}
preferredTextRoleFlags = C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND;
Locale preferredLocale = captioningManager.getLocale();
if (preferredLocale != null) {
preferredTextLanguages = ImmutableList.of(Util.getLocaleLanguageTag(preferredLocale));
}
return this;
}
Expand Down Expand Up @@ -832,26 +843,6 @@ public TrackSelectionParameters build() {
return new TrackSelectionParameters(this);
}

@RequiresApi(19)
private void setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(
Context context) {
if (Util.SDK_INT < 23 && Looper.myLooper() == null) {
// Android platform bug (pre-Marshmallow) that causes RuntimeExceptions when
// CaptioningService is instantiated from a non-Looper thread. See [internal: b/143779904].
return;
}
CaptioningManager captioningManager =
(CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE);
if (captioningManager == null || !captioningManager.isEnabled()) {
return;
}
preferredTextRoleFlags = C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND;
Locale preferredLocale = captioningManager.getLocale();
if (preferredLocale != null) {
preferredTextLanguages = ImmutableList.of(Util.getLocaleLanguageTag(preferredLocale));
}
}

private static ImmutableList<String> normalizeLanguageCodes(String[] preferredTextLanguages) {
ImmutableList.Builder<String> listBuilder = ImmutableList.builder();
for (String language : checkNotNull(preferredTextLanguages)) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
import android.os.Handler;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/** Generates a {@link SurfaceTexture} using EGL/GLES functions. */
@RequiresApi(17)
@UnstableApi
public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableListener, Runnable {

Expand Down Expand Up @@ -150,10 +148,7 @@ public void release() {
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().
Expand Down
Loading

0 comments on commit fb74383

Please sign in to comment.