Fix lint errors

- Add required mutability flag to `ConnectionStateTest` to fix
  `Missing PendingIntent mutability flag`.
- Suppress `WrongConstant` lint error caused by Kotlin's spread operator
  not propagating the `@IntDef` annotation.

#cherrypick

PiperOrigin-RevId: 707061163
This commit is contained in:
rohks 2024-12-17 05:50:10 -08:00 committed by Copybara-Service
parent 601b025b3c
commit 4b26eb2800
2 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import android.content.Intent;
import android.os.Bundle;
import androidx.media3.common.MediaLibraryInfo;
import androidx.media3.common.Player;
import androidx.media3.common.util.Util;
import androidx.media3.test.utils.TestExoPlayerBuilder;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@ -49,7 +50,10 @@ public class ConnectionStateTest {
MediaSessionStub.VERSION_INT,
new MediaSessionStub(session.getImpl()),
/* sessionActivity= */ PendingIntent.getActivity(
context, /* requestCode= */ 0, new Intent(), /* flags= */ 0),
context,
/* requestCode= */ 0,
new Intent(),
/* flags= */ Util.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0),
/* customLayout= */ ImmutableList.of(
new CommandButton.Builder(CommandButton.ICON_ARTIST)
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)

View File

@ -116,6 +116,9 @@ internal class TestPlayer : SimpleBasePlayer(Looper.myLooper()!!) {
}
fun addCommands(vararg commands: @Player.Command Int) {
// It doesn't seem possible to propagate the @IntDef annotation through Kotlin's spread operator
// in a way that lint understands.
@SuppressWarnings("WrongConstant")
state =
state
.buildUpon()