mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Remove unneeded @Nullable from PlayerWrapper.legacyExtras
All values passed in via the constructor or setLegacyExtras are guaranteed to be non-null. PiperOrigin-RevId: 687245475 (cherry picked from commit 5fffe033121a75386e7132e8245b63becc85550a)
This commit is contained in:
parent
88a78ade04
commit
e6c24087f8
@ -85,7 +85,7 @@ import java.util.List;
|
||||
|
||||
private final boolean playIfSuppressed;
|
||||
@Nullable private LegacyError legacyError;
|
||||
@Nullable private Bundle legacyExtras;
|
||||
private Bundle legacyExtras;
|
||||
private ImmutableList<CommandButton> customLayout;
|
||||
private ImmutableList<CommandButton> mediaButtonPreferences;
|
||||
private SessionCommands availableSessionCommands;
|
||||
@ -98,7 +98,7 @@ import java.util.List;
|
||||
ImmutableList<CommandButton> mediaButtonPreferences,
|
||||
SessionCommands availableSessionCommands,
|
||||
Commands availablePlayerCommands,
|
||||
@Nullable Bundle legacyExtras) {
|
||||
Bundle legacyExtras) {
|
||||
super(player);
|
||||
this.playIfSuppressed = playIfSuppressed;
|
||||
this.customLayout = customLayout;
|
||||
@ -138,15 +138,12 @@ import java.util.List;
|
||||
return mediaButtonPreferences;
|
||||
}
|
||||
|
||||
public void setLegacyExtras(@Nullable Bundle extras) {
|
||||
if (extras != null) {
|
||||
public void setLegacyExtras(Bundle extras) {
|
||||
checkArgument(!extras.containsKey(EXTRAS_KEY_PLAYBACK_SPEED_COMPAT));
|
||||
checkArgument(!extras.containsKey(EXTRAS_KEY_MEDIA_ID_COMPAT));
|
||||
}
|
||||
this.legacyExtras = extras;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Bundle getLegacyExtras() {
|
||||
return legacyExtras;
|
||||
}
|
||||
@ -1020,9 +1017,7 @@ import java.util.List;
|
||||
LegacyError legacyError = this.legacyError;
|
||||
if (legacyError != null && legacyError.isFatal) {
|
||||
Bundle extras = new Bundle(legacyError.extras);
|
||||
if (legacyExtras != null) {
|
||||
extras.putAll(legacyExtras);
|
||||
}
|
||||
return new PlaybackStateCompat.Builder()
|
||||
.setState(
|
||||
PlaybackStateCompat.STATE_ERROR,
|
||||
@ -1052,9 +1047,7 @@ import java.util.List;
|
||||
float playbackSpeed = getPlaybackParameters().speed;
|
||||
float sessionPlaybackSpeed = isPlaying() ? playbackSpeed : 0f;
|
||||
Bundle extras = legacyError != null ? new Bundle(legacyError.extras) : new Bundle();
|
||||
if (legacyExtras != null && !legacyExtras.isEmpty()) {
|
||||
extras.putAll(legacyExtras);
|
||||
}
|
||||
extras.putFloat(EXTRAS_KEY_PLAYBACK_SPEED_COMPAT, playbackSpeed);
|
||||
@Nullable MediaItem currentMediaItem = getCurrentMediaItemWithCommandCheck();
|
||||
if (currentMediaItem != null && !MediaItem.DEFAULT_MEDIA_ID.equals(currentMediaItem.mediaId)) {
|
||||
|
@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@ -51,7 +52,7 @@ public class PlayerWrapperTest {
|
||||
/* mediaButtonPreferences= */ ImmutableList.of(),
|
||||
SessionCommands.EMPTY,
|
||||
Player.Commands.EMPTY,
|
||||
/* legacyExtras= */ null);
|
||||
/* legacyExtras= */ Bundle.EMPTY);
|
||||
when(player.isCommandAvailable(anyInt())).thenReturn(true);
|
||||
when(player.getApplicationLooper()).thenReturn(Looper.myLooper());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user