Remove invalid command comparison
The removed check searched for a player command inside a list of session commands, which is not allowed by the IntDef definition and only worked because both types map to a Java int. PiperOrigin-RevId: 612758442
This commit is contained in:
parent
bbdaf2b092
commit
c79ac5ba21
@ -651,10 +651,9 @@ public final class CommandButton implements Bundleable {
|
||||
*/
|
||||
/* package */ static boolean isEnabled(
|
||||
CommandButton button, SessionCommands sessionCommands, Player.Commands playerCommands) {
|
||||
return playerCommands.contains(button.playerCommand)
|
||||
|| (button.sessionCommand != null && sessionCommands.contains(button.sessionCommand))
|
||||
return (button.sessionCommand != null && sessionCommands.contains(button.sessionCommand))
|
||||
|| (button.playerCommand != Player.COMMAND_INVALID
|
||||
&& sessionCommands.contains(button.playerCommand));
|
||||
&& playerCommands.contains(button.playerCommand));
|
||||
}
|
||||
|
||||
// Bundleable implementation.
|
||||
|
@ -47,23 +47,6 @@ public class CommandButtonTest {
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isEnabled_playerCommandAvailableOrUnavailableInSessionCommands_isEnabledCorrectly() {
|
||||
CommandButton button =
|
||||
new CommandButton.Builder()
|
||||
.setDisplayName("button")
|
||||
.setIconResId(R.drawable.media3_notification_small_icon)
|
||||
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
|
||||
.build();
|
||||
SessionCommands availableSessionCommands =
|
||||
SessionCommands.EMPTY.buildUpon().add(Player.COMMAND_SEEK_TO_NEXT).build();
|
||||
|
||||
assertThat(CommandButton.isEnabled(button, SessionCommands.EMPTY, Player.Commands.EMPTY))
|
||||
.isFalse();
|
||||
assertThat(CommandButton.isEnabled(button, availableSessionCommands, Player.Commands.EMPTY))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isEnabled_sessionCommandAvailableOrUnavailable_isEnabledCorrectly() {
|
||||
SessionCommand command1 = new SessionCommand("command1", Bundle.EMPTY);
|
||||
|
Loading…
x
Reference in New Issue
Block a user