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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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