Clean up unecessary zero-arg toBundle() methods

These are no longer needed now that the `Bundleable` interface has been
removed. Public methods are deprecated, package-private ones are
removed. Callers are migrated in both cases (except where tests
explicitly exist for the deprecated method).

PiperOrigin-RevId: 642294451
This commit is contained in:
ibaker 2024-06-11 09:25:24 -07:00 committed by Copybara-Service
parent 347da7e6a1
commit b145a96c79
10 changed files with 26 additions and 33 deletions

View File

@ -1397,7 +1397,11 @@ public final class Format {
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(31);
private static final String FIELD_LABELS = Util.intToStringMaxRadix(32);
/**
* @deprecated Use {@link #toBundle(boolean)} instead.
*/
@UnstableApi
@Deprecated
public Bundle toBundle() {
return toBundle(/* excludeMetadata= */ false);
}

View File

@ -461,13 +461,10 @@ public interface Player {
}
/**
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #windowUid} and {@link #periodUid} fields. The {@link #windowUid} and
* {@link #periodUid} of an instance restored by {@link #fromBundle} will always be {@code
* null}.
* @deprecated Use {@link #toBundle(int)} instead.
*/
@UnstableApi
@Deprecated
public Bundle toBundle() {
return toBundle(Integer.MAX_VALUE);
}

View File

@ -44,7 +44,8 @@ public final class FormatTest {
@Test
public void roundTripViaBundle_ofParameters_yieldsEqualInstance() {
Format formatToBundle = createTestFormat();
Format formatFromBundle = Format.fromBundle(formatToBundle.toBundle());
Format formatFromBundle =
Format.fromBundle(formatToBundle.toBundle(/* excludeMetadata= */ false));
assertThat(formatFromBundle).isEqualTo(formatToBundle);
}

View File

@ -432,7 +432,8 @@ public final class ExoPlaybackException extends PlaybackException {
bundle.putString(FIELD_RENDERER_NAME, rendererName);
bundle.putInt(FIELD_RENDERER_INDEX, rendererIndex);
if (rendererFormat != null) {
bundle.putBundle(FIELD_RENDERER_FORMAT, rendererFormat.toBundle());
bundle.putBundle(
FIELD_RENDERER_FORMAT, rendererFormat.toBundle(/* excludeMetadata= */ false));
}
bundle.putInt(FIELD_RENDERER_FORMAT_SUPPORT, rendererFormatSupport);
bundle.putBoolean(FIELD_IS_RECOVERABLE, isRecoverable);

View File

@ -97,10 +97,6 @@ import java.util.List;
// Next field key = 12
public Bundle toBundle() {
return toBundleForRemoteProcess(Integer.MAX_VALUE);
}
public Bundle toBundleForRemoteProcess(int controllerInterfaceVersion) {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_LIBRARY_VERSION, libraryVersion);

View File

@ -891,10 +891,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
return bundle;
}
public Bundle toBundle() {
return toBundleForRemoteProcess(Integer.MAX_VALUE);
}
public Bundle toBundleForRemoteProcess(int controllerInterfaceVersion) {
Bundle bundle = new Bundle();
if (playerError != null) {

View File

@ -199,10 +199,6 @@ import com.google.common.base.Objects;
canAccessCurrentMediaItem ? contentBufferedPositionMs : 0);
}
public Bundle toBundle() {
return toBundle(Integer.MAX_VALUE);
}
public Bundle toBundle(int controllerInterfaceVersion) {
Bundle bundle = new Bundle();
if (controllerInterfaceVersion < 3 || !DEFAULT_POSITION_INFO.equalsForBundling(positionInfo)) {

View File

@ -63,7 +63,7 @@ public class MediaControllerStubTest {
.toBundle());
binder.onPlayerInfoChangedWithExclusions(
/* seq= */ 0,
/* playerInfoBundle= */ PlayerInfo.DEFAULT.toBundle(),
/* playerInfoBundle= */ PlayerInfo.DEFAULT.toBundleInProcess(),
/* playerInfoExclusions= */ null);
binder.onPeriodicSessionPositionInfoChanged(/* seq= */ 0, /* sessionPositionInfo= */ null);
binder.onAvailableCommandsChangedFromPlayer(/* seq= */ 0, /* commandsBundle= */ null);
@ -114,7 +114,7 @@ public class MediaControllerStubTest {
.toBundle());
binder.onPlayerInfoChangedWithExclusions(
/* seq= */ 0,
/* playerInfoBundle= */ PlayerInfo.DEFAULT.toBundle(),
/* playerInfoBundle= */ PlayerInfo.DEFAULT.toBundleInProcess(),
/* playerInfoExclusions= */ getThrowingBundle());
binder.onPeriodicSessionPositionInfoChanged(
/* seq= */ 0, /* sessionPositionInfo= */ getThrowingBundle());

View File

@ -163,7 +163,7 @@ public class PlayerInfoTest {
.setVideoSize(new VideoSize(/* width= */ 1024, /* height= */ 768))
.build();
PlayerInfo infoAfterBundling = PlayerInfo.fromBundle(playerInfo.toBundle());
PlayerInfo infoAfterBundling = PlayerInfo.fromBundle(playerInfo.toBundleInProcess());
assertThat(infoAfterBundling.oldPositionInfo.mediaItemIndex).isEqualTo(5);
assertThat(infoAfterBundling.oldPositionInfo.periodIndex).isEqualTo(4);
@ -292,7 +292,7 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ false,
/* excludeTracks= */ false)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.oldPositionInfo.mediaItemIndex).isEqualTo(5);
assertThat(infoAfterBundling.oldPositionInfo.periodIndex).isEqualTo(4);
@ -413,7 +413,7 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ true,
/* excludeTracks= */ false)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.oldPositionInfo.mediaItemIndex).isEqualTo(0);
assertThat(infoAfterBundling.oldPositionInfo.periodIndex).isEqualTo(0);
@ -482,7 +482,7 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ false,
/* excludeTracks= */ false)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.mediaMetadata).isEqualTo(MediaMetadata.EMPTY);
assertThat(infoAfterBundling.playlistMetadata).isEqualTo(MediaMetadata.EMPTY);
@ -502,7 +502,7 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ false,
/* excludeTracks= */ false)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.volume).isEqualTo(1f);
}
@ -522,7 +522,7 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ false,
/* excludeTracks= */ false)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.deviceVolume).isEqualTo(0);
assertThat(infoAfterBundling.deviceMuted).isFalse();
@ -546,7 +546,7 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ false,
/* excludeTracks= */ false)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.audioAttributes).isEqualTo(AudioAttributes.DEFAULT);
}
@ -568,7 +568,7 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ false,
/* excludeTracks= */ false)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.cueGroup).isEqualTo(CueGroup.EMPTY_TIME_ZERO);
}
@ -598,14 +598,14 @@ public class PlayerInfoTest {
.build(),
/* excludeTimeline= */ false,
/* excludeTracks= */ true)
.toBundle());
.toBundleInProcess());
assertThat(infoAfterBundling.currentTracks).isEqualTo(Tracks.EMPTY);
}
@Test
public void toBundleFromBundle_withDefaultValues_restoresAllData() {
PlayerInfo roundTripValue = PlayerInfo.fromBundle(PlayerInfo.DEFAULT.toBundle());
PlayerInfo roundTripValue = PlayerInfo.fromBundle(PlayerInfo.DEFAULT.toBundleInProcess());
assertThat(roundTripValue.oldPositionInfo).isEqualTo(PlayerInfo.DEFAULT.oldPositionInfo);
assertThat(roundTripValue.newPositionInfo).isEqualTo(PlayerInfo.DEFAULT.newPositionInfo);

View File

@ -53,7 +53,8 @@ public class SessionPositionInfoTest {
/* currentLiveOffsetMs= */ 20L,
/* contentDurationMs= */ 400L,
/* contentBufferedPositionMs= */ 223L);
Bundle sessionPositionInfoBundle = testSessionPositionInfo.toBundle();
Bundle sessionPositionInfoBundle =
testSessionPositionInfo.toBundle(MediaControllerStub.VERSION_INT);
SessionPositionInfo sessionPositionInfo =
SessionPositionInfo.fromBundle(sessionPositionInfoBundle);
assertThat(sessionPositionInfo).isEqualTo(testSessionPositionInfo);
@ -89,7 +90,8 @@ public class SessionPositionInfoTest {
@Test
public void roundTripViaBundle_withDefaultValues_yieldsEqualInstance() {
SessionPositionInfo roundTripValue =
SessionPositionInfo.fromBundle(SessionPositionInfo.DEFAULT.toBundle());
SessionPositionInfo.fromBundle(
SessionPositionInfo.DEFAULT.toBundle(MediaControllerStub.VERSION_INT));
assertThat(roundTripValue).isEqualTo(SessionPositionInfo.DEFAULT);
}