Add @Nullable to ExoMediaDrm's setListener methods

These methods document themselves only by referencing the Android's
MediaDrm, which explicitly accepts null [1]. The implementation in
FrameworkMediaDrm also handles nulls.

[1] https://developer.android.com/reference/android/media/MediaDrm#setOnEventListener(android.media.MediaDrm.OnEventListener)

PiperOrigin-RevId: 302007441
This commit is contained in:
ibaker 2020-03-20 12:16:22 +00:00 committed by Oliver Woodman
parent c251eac545
commit c0d632936a
3 changed files with 10 additions and 9 deletions

View File

@ -34,17 +34,17 @@ public final class DummyExoMediaDrm implements ExoMediaDrm {
} }
@Override @Override
public void setOnEventListener(OnEventListener listener) { public void setOnEventListener(@Nullable OnEventListener listener) {
// Do nothing. // Do nothing.
} }
@Override @Override
public void setOnKeyStatusChangeListener(OnKeyStatusChangeListener listener) { public void setOnKeyStatusChangeListener(@Nullable OnKeyStatusChangeListener listener) {
// Do nothing. // Do nothing.
} }
@Override @Override
public void setOnExpirationUpdateListener(OnExpirationUpdateListener listener) { public void setOnExpirationUpdateListener(@Nullable OnExpirationUpdateListener listener) {
// Do nothing. // Do nothing.
} }

View File

@ -225,13 +225,13 @@ public interface ExoMediaDrm {
} }
/** @see MediaDrm#setOnEventListener(MediaDrm.OnEventListener) */ /** @see MediaDrm#setOnEventListener(MediaDrm.OnEventListener) */
void setOnEventListener(OnEventListener listener); void setOnEventListener(@Nullable OnEventListener listener);
/** @see MediaDrm#setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler) */ /** @see MediaDrm#setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler) */
void setOnKeyStatusChangeListener(OnKeyStatusChangeListener listener); void setOnKeyStatusChangeListener(@Nullable OnKeyStatusChangeListener listener);
/** @see MediaDrm#setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler) */ /** @see MediaDrm#setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler) */
void setOnExpirationUpdateListener(OnExpirationUpdateListener listener); void setOnExpirationUpdateListener(@Nullable OnExpirationUpdateListener listener);
/** @see MediaDrm#openSession() */ /** @see MediaDrm#openSession() */
byte[] openSession() throws MediaDrmException; byte[] openSession() throws MediaDrmException;

View File

@ -106,7 +106,7 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
} }
@Override @Override
public void setOnEventListener(ExoMediaDrm.OnEventListener listener) { public void setOnEventListener(@Nullable ExoMediaDrm.OnEventListener listener) {
mediaDrm.setOnEventListener( mediaDrm.setOnEventListener(
listener == null listener == null
? null ? null
@ -115,7 +115,8 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
} }
@Override @Override
public void setOnKeyStatusChangeListener(ExoMediaDrm.OnKeyStatusChangeListener listener) { public void setOnKeyStatusChangeListener(
@Nullable ExoMediaDrm.OnKeyStatusChangeListener listener) {
if (Util.SDK_INT < 23) { if (Util.SDK_INT < 23) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -135,7 +136,7 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
} }
@Override @Override
public void setOnExpirationUpdateListener(OnExpirationUpdateListener listener) { public void setOnExpirationUpdateListener(@Nullable OnExpirationUpdateListener listener) {
if (Util.SDK_INT < 23) { if (Util.SDK_INT < 23) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }