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() {
|
||||
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.
|
||||
Intent intent = new Intent(MediaSessionService.SERVICE_INTERFACE);
|
||||
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
|
||||
// bound service. But there had been request for the feature for system apps
|
||||
// and using bindService() will be better fit with it.
|
||||
boolean result =
|
||||
context.bindService(
|
||||
intent,
|
||||
serviceConnection,
|
||||
Context.BIND_AUTO_CREATE | Context.BIND_INCLUDE_CAPABILITIES);
|
||||
boolean result = context.bindService(intent, serviceConnection, flags);
|
||||
if (!result) {
|
||||
Log.w(TAG, "bind to " + token + " failed");
|
||||
return false;
|
||||
|
@ -2026,11 +2026,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||
PlayerInfo playerInfo =
|
||||
new PlayerInfo(
|
||||
/* playerError= */ playerError,
|
||||
/* mediaItemTransitionReason= */ C.INDEX_UNSET,
|
||||
/* mediaItemTransitionReason= */ PlayerInfo.MEDIA_ITEM_TRANSITION_REASON_DEFAULT,
|
||||
/* sessionPositionInfo= */ sessionPositionInfo,
|
||||
/* oldPositionInfo= */ SessionPositionInfo.DEFAULT_POSITION_INFO,
|
||||
/* newPositionInfo= */ SessionPositionInfo.DEFAULT_POSITION_INFO,
|
||||
/* discontinuityReason= */ C.INDEX_UNSET,
|
||||
/* discontinuityReason= */ PlayerInfo.DISCONTINUITY_REASON_DEFAULT,
|
||||
/* playbackParameters= */ playbackParameters,
|
||||
/* repeatMode= */ repeatMode,
|
||||
/* shuffleModeEnabled= */ shuffleModeEnabled,
|
||||
@ -2044,8 +2044,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||
/* deviceVolume= */ deviceVolume,
|
||||
/* deviceMuted= */ deviceMuted,
|
||||
/* playWhenReady= */ playWhenReady,
|
||||
/* playWhenReadyChangedReason= */ C.INDEX_UNSET,
|
||||
/* playbackSuppressionReason= */ C.INDEX_UNSET,
|
||||
/* playWhenReadyChangedReason= */ PlayerInfo.PLAY_WHEN_READY_CHANGE_REASON_DEFAULT,
|
||||
/* playbackSuppressionReason= */ Player.PLAYBACK_SUPPRESSION_REASON_NONE,
|
||||
/* playbackState= */ playbackState,
|
||||
/* isPlaying= */ isPlaying,
|
||||
/* isLoading= */ false,
|
||||
|
@ -1132,6 +1132,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||
}
|
||||
|
||||
/** 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(
|
||||
@Nullable AudioAttributesCompat audioAttributesCompat) {
|
||||
if (audioAttributesCompat == null) {
|
||||
|
@ -398,10 +398,6 @@ public class PlayerNotificationManager {
|
||||
"androidx.media3.session.notificaiton.EXTRA_INSTANCE_ID";
|
||||
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";
|
||||
|
||||
// Internal messages.
|
||||
@ -1033,14 +1029,14 @@ public class PlayerNotificationManager {
|
||||
.appendPath(button.sessionCommand == null ? "null" : button.sessionCommand.customAction)
|
||||
.build();
|
||||
intent.setData(intentUri);
|
||||
return PendingIntent.getBroadcast(context, instanceId, intent, PENDING_INTENT_FLAGS);
|
||||
return PendingIntent.getBroadcast(context, instanceId, intent, getPendingIntentFlags());
|
||||
}
|
||||
|
||||
private static PendingIntent createBroadcastIntent(
|
||||
Context context, String action, int instanceId) {
|
||||
Intent intent = new Intent(action).setPackage(context.getPackageName());
|
||||
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")
|
||||
@ -1048,6 +1044,12 @@ public class PlayerNotificationManager {
|
||||
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 {
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user