From 1dd96cd8fb0741ab85943b8b99cf5e870841cd31 Mon Sep 17 00:00:00 2001 From: tonihei Date: Fri, 9 Apr 2021 09:56:51 +0100 Subject: [PATCH] Remove warning suppression. This was added in https://github.com/google/ExoPlayer/commit/9609af3c23383f2fd5571662d271c3013875705d as part of a LSC. The RequiresNonNull annotation doesn't work anymore (it doesn't recognize the outer class member and instead tries to find the same variable on the inner class). So instead of suppressing the warning of the non-fulfilled precondition, we can just check the non-nullness directly and remove the precondition. PiperOrigin-RevId: 367593941 --- .../drm/DefaultDrmSessionManager.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java index 942174330d..ebc08641fb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java @@ -52,7 +52,6 @@ import java.util.Set; import java.util.UUID; import org.checkerframework.checker.nullness.qual.EnsuresNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; -import org.checkerframework.checker.nullness.qual.RequiresNonNull; /** * A {@link DrmSessionManager} that supports playbacks using {@link ExoMediaDrm}. @@ -483,8 +482,6 @@ public class DefaultDrmSessionManager implements DrmSessionManager { exoMediaDrm = null; } - // precondition of preacquiredSessionReference.acquire is not satisfied. - @SuppressWarnings("nullness:contracts.precondition.not.satisfied") @Override public DrmSessionReference preacquireSession( Looper playbackLooper, @@ -943,23 +940,23 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * *

Must be called at most once. Can be called from any thread. */ - @RequiresNonNull("playbackHandler") public void acquire(Format format) { - playbackHandler.post( - () -> { - if (prepareCallsCount == 0 || isReleased) { - // The manager has been fully released or this reference has already been released. - // Abort the acquisition attempt. - return; - } - this.session = - acquireSession( - checkNotNull(playbackLooper), - eventDispatcher, - format, - /* shouldReleasePreacquiredSessionsBeforeRetrying= */ false); - preacquiredSessionReferences.add(this); - }); + checkNotNull(playbackHandler) + .post( + () -> { + if (prepareCallsCount == 0 || isReleased) { + // The manager has been fully released or this reference has already been + // released. Abort the acquisition attempt. + return; + } + this.session = + acquireSession( + checkNotNull(playbackLooper), + eventDispatcher, + format, + /* shouldReleasePreacquiredSessionsBeforeRetrying= */ false); + preacquiredSessionReferences.add(this); + }); } @Override