Rename MediaSession.Builder.setSessionCallback to setCallback

Follow-up to c78c1f5891

PiperOrigin-RevId: 449492810
This commit is contained in:
ibaker 2022-05-18 16:48:33 +01:00 committed by Ian Baker
parent 2a45dd3930
commit cd142872bb
12 changed files with 66 additions and 77 deletions

View File

@ -15,7 +15,7 @@
* Fix bug that tracks are reset too often when using `MergingMediaSource`,
for example when side-loading subtitles and changing the selected
subtitle mid-playback
([#10248](https://github.com/google/ExoPlayer/issues/10248)).
([#10248](https://github.com/google/ExoPlayer/issues/10248)).
* Track selection:
* Flatten `TrackSelectionOverrides` class into `TrackSelectionParameters`,
and promote `TrackSelectionOverride` to a top level class.
@ -98,10 +98,10 @@
change([#51](https://github.com/androidx/media/issues/51)).
* Fix NPE in MediaControllerImplBase after releasing controller
([#74](https://github.com/androidx/media/issues/74)).
* Rename `MediaSession.MediaSessionCallback` to `MediaSession.Callback`
and `MediaLibrarySession.MediaLibrarySession` to
`MediaLibrarySession.Callback` for consistency with other nested
listener and callbacks like `Player.Listener`.
* Rename `MediaSession.MediaSessionCallback` to `MediaSession.Callback`,
`MediaLibrarySession.MediaLibrarySessionCallback` to
`MediaLibrarySession.Callback` and
`MediaSession.Builder.setSessionCallback` to `setCallback`.
* Data sources:
* Rename `DummyDataSource` to `PlaceHolderDataSource`.
* Workaround OkHttp interrupt handling.

View File

@ -280,8 +280,8 @@ public class MediaSession {
* @return The builder to allow chaining.
*/
@Override
public Builder setSessionCallback(Callback callback) {
return super.setSessionCallback(callback);
public Builder setCallback(Callback callback) {
return super.setCallback(callback);
}
/**
@ -769,8 +769,8 @@ public class MediaSession {
* <p>The callback methods will be called from the application thread associated with the {@link
* Player#getApplicationLooper() application looper} of the underlying {@link Player}.
*
* <p>If it's not set by {@link MediaSession.Builder#setSessionCallback(Callback)}, the session
* will accept all controllers and all incoming commands by default.
* <p>If it's not set by {@link MediaSession.Builder#setCallback(Callback)}, the session will
* accept all controllers and all incoming commands by default.
*/
public interface Callback {
@ -1227,7 +1227,7 @@ public class MediaSession {
}
@SuppressWarnings("unchecked")
/* package */ U setSessionCallback(C callback) {
/* package */ U setCallback(C callback) {
this.callback = checkNotNull(callback);
return (U) this;
}

View File

@ -91,7 +91,7 @@ public class MediaSessionCallbackTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(callback)
.setCallback(callback)
.setId("testOnPostConnect_afterConnected")
.build());
controllerTestRule.createRemoteController(session.getToken());
@ -117,7 +117,7 @@ public class MediaSessionCallbackTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(callback)
.setCallback(callback)
.setId("testOnPostConnect_afterConnectionRejected")
.build());
controllerTestRule.createRemoteController(session.getToken());
@ -149,7 +149,7 @@ public class MediaSessionCallbackTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(callback)
.setCallback(callback)
.setId("testOnCommandRequest")
.build());
RemoteMediaController controller =
@ -210,7 +210,7 @@ public class MediaSessionCallbackTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(callback)
.setCallback(callback)
.setId("testOnCustomCommand")
.build());
RemoteMediaController controller =
@ -247,7 +247,7 @@ public class MediaSessionCallbackTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(callback)
.setCallback(callback)
.setId("testOnSetMediaUri")
.build());
RemoteMediaController controller =
@ -287,7 +287,7 @@ public class MediaSessionCallbackTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(callback)
.setCallback(callback)
.setId("testOnSetRating")
.build());
RemoteMediaController controller =
@ -323,7 +323,7 @@ public class MediaSessionCallbackTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(callback)
.setCallback(callback)
.setId("testOnSetRating")
.build());
RemoteMediaController controller =
@ -507,7 +507,7 @@ public class MediaSessionCallbackTest {
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setId("testOnConnect")
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
@Override
public MediaSession.ConnectionResult onConnect(
@ -538,7 +538,7 @@ public class MediaSessionCallbackTest {
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setId("testOnDisconnected")
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
@Override
public void onDisconnected(MediaSession session, ControllerInfo controller) {

View File

@ -115,7 +115,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("onDisconnected_afterTimeout_isCalled")
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
private ControllerInfo connectedController;
@ -154,7 +154,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("onConnected_afterDisconnectedByTimeout_isCalled")
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
private ControllerInfo connectedController;
@ -197,7 +197,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("play")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -213,7 +213,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("pause")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -229,7 +229,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("stop")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -245,7 +245,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("prepare")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -261,7 +261,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("seekTo")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -279,7 +279,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("setPlaybackSpeed")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -297,7 +297,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("addQueueItem")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -323,7 +323,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("addQueueItemWithIndex")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -351,7 +351,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("removeQueueItem")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -380,7 +380,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("skipToPrevious")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -396,7 +396,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("skipToNext")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -412,7 +412,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("skipToQueueItem")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -439,7 +439,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("setShuffleMode")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -457,7 +457,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("setRepeatMode")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -475,7 +475,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("setVolumeTo_setsDeviceVolume")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -503,7 +503,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("adjustVolume_raise_increasesDeviceVolume")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -529,7 +529,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("adjustVolume_lower_decreasesDeviceVolume")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -560,7 +560,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("setVolumeWithLocalVolume")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -608,7 +608,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("adjustVolumeWithLocalVolume")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -689,7 +689,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("sendCommand")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -741,7 +741,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("sendCommand")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -765,7 +765,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("controllerCallback_sessionRejects")
.setSessionCallback(sessionCallback)
.setCallback(sessionCallback)
.build();
// Session will not accept the controller's commands.
controller =
@ -798,7 +798,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("prepareFromMediaUri")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -830,7 +830,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("playFromMediaUri")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -863,7 +863,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("prepareFromMediaId")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -896,7 +896,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("playFromMediaId")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -929,7 +929,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("prepareFromSearch")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -962,7 +962,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("playFromSearch")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -1002,10 +1002,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
player.timeline = MediaTestUtils.createTimeline(mediaItems);
});
session =
new MediaSession.Builder(context, player)
.setId("setRating")
.setSessionCallback(callback)
.build();
new MediaSession.Builder(context, player).setId("setRating").setCallback(callback).build();
controller =
new RemoteMediaControllerCompat(
context, session.getSessionCompat().getSessionToken(), /* waitForConnection= */ true);
@ -1037,7 +1034,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("onPlayerCommandRequest")
.setSessionCallback(callback)
.setCallback(callback)
.build();
controller =
new RemoteMediaControllerCompat(
@ -1066,7 +1063,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId("deadlock")
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -1101,7 +1098,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId(sessionId)
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller =
new RemoteMediaControllerCompat(
@ -1119,7 +1116,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
session =
new MediaSession.Builder(context, player)
.setId(sessionId)
.setSessionCallback(new TestSessionCallback())
.setCallback(new TestSessionCallback())
.build();
controller.getTransportControls().play();

View File

@ -92,7 +92,7 @@ public class MediaSessionKeyEventTest {
player = new MockPlayer.Builder().setApplicationLooper(handler.getLooper()).build();
sessionCallback = new TestSessionCallback();
session = new MediaSession.Builder(context, player).setSessionCallback(sessionCallback).build();
session = new MediaSession.Builder(context, player).setCallback(sessionCallback).build();
// Here's the requirement for an app to receive media key events via MediaSession.
// - SDK < 26: Player should be playing for receiving key events

View File

@ -381,10 +381,7 @@ public class MediaSessionPermissionTest {
this.session.release();
}
this.session =
new MediaSession.Builder(context, player)
.setId(SESSION_ID)
.setSessionCallback(callback)
.build();
new MediaSession.Builder(context, player).setId(SESSION_ID).setCallback(callback).build();
}
private SessionCommands createSessionCommandsWith(SessionCommand command) {

View File

@ -66,7 +66,7 @@ public class MediaSessionPlayerTest {
.build();
session =
new MediaSession.Builder(ApplicationProvider.getApplicationContext(), player)
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
@Override
public MediaSession.ConnectionResult onConnect(

View File

@ -127,7 +127,7 @@ public class MediaSessionServiceTest {
new MediaSession.Builder(
context, new MockPlayer.Builder().setApplicationLooper(looper).build())
.setId("testOnGetSession_returnsSession")
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
@Override
public MediaSession.ConnectionResult onConnect(

View File

@ -84,7 +84,7 @@ public class MediaSessionTest {
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setId(TAG)
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
@Override
public MediaSession.ConnectionResult onConnect(
@ -354,9 +354,7 @@ public class MediaSessionTest {
};
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setSessionCallback(testSessionCallback)
.build());
new MediaSession.Builder(context, player).setCallback(testSessionCallback).build());
controllerTestRule.createRemoteController(session.getToken());
assertThat(latch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
}
@ -372,7 +370,7 @@ public class MediaSessionTest {
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setId("getSessionCompatToken_returnsCompatibleWithMediaControllerCompat")
.setSessionCallback(
.setCallback(
new MediaSession.Callback() {
@Override
public MediaSession.ConnectionResult onConnect(
@ -426,7 +424,7 @@ public class MediaSessionTest {
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setId("getControllerVersion")
.setSessionCallback(sessionCallback)
.setCallback(sessionCallback)
.build());
controllerTestRule.createRemoteController(session.getToken());

View File

@ -79,10 +79,7 @@ public class MediaSessionWithMediaControllerCompatTest {
MediaSession session =
sessionTestRule.ensureReleaseAfterTest(
new MediaSession.Builder(context, player)
.setId(TAG)
.setSessionCallback(callback)
.build());
new MediaSession.Builder(context, player).setId(TAG).setCallback(callback).build());
RemoteMediaControllerCompat controllerCompat =
remoteControllerTestRule.createRemoteControllerCompat(
session.getSessionCompat().getSessionToken());

View File

@ -179,7 +179,7 @@ public class MediaSessionProviderService extends Service {
}
case TEST_CONTROLLER_LISTENER_SESSION_REJECTS:
{
builder.setSessionCallback(
builder.setCallback(
new MediaSession.Callback() {
@Override
public MediaSession.ConnectionResult onConnect(
@ -194,7 +194,7 @@ public class MediaSessionProviderService extends Service {
SessionCommands availableSessionCommands =
SessionCommands.CREATOR.fromBundle(
tokenExtras.getBundle(KEY_AVAILABLE_SESSION_COMMANDS));
builder.setSessionCallback(
builder.setCallback(
new MediaSession.Callback() {
@Override
public MediaSession.ConnectionResult onConnect(

View File

@ -66,7 +66,7 @@ public class MockMediaSessionService extends MediaSessionService {
session =
new MediaSession.Builder(MockMediaSessionService.this, player)
.setId(ID)
.setSessionCallback(callback != null ? callback : new TestSessionCallback())
.setCallback(callback != null ? callback : new TestSessionCallback())
.build();
}
return session;