Fix some additional lint warnings
PiperOrigin-RevId: 424584225
This commit is contained in:
parent
c9e2a9eb30
commit
78411006df
@ -2157,6 +2157,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean requestConnectToService() {
|
private boolean requestConnectToService() {
|
||||||
|
int flags =
|
||||||
|
Util.SDK_INT >= 29
|
||||||
|
? Context.BIND_AUTO_CREATE | Context.BIND_INCLUDE_CAPABILITIES
|
||||||
|
: Context.BIND_AUTO_CREATE;
|
||||||
|
|
||||||
// Service. Needs to get fresh binder whenever connection is needed.
|
// Service. Needs to get fresh binder whenever connection is needed.
|
||||||
Intent intent = new Intent(MediaSessionService.SERVICE_INTERFACE);
|
Intent intent = new Intent(MediaSessionService.SERVICE_INTERFACE);
|
||||||
intent.setClassName(token.getPackageName(), token.getServiceName());
|
intent.setClassName(token.getPackageName(), token.getServiceName());
|
||||||
@ -2175,11 +2180,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
// If a service wants to keep running, it should be either foreground service or
|
// If a service wants to keep running, it should be either foreground service or
|
||||||
// bound service. But there had been request for the feature for system apps
|
// bound service. But there had been request for the feature for system apps
|
||||||
// and using bindService() will be better fit with it.
|
// and using bindService() will be better fit with it.
|
||||||
boolean result =
|
boolean result = context.bindService(intent, serviceConnection, flags);
|
||||||
context.bindService(
|
|
||||||
intent,
|
|
||||||
serviceConnection,
|
|
||||||
Context.BIND_AUTO_CREATE | Context.BIND_INCLUDE_CAPABILITIES);
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
Log.w(TAG, "bind to " + token + " failed");
|
Log.w(TAG, "bind to " + token + " failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -2026,11 +2026,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
PlayerInfo playerInfo =
|
PlayerInfo playerInfo =
|
||||||
new PlayerInfo(
|
new PlayerInfo(
|
||||||
/* playerError= */ playerError,
|
/* playerError= */ playerError,
|
||||||
/* mediaItemTransitionReason= */ C.INDEX_UNSET,
|
/* mediaItemTransitionReason= */ PlayerInfo.MEDIA_ITEM_TRANSITION_REASON_DEFAULT,
|
||||||
/* sessionPositionInfo= */ sessionPositionInfo,
|
/* sessionPositionInfo= */ sessionPositionInfo,
|
||||||
/* oldPositionInfo= */ SessionPositionInfo.DEFAULT_POSITION_INFO,
|
/* oldPositionInfo= */ SessionPositionInfo.DEFAULT_POSITION_INFO,
|
||||||
/* newPositionInfo= */ SessionPositionInfo.DEFAULT_POSITION_INFO,
|
/* newPositionInfo= */ SessionPositionInfo.DEFAULT_POSITION_INFO,
|
||||||
/* discontinuityReason= */ C.INDEX_UNSET,
|
/* discontinuityReason= */ PlayerInfo.DISCONTINUITY_REASON_DEFAULT,
|
||||||
/* playbackParameters= */ playbackParameters,
|
/* playbackParameters= */ playbackParameters,
|
||||||
/* repeatMode= */ repeatMode,
|
/* repeatMode= */ repeatMode,
|
||||||
/* shuffleModeEnabled= */ shuffleModeEnabled,
|
/* shuffleModeEnabled= */ shuffleModeEnabled,
|
||||||
@ -2044,8 +2044,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
/* deviceVolume= */ deviceVolume,
|
/* deviceVolume= */ deviceVolume,
|
||||||
/* deviceMuted= */ deviceMuted,
|
/* deviceMuted= */ deviceMuted,
|
||||||
/* playWhenReady= */ playWhenReady,
|
/* playWhenReady= */ playWhenReady,
|
||||||
/* playWhenReadyChangedReason= */ C.INDEX_UNSET,
|
/* playWhenReadyChangedReason= */ PlayerInfo.PLAY_WHEN_READY_CHANGE_REASON_DEFAULT,
|
||||||
/* playbackSuppressionReason= */ C.INDEX_UNSET,
|
/* playbackSuppressionReason= */ Player.PLAYBACK_SUPPRESSION_REASON_NONE,
|
||||||
/* playbackState= */ playbackState,
|
/* playbackState= */ playbackState,
|
||||||
/* isPlaying= */ isPlaying,
|
/* isPlaying= */ isPlaying,
|
||||||
/* isLoading= */ false,
|
/* isLoading= */ false,
|
||||||
|
@ -1132,6 +1132,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Converts {@link AudioAttributesCompat} into {@link AudioAttributes}. */
|
/** Converts {@link AudioAttributesCompat} into {@link AudioAttributes}. */
|
||||||
|
/*
|
||||||
|
* @AudioAttributesCompat.AttributeUsage and @C.AudioUsage both use the same constant values,
|
||||||
|
* defined by AudioAttributes in the platform.
|
||||||
|
*/
|
||||||
|
@SuppressLint("WrongConstant")
|
||||||
public static AudioAttributes convertToAudioAttributes(
|
public static AudioAttributes convertToAudioAttributes(
|
||||||
@Nullable AudioAttributesCompat audioAttributesCompat) {
|
@Nullable AudioAttributesCompat audioAttributesCompat) {
|
||||||
if (audioAttributesCompat == null) {
|
if (audioAttributesCompat == null) {
|
||||||
|
@ -398,10 +398,6 @@ public class PlayerNotificationManager {
|
|||||||
"androidx.media3.session.notificaiton.EXTRA_INSTANCE_ID";
|
"androidx.media3.session.notificaiton.EXTRA_INSTANCE_ID";
|
||||||
private static final String INTENT_SCHEME = "media3";
|
private static final String INTENT_SCHEME = "media3";
|
||||||
|
|
||||||
private static final int PENDING_INTENT_FLAGS =
|
|
||||||
(Util.SDK_INT >= 23)
|
|
||||||
? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
|
|
||||||
: PendingIntent.FLAG_UPDATE_CURRENT;
|
|
||||||
private static final String TAG = "NotificationManager";
|
private static final String TAG = "NotificationManager";
|
||||||
|
|
||||||
// Internal messages.
|
// Internal messages.
|
||||||
@ -1033,14 +1029,14 @@ public class PlayerNotificationManager {
|
|||||||
.appendPath(button.sessionCommand == null ? "null" : button.sessionCommand.customAction)
|
.appendPath(button.sessionCommand == null ? "null" : button.sessionCommand.customAction)
|
||||||
.build();
|
.build();
|
||||||
intent.setData(intentUri);
|
intent.setData(intentUri);
|
||||||
return PendingIntent.getBroadcast(context, instanceId, intent, PENDING_INTENT_FLAGS);
|
return PendingIntent.getBroadcast(context, instanceId, intent, getPendingIntentFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PendingIntent createBroadcastIntent(
|
private static PendingIntent createBroadcastIntent(
|
||||||
Context context, String action, int instanceId) {
|
Context context, String action, int instanceId) {
|
||||||
Intent intent = new Intent(action).setPackage(context.getPackageName());
|
Intent intent = new Intent(action).setPackage(context.getPackageName());
|
||||||
intent.putExtra(INTENT_EXTRA_INSTANCE_ID, instanceId);
|
intent.putExtra(INTENT_EXTRA_INSTANCE_ID, instanceId);
|
||||||
return PendingIntent.getBroadcast(context, instanceId, intent, PENDING_INTENT_FLAGS);
|
return PendingIntent.getBroadcast(context, instanceId, intent, getPendingIntentFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("nullness:argument")
|
@SuppressWarnings("nullness:argument")
|
||||||
@ -1048,6 +1044,12 @@ public class PlayerNotificationManager {
|
|||||||
builder.setLargeIcon(largeIcon);
|
builder.setLargeIcon(largeIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getPendingIntentFlags() {
|
||||||
|
return Util.SDK_INT >= 23
|
||||||
|
? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
|
||||||
|
: PendingIntent.FLAG_UPDATE_CURRENT;
|
||||||
|
}
|
||||||
|
|
||||||
private class PlayerListener implements Player.Listener {
|
private class PlayerListener implements Player.Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user