Commit d9fd8f43 by tonihei Committed by Rohit Singh

Add Builder for DeviceInfo

This simplifies the addition of new fields in the future.

Also do some misc clean up for the volume limit values:
 - Add some documentation to mention assumed defaults
 - Add the IntRange annotations to match the ones we have in Player
   already
 - Mention the limits in the relevant Player methods
 - Avoid bundling default values
 - Improve range checks for masking in MediaController

PiperOrigin-RevId: 526029619
parent 186f3d5c
Showing with 155 additions and 67 deletions
......@@ -36,6 +36,7 @@
* Fix issue where last frame may not be rendered if the last sample with
frames is dequeued without reading the 'end of stream' sample.
([#11079](https://github.com/google/ExoPlayer/issues/11079)).
* Add `Builder` for `DeviceInfo` and deprecate existing constructor.
* Session:
* Deprecate 4 volume-controlling methods in `Player` and add overloaded
methods which allow users to specify volume flags:
......
......@@ -178,11 +178,18 @@ package androidx.media3.common {
field public static final int PLAYBACK_TYPE_LOCAL = 0; // 0x0
field public static final int PLAYBACK_TYPE_REMOTE = 1; // 0x1
field public static final androidx.media3.common.DeviceInfo UNKNOWN;
field public final int maxVolume;
field public final int minVolume;
field @IntRange(from=0) public final int maxVolume;
field @IntRange(from=0) public final int minVolume;
field @androidx.media3.common.DeviceInfo.PlaybackType public final int playbackType;
}
public static final class DeviceInfo.Builder {
ctor public DeviceInfo.Builder(@androidx.media3.common.DeviceInfo.PlaybackType int);
method public androidx.media3.common.DeviceInfo build();
method public androidx.media3.common.DeviceInfo.Builder setMaxVolume(@IntRange(from=0) int);
method public androidx.media3.common.DeviceInfo.Builder setMinVolume(@IntRange(from=0) int);
}
@IntDef({androidx.media3.common.DeviceInfo.PLAYBACK_TYPE_LOCAL, androidx.media3.common.DeviceInfo.PLAYBACK_TYPE_REMOTE}) @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) public static @interface DeviceInfo.PlaybackType {
}
......
......@@ -85,7 +85,7 @@ public final class CastPlayer extends BasePlayer {
/** The {@link DeviceInfo} returned by {@link #getDeviceInfo() this player}. */
public static final DeviceInfo DEVICE_INFO =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 0);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).build();
static {
MediaLibraryInfo.registerModule("media3.cast");
......
......@@ -19,9 +19,12 @@ import static java.lang.annotation.ElementType.TYPE_USE;
import android.os.Bundle;
import androidx.annotation.IntDef;
import androidx.annotation.IntRange;
import androidx.annotation.Nullable;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -45,22 +48,83 @@ public final class DeviceInfo implements Bundleable {
public static final int PLAYBACK_TYPE_REMOTE = 1;
/** Unknown DeviceInfo. */
public static final DeviceInfo UNKNOWN =
new DeviceInfo(PLAYBACK_TYPE_LOCAL, /* minVolume= */ 0, /* maxVolume= */ 0);
public static final DeviceInfo UNKNOWN = new Builder(PLAYBACK_TYPE_LOCAL).build();
/** Builder for {@link DeviceInfo}. */
public static final class Builder {
private final @PlaybackType int playbackType;
private int minVolume;
private int maxVolume;
/**
* Creates the builder.
*
* @param playbackType The {@link PlaybackType}.
*/
public Builder(@PlaybackType int playbackType) {
this.playbackType = playbackType;
}
/**
* Sets the minimum supported device volume.
*
* <p>The minimum will be set to {@code 0} if not specified.
*
* @param minVolume The minimum device volume.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder setMinVolume(@IntRange(from = 0) int minVolume) {
this.minVolume = minVolume;
return this;
}
/**
* Sets the maximum supported device volume.
*
* @param maxVolume The maximum device volume, or {@code 0} to leave the maximum unspecified.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder setMaxVolume(@IntRange(from = 0) int maxVolume) {
this.maxVolume = maxVolume;
return this;
}
/** Builds the {@link DeviceInfo}. */
public DeviceInfo build() {
Assertions.checkArgument(minVolume <= maxVolume);
return new DeviceInfo(this);
}
}
/** The type of playback. */
public final @PlaybackType int playbackType;
/** The minimum volume that the device supports. */
@IntRange(from = 0)
public final int minVolume;
/** The maximum volume that the device supports. */
/** The maximum volume that the device supports, or {@code 0} if unspecified. */
@IntRange(from = 0)
public final int maxVolume;
/** Creates device information. */
/**
* @deprecated Use {@link Builder} instead.
*/
@UnstableApi
public DeviceInfo(@PlaybackType int playbackType, int minVolume, int maxVolume) {
this.playbackType = playbackType;
this.minVolume = minVolume;
this.maxVolume = maxVolume;
@Deprecated
public DeviceInfo(
@PlaybackType int playbackType,
@IntRange(from = 0) int minVolume,
@IntRange(from = 0) int maxVolume) {
this(new Builder(playbackType).setMinVolume(minVolume).setMaxVolume(maxVolume));
}
private DeviceInfo(Builder builder) {
this.playbackType = builder.playbackType;
this.minVolume = builder.minVolume;
this.maxVolume = builder.maxVolume;
}
@Override
......@@ -96,9 +160,15 @@ public final class DeviceInfo implements Bundleable {
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_PLAYBACK_TYPE, playbackType);
bundle.putInt(FIELD_MIN_VOLUME, minVolume);
bundle.putInt(FIELD_MAX_VOLUME, maxVolume);
if (playbackType != PLAYBACK_TYPE_LOCAL) {
bundle.putInt(FIELD_PLAYBACK_TYPE, playbackType);
}
if (minVolume != 0) {
bundle.putInt(FIELD_MIN_VOLUME, minVolume);
}
if (maxVolume != 0) {
bundle.putInt(FIELD_MAX_VOLUME, maxVolume);
}
return bundle;
}
......@@ -110,6 +180,9 @@ public final class DeviceInfo implements Bundleable {
bundle.getInt(FIELD_PLAYBACK_TYPE, /* defaultValue= */ PLAYBACK_TYPE_LOCAL);
int minVolume = bundle.getInt(FIELD_MIN_VOLUME, /* defaultValue= */ 0);
int maxVolume = bundle.getInt(FIELD_MAX_VOLUME, /* defaultValue= */ 0);
return new DeviceInfo(playbackType, minVolume, maxVolume);
return new DeviceInfo.Builder(playbackType)
.setMinVolume(minVolume)
.setMaxVolume(maxVolume)
.build();
};
}
......@@ -3135,6 +3135,9 @@ public interface Player {
/**
* Increases the volume of the device.
*
* <p>The {@link #getDeviceVolume()} device volume cannot be increased above {@link
* DeviceInfo#maxVolume}, if defined.
*
* <p>This method must only be called if {@link #COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS} is
* {@linkplain #getAvailableCommands() available}.
*
......@@ -3151,6 +3154,9 @@ public interface Player {
/**
* Decreases the volume of the device.
*
* <p>The {@link #getDeviceVolume()} device volume cannot be decreased below {@link
* DeviceInfo#minVolume}.
*
* <p>This method must only be called if {@link #COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS} is
* {@linkplain #getAvailableCommands() available}.
*
......
......@@ -28,7 +28,10 @@ public class DeviceInfoTest {
@Test
public void roundTripViaBundle_yieldsEqualInstance() {
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 1, /* maxVolume= */ 9);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE)
.setMinVolume(1)
.setMaxVolume(9)
.build();
assertThat(DeviceInfo.CREATOR.fromBundle(deviceInfo.toBundle())).isEqualTo(deviceInfo);
}
......
......@@ -109,8 +109,7 @@ public class SimpleBasePlayerTest {
ImmutableList.of(new Cue.Builder().setText("text").build()),
/* presentationTimeUs= */ 123))
.setDeviceInfo(
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_LOCAL, /* minVolume= */ 3, /* maxVolume= */ 7))
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL).setMaxVolume(7).build())
.setIsDeviceMuted(true)
.setSurfaceSize(new Size(480, 360))
.setNewlyRenderedFirstFrame(true)
......@@ -225,7 +224,7 @@ public class SimpleBasePlayerTest {
Metadata timedMetadata = new Metadata(new FakeMetadataEntry("data"));
Size surfaceSize = new Size(480, 360);
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_LOCAL, /* minVolume= */ 3, /* maxVolume= */ 7);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL).setMaxVolume(7).build();
ImmutableList<SimpleBasePlayer.MediaItemData> playlist =
ImmutableList.of(
new SimpleBasePlayer.MediaItemData.Builder(/* uid= */ new Object()).build(),
......@@ -811,7 +810,7 @@ public class SimpleBasePlayerTest {
ImmutableList.of(new Cue.Builder().setText("text").build()),
/* presentationTimeUs= */ 123);
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_LOCAL, /* minVolume= */ 3, /* maxVolume= */ 7);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL).setMaxVolume(7).build();
MediaMetadata playlistMetadata = new MediaMetadata.Builder().setArtist("artist").build();
SimpleBasePlayer.PositionSupplier contentPositionSupplier = () -> 456;
SimpleBasePlayer.PositionSupplier contentBufferedPositionSupplier = () -> 499;
......@@ -1276,7 +1275,7 @@ public class SimpleBasePlayerTest {
new Metadata(/* presentationTimeUs= */ 42, new FakeMetadataEntry("data"));
Size surfaceSize = new Size(480, 360);
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_LOCAL, /* minVolume= */ 3, /* maxVolume= */ 7);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL).setMaxVolume(7).build();
MediaMetadata playlistMetadata = new MediaMetadata.Builder().setArtist("artist").build();
State state2 =
new State.Builder()
......
......@@ -2791,10 +2791,10 @@ import java.util.concurrent.TimeoutException;
}
private static DeviceInfo createDeviceInfo(StreamVolumeManager streamVolumeManager) {
return new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_LOCAL,
streamVolumeManager.getMinVolume(),
streamVolumeManager.getMaxVolume());
return new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL)
.setMinVolume(streamVolumeManager.getMinVolume())
.setMaxVolume(streamVolumeManager.getMaxVolume())
.build();
}
private static int getPlayWhenReadyChangeReason(boolean playWhenReady, int playerCommand) {
......
......@@ -1399,7 +1399,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
dispatchRemoteSessionTaskWithPlayerCommand(
(iSession, seq) -> iSession.setDeviceVolume(controllerStub, seq, volume));
if (playerInfo.deviceVolume != volume) {
DeviceInfo deviceInfo = getDeviceInfo();
if (playerInfo.deviceVolume != volume
&& deviceInfo.minVolume <= volume
&& (deviceInfo.maxVolume == 0 || volume <= deviceInfo.maxVolume)) {
playerInfo = playerInfo.copyWithDeviceVolume(volume, playerInfo.deviceMuted);
listeners.queueEvent(
......@@ -1418,7 +1421,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
dispatchRemoteSessionTaskWithPlayerCommand(
(iSession, seq) -> iSession.setDeviceVolumeWithFlags(controllerStub, seq, volume, flags));
if (playerInfo.deviceVolume != volume) {
DeviceInfo deviceInfo = getDeviceInfo();
if (playerInfo.deviceVolume != volume
&& deviceInfo.minVolume <= volume
&& (deviceInfo.maxVolume == 0 || volume <= deviceInfo.maxVolume)) {
playerInfo = playerInfo.copyWithDeviceVolume(volume, playerInfo.deviceMuted);
listeners.queueEvent(
......@@ -1442,7 +1448,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
(iSession, seq) -> iSession.increaseDeviceVolume(controllerStub, seq));
int newDeviceVolume = playerInfo.deviceVolume + 1;
if (newDeviceVolume <= getDeviceInfo().maxVolume) {
int maxVolume = getDeviceInfo().maxVolume;
if (maxVolume == 0 || newDeviceVolume <= maxVolume) {
playerInfo = playerInfo.copyWithDeviceVolume(newDeviceVolume, playerInfo.deviceMuted);
listeners.queueEvent(
/* eventFlag= */ Player.EVENT_DEVICE_VOLUME_CHANGED,
......@@ -1461,7 +1468,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
(iSession, seq) -> iSession.increaseDeviceVolumeWithFlags(controllerStub, seq, flags));
int newDeviceVolume = playerInfo.deviceVolume + 1;
if (newDeviceVolume <= getDeviceInfo().maxVolume) {
int maxVolume = getDeviceInfo().maxVolume;
if (maxVolume == 0 || newDeviceVolume <= maxVolume) {
playerInfo = playerInfo.copyWithDeviceVolume(newDeviceVolume, playerInfo.deviceMuted);
listeners.queueEvent(
/* eventFlag= */ Player.EVENT_DEVICE_VOLUME_CHANGED,
......
......@@ -1063,7 +1063,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
DeviceInfo deviceInfo = getDeviceInfo();
int minVolume = deviceInfo.minVolume;
int maxVolume = deviceInfo.maxVolume;
if (minVolume <= volume && volume <= maxVolume) {
if (minVolume <= volume && (maxVolume == 0 || volume <= maxVolume)) {
boolean isDeviceMuted = isDeviceMuted();
ControllerInfo maskedControllerInfo =
new ControllerInfo(
......@@ -1093,7 +1093,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
public void increaseDeviceVolume(@C.VolumeFlags int flags) {
int volume = getDeviceVolume();
int maxVolume = getDeviceInfo().maxVolume;
if (volume + 1 <= maxVolume) {
if (maxVolume == 0 || volume + 1 <= maxVolume) {
boolean isDeviceMuted = isDeviceMuted();
ControllerInfo maskedControllerInfo =
......
......@@ -1335,13 +1335,13 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if (playbackInfoCompat == null) {
return DeviceInfo.UNKNOWN;
}
return new DeviceInfo(
playbackInfoCompat.getPlaybackType()
== MediaControllerCompat.PlaybackInfo.PLAYBACK_TYPE_REMOTE
? DeviceInfo.PLAYBACK_TYPE_REMOTE
: DeviceInfo.PLAYBACK_TYPE_LOCAL,
/* minVolume= */ 0,
playbackInfoCompat.getMaxVolume());
return new DeviceInfo.Builder(
playbackInfoCompat.getPlaybackType()
== MediaControllerCompat.PlaybackInfo.PLAYBACK_TYPE_REMOTE
? DeviceInfo.PLAYBACK_TYPE_REMOTE
: DeviceInfo.PLAYBACK_TYPE_LOCAL)
.setMaxVolume(playbackInfoCompat.getMaxVolume())
.build();
}
/** Converts {@link MediaControllerCompat.PlaybackInfo} to device volume. */
......
......@@ -136,8 +136,7 @@ public class PlayerInfoTest {
new int[] {C.FORMAT_EXCEEDS_CAPABILITIES},
/* trackSelected= */ new boolean[] {true}))))
.setDeviceInfo(
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 4, /* maxVolume= */ 10))
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(10).build())
.setDiscontinuityReason(Player.DISCONTINUITY_REASON_REMOVE)
.setIsLoading(true)
.setIsPlaying(true)
......
......@@ -411,7 +411,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
@Test
public void setPlayer_playbackTypeChangedToRemote() throws Exception {
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 25);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(25).build();
int legacyPlaybackType = MediaControllerCompat.PlaybackInfo.PLAYBACK_TYPE_REMOTE;
int deviceVolume = 10;
CountDownLatch playbackInfoNotified = new CountDownLatch(1);
......@@ -445,12 +445,12 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
@Test
public void setPlayer_playbackTypeChangedToLocal() throws Exception {
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 10);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(10).build();
Bundle playerConfig =
new RemoteMediaSession.MockPlayerConfigBuilder().setDeviceInfo(deviceInfo).build();
session.setPlayer(playerConfig);
DeviceInfo deviceInfoToUpdate =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_LOCAL, /* minVolume= */ 0, /* maxVolume= */ 10);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL).setMaxVolume(10).build();
int legacyPlaybackTypeToUpdate = MediaControllerCompat.PlaybackInfo.PLAYBACK_TYPE_LOCAL;
int legacyStream = AudioManager.STREAM_RING;
AudioAttributesCompat attrsCompat =
......@@ -496,7 +496,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
@Test
public void setPlayer_playbackTypeNotChanged_local() throws Exception {
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_LOCAL, /* minVolume= */ 0, /* maxVolume= */ 10);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL).setMaxVolume(10).build();
int legacyPlaybackType = MediaControllerCompat.PlaybackInfo.PLAYBACK_TYPE_LOCAL;
int legacyStream = AudioManager.STREAM_RING;
AudioAttributesCompat attrsCompat =
......@@ -542,7 +542,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
@Test
public void setPlayer_playbackTypeNotChanged_remote() throws Exception {
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 10);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(10).build();
Bundle playerConfig =
new RemoteMediaSession.MockPlayerConfigBuilder()
.setDeviceInfo(deviceInfo)
......@@ -550,7 +550,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
.build();
session.setPlayer(playerConfig);
DeviceInfo deviceInfoToUpdate =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 25);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(25).build();
int legacyPlaybackTypeToUpdate = MediaControllerCompat.PlaybackInfo.PLAYBACK_TYPE_REMOTE;
int deviceVolumeToUpdate = 10;
CountDownLatch playbackInfoNotified = new CountDownLatch(1);
......@@ -1316,7 +1316,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
@Test
public void onAudioInfoChanged_isCalledByVolumeChange() throws Exception {
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 10);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(10).build();
Bundle playerConfig =
new RemoteMediaSession.MockPlayerConfigBuilder()
.setDeviceInfo(deviceInfo)
......
......@@ -2767,7 +2767,7 @@ public class MediaControllerListenerTest {
threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener));
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
Bundle playerConfig =
new RemoteMediaSession.MockPlayerConfigBuilder().setDeviceInfo(deviceInfo).build();
remoteSession.setPlayer(playerConfig);
......@@ -2806,7 +2806,7 @@ public class MediaControllerListenerTest {
threadTestRule.getHandler().postAndSync(() -> controller.addListener(listener));
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 1, /* maxVolume= */ 23);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(23).build();
remoteSession.getMockPlayer().notifyDeviceInfoChanged(deviceInfo);
assertThat(latch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
......@@ -2819,7 +2819,7 @@ public class MediaControllerListenerTest {
@Test
public void onDeviceVolumeChanged_isCalledByDeviceVolumeChange() throws Exception {
DeviceInfo deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
Bundle playerConfig =
new RemoteMediaSession.MockPlayerConfigBuilder()
.setDeviceInfo(deviceInfo)
......
......@@ -486,8 +486,7 @@ public class MediaControllerStateMaskingTest {
new RemoteMediaSession.MockPlayerConfigBuilder()
.setDeviceVolume(1)
.setDeviceInfo(
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_LOCAL, /* minVolume= */ 0, /* maxVolume= */ 2))
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_LOCAL).setMaxVolume(2).build())
.build();
remoteSession.setPlayer(playerConfig);
......
......@@ -673,8 +673,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
handler.postAndSync(
() -> {
remotePlayer.deviceInfo =
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
remotePlayer.deviceVolume = 23;
session.setPlayer(remotePlayer);
});
......@@ -702,8 +701,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
handler.postAndSync(
() -> {
remotePlayer.deviceInfo =
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
remotePlayer.deviceVolume = 23;
session.setPlayer(remotePlayer);
});
......@@ -735,8 +733,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
handler.postAndSync(
() -> {
remotePlayer.deviceInfo =
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
remotePlayer.deviceVolume = 23;
session.setPlayer(remotePlayer);
});
......@@ -761,8 +758,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
handler.postAndSync(
() -> {
remotePlayer.deviceInfo =
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
remotePlayer.deviceVolume = 23;
session.setPlayer(remotePlayer);
});
......@@ -792,8 +788,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
handler.postAndSync(
() -> {
remotePlayer.deviceInfo =
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
remotePlayer.deviceVolume = 23;
session.setPlayer(remotePlayer);
});
......@@ -819,8 +814,7 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
handler.postAndSync(
() -> {
remotePlayer.deviceInfo =
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
remotePlayer.deviceVolume = 23;
session.setPlayer(remotePlayer);
});
......
......@@ -279,7 +279,7 @@ public class MediaSessionPermissionTest {
.build();
// Set remote device info to ensure we also cover the volume provider compat setup.
mockPlayer.deviceInfo =
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
Player player =
new ForwardingPlayer(mockPlayer) {
@Override
......
......@@ -842,8 +842,7 @@ public class MediaSessionPlayerTest {
.postAndSync(
() -> {
player.deviceInfo =
new DeviceInfo(
DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 100);
new DeviceInfo.Builder(DeviceInfo.PLAYBACK_TYPE_REMOTE).setMaxVolume(100).build();
player.notifyDeviceInfoChanged();
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment