正在查看: CallApp v2.226 应用的 PlayerNotificationManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: CallApp v2.226 应用的 PlayerNotificationManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.bidmachine.media3.ui;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.media.session.MediaSession;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v4.media.session.MediaSessionCompat;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.core.app.r;
import io.bidmachine.media3.common.AudioAttributes;
import io.bidmachine.media3.common.C;
import io.bidmachine.media3.common.DeviceInfo;
import io.bidmachine.media3.common.MediaItem;
import io.bidmachine.media3.common.MediaMetadata;
import io.bidmachine.media3.common.Metadata;
import io.bidmachine.media3.common.PlaybackException;
import io.bidmachine.media3.common.PlaybackParameters;
import io.bidmachine.media3.common.Player;
import io.bidmachine.media3.common.Timeline;
import io.bidmachine.media3.common.TrackSelectionParameters;
import io.bidmachine.media3.common.Tracks;
import io.bidmachine.media3.common.VideoSize;
import io.bidmachine.media3.common.text.Cue;
import io.bidmachine.media3.common.text.CueGroup;
import io.bidmachine.media3.common.util.Assertions;
import io.bidmachine.media3.common.util.NotificationUtil;
import io.bidmachine.media3.common.util.UnstableApi;
import io.bidmachine.media3.common.util.Util;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@UnstableApi
public class PlayerNotificationManager {
private static final String ACTION_DISMISS = "io.bidmachine.media3.ui.notification.dismiss";
public static final String ACTION_FAST_FORWARD = "io.bidmachine.media3.ui.notification.ffwd";
public static final String ACTION_NEXT = "io.bidmachine.media3.ui.notification.next";
public static final String ACTION_PAUSE = "io.bidmachine.media3.ui.notification.pause";
public static final String ACTION_PLAY = "io.bidmachine.media3.ui.notification.play";
public static final String ACTION_PREVIOUS = "io.bidmachine.media3.ui.notification.prev";
public static final String ACTION_REWIND = "io.bidmachine.media3.ui.notification.rewind";
public static final String ACTION_STOP = "io.bidmachine.media3.ui.notification.stop";
public static final String EXTRA_INSTANCE_ID = "INSTANCE_ID";
private static final int MSG_START_OR_UPDATE_NOTIFICATION = 1;
private static final int MSG_UPDATE_NOTIFICATION_BITMAP = 2;
private static int instanceIdCounter;
private int badgeIconType;
@Nullable
private NotificationCompat.h builder;
@Nullable
private List<NotificationCompat.a> builderActions;
private final String channelId;
private int color;
private boolean colorized;
private final Context context;
private int currentNotificationTag;
@Nullable
private final CustomActionReceiver customActionReceiver;
private final Map<String, NotificationCompat.a> customActions;
private int defaults;
private final PendingIntent dismissPendingIntent;
@Nullable
private String groupKey;
private final int instanceId;
private final IntentFilter intentFilter;
private boolean isNotificationStarted;
private final Handler mainHandler;
private final MediaDescriptionAdapter mediaDescriptionAdapter;
@Nullable
private MediaSession.Token mediaSessionToken;
private final b notificationBroadcastReceiver;
private final int notificationId;
@Nullable
private final NotificationListener notificationListener;
private final r notificationManager;
private final Map<String, NotificationCompat.a> playbackActions;
@Nullable
private Player player;
private final Player.Listener playerListener;
private int priority;
private boolean showPlayButtonIfSuppressed;
private int smallIconResourceId;
private boolean useChronometer;
private boolean useFastForwardAction;
private boolean useFastForwardActionInCompactView;
private boolean useNextAction;
private boolean useNextActionInCompactView;
private boolean usePlayPauseActions;
private boolean usePreviousAction;
private boolean usePreviousActionInCompactView;
private boolean useRewindAction;
private boolean useRewindActionInCompactView;
private boolean useStopAction;
private int visibility;
public final class BitmapCallback {
private final int notificationTag;
public void onBitmap(Bitmap bitmap) {
if (bitmap != null) {
PlayerNotificationManager.this.postUpdateNotificationBitmap(bitmap, this.notificationTag);
}
}
private BitmapCallback(int i) {
this.notificationTag = i;
}
}
public interface CustomActionReceiver {
Map<String, NotificationCompat.a> createCustomActions(Context context, int i);
List<String> getCustomActions(Player player);
void onCustomAction(Player player, String str, Intent intent);
}
public interface MediaDescriptionAdapter {
@Nullable
PendingIntent createCurrentContentIntent(Player player);
@Nullable
CharSequence getCurrentContentText(Player player);
CharSequence getCurrentContentTitle(Player player);
@Nullable
Bitmap getCurrentLargeIcon(Player player, BitmapCallback bitmapCallback);
@Nullable
default CharSequence getCurrentSubText(Player player) {
return null;
}
}
public interface NotificationListener {
default void onNotificationCancelled(int i, boolean z) {
}
default void onNotificationPosted(int i, Notification notification, boolean z) {
}
}
@Target({ElementType.TYPE_USE})
@Documented
@Retention(RetentionPolicy.SOURCE)
public @interface Priority {
}
@Target({ElementType.TYPE_USE})
@Documented
@Retention(RetentionPolicy.SOURCE)
public @interface Visibility {
}
public static final class a extends NotificationCompat.m {
private final int[] actionsToShowInCompact;
@Nullable
private final MediaSession.Token token;
public a(@Nullable MediaSession.Token token, int[] iArr) {
this.token = token;
this.actionsToShowInCompact = iArr;
}
public void apply(androidx.core.app.n nVar) {
Notification.MediaStyle mediaStyle = new Notification.MediaStyle();
mediaStyle.setShowActionsInCompactView(this.actionsToShowInCompact);
MediaSession.Token token = this.token;
if (token != null) {
mediaStyle.setMediaSession(token);
}
((androidx.core.app.p) nVar).b.setStyle(mediaStyle);
}
}
public class b extends BroadcastReceiver {
private b() {
}
@Override
public void onReceive(Context context, Intent intent) {
Player player = PlayerNotificationManager.this.player;
if (player != null && PlayerNotificationManager.this.isNotificationStarted && intent.getIntExtra(PlayerNotificationManager.EXTRA_INSTANCE_ID, PlayerNotificationManager.this.instanceId) == PlayerNotificationManager.this.instanceId) {
String action = intent.getAction();
if (PlayerNotificationManager.ACTION_PLAY.equals(action)) {
Util.handlePlayButtonAction(player);
return;
}
if (PlayerNotificationManager.ACTION_PAUSE.equals(action)) {
Util.handlePauseButtonAction(player);
return;
}
if (PlayerNotificationManager.ACTION_PREVIOUS.equals(action)) {
if (player.isCommandAvailable(7)) {
player.seekToPrevious();
return;
}
return;
}
if (PlayerNotificationManager.ACTION_REWIND.equals(action)) {
if (player.isCommandAvailable(11)) {
player.seekBack();
return;
}
return;
}
if (PlayerNotificationManager.ACTION_FAST_FORWARD.equals(action)) {
if (player.isCommandAvailable(12)) {
player.seekForward();
return;
}
return;
}
if (PlayerNotificationManager.ACTION_NEXT.equals(action)) {
if (player.isCommandAvailable(9)) {
player.seekToNext();
return;
}
return;
}
if (PlayerNotificationManager.ACTION_STOP.equals(action)) {
if (player.isCommandAvailable(3)) {
player.stop();
}
if (player.isCommandAvailable(20)) {
player.clearMediaItems();
return;
}
return;
}
if (PlayerNotificationManager.ACTION_DISMISS.equals(action)) {
PlayerNotificationManager.this.stopNotification(true);
} else {
if (action == null || PlayerNotificationManager.this.customActionReceiver == null || !PlayerNotificationManager.this.customActions.containsKey(action)) {
return;
}
PlayerNotificationManager.this.customActionReceiver.onCustomAction(player, action, intent);
}
}
}
}
public class c implements Player.Listener {
private c() {
}
@Override
public void onAudioAttributesChanged(AudioAttributes audioAttributes) {
super.onAudioAttributesChanged(audioAttributes);
}
@Override
@UnstableApi
public void onAudioSessionIdChanged(int i) {
super.onAudioSessionIdChanged(i);
}
@Override
public void onAvailableCommandsChanged(Player.Commands commands) {
super.onAvailableCommandsChanged(commands);
}
@Override
public void onCues(CueGroup cueGroup) {
super.onCues(cueGroup);
}
@Override
public void onDeviceInfoChanged(DeviceInfo deviceInfo) {
super.onDeviceInfoChanged(deviceInfo);
}
@Override
public void onDeviceVolumeChanged(int i, boolean z) {
super.onDeviceVolumeChanged(i, z);
}
@Override
public void onEvents(Player player, Player.Events events) {
if (events.containsAny(4, 5, 7, 0, 12, 11, 8, 9, 14)) {
PlayerNotificationManager.this.postStartOrUpdateNotification();
}
}
@Override
public void onIsLoadingChanged(boolean z) {
super.onIsLoadingChanged(z);
}
@Override
public void onIsPlayingChanged(boolean z) {
super.onIsPlayingChanged(z);
}
@Override
@UnstableApi
@Deprecated
public void onLoadingChanged(boolean z) {
super.onLoadingChanged(z);
}
@Override
public void onMaxSeekToPreviousPositionChanged(long j) {
super.onMaxSeekToPreviousPositionChanged(j);
}
@Override
public void onMediaItemTransition(@Nullable MediaItem mediaItem, int i) {
super.onMediaItemTransition(mediaItem, i);
}
@Override
public void onMediaMetadataChanged(MediaMetadata mediaMetadata) {
super.onMediaMetadataChanged(mediaMetadata);
}
@Override
@UnstableApi
public void onMetadata(Metadata metadata) {
super.onMetadata(metadata);
}
@Override
public void onPlayWhenReadyChanged(boolean z, int i) {
super.onPlayWhenReadyChanged(z, i);
}
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
super.onPlaybackParametersChanged(playbackParameters);
}
@Override
public void onPlaybackStateChanged(int i) {
super.onPlaybackStateChanged(i);
}
@Override
public void onPlaybackSuppressionReasonChanged(int i) {
super.onPlaybackSuppressionReasonChanged(i);
}
@Override
public void onPlayerError(PlaybackException playbackException) {
super.onPlayerError(playbackException);
}
@Override
public void onPlayerErrorChanged(@Nullable PlaybackException playbackException) {
super.onPlayerErrorChanged(playbackException);
}
@Override
@UnstableApi
@Deprecated
public void onPlayerStateChanged(boolean z, int i) {
super.onPlayerStateChanged(z, i);
}
@Override
public void onPlaylistMetadataChanged(MediaMetadata mediaMetadata) {
super.onPlaylistMetadataChanged(mediaMetadata);
}
@Override
@UnstableApi
@Deprecated
public void onPositionDiscontinuity(int i) {
super.onPositionDiscontinuity(i);
}
@Override
public void onRenderedFirstFrame() {
super.onRenderedFirstFrame();
}
@Override
public void onRepeatModeChanged(int i) {
super.onRepeatModeChanged(i);
}
@Override
public void onSeekBackIncrementChanged(long j) {
super.onSeekBackIncrementChanged(j);
}
@Override
public void onSeekForwardIncrementChanged(long j) {
super.onSeekForwardIncrementChanged(j);
}
@Override
public void onShuffleModeEnabledChanged(boolean z) {
super.onShuffleModeEnabledChanged(z);
}
@Override
public void onSkipSilenceEnabledChanged(boolean z) {
super.onSkipSilenceEnabledChanged(z);
}
@Override
public void onSurfaceSizeChanged(int i, int i2) {
super.onSurfaceSizeChanged(i, i2);
}
@Override
public void onTimelineChanged(Timeline timeline, int i) {
super.onTimelineChanged(timeline, i);
}
@Override
public void onTrackSelectionParametersChanged(TrackSelectionParameters trackSelectionParameters) {
super.onTrackSelectionParametersChanged(trackSelectionParameters);
}
@Override
public void onTracksChanged(Tracks tracks) {
super.onTracksChanged(tracks);
}
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
super.onVideoSizeChanged(videoSize);
}
@Override
public void onVolumeChanged(float f) {
super.onVolumeChanged(f);
}
@Override
@UnstableApi
@Deprecated
public void onCues(List list) {
super.onCues((List<Cue>) list);
}
@Override
public void onPositionDiscontinuity(Player.PositionInfo positionInfo, Player.PositionInfo positionInfo2, int i) {
super.onPositionDiscontinuity(positionInfo, positionInfo2, i);
}
}
public PlayerNotificationManager(Context context, String str, int i, MediaDescriptionAdapter mediaDescriptionAdapter, @Nullable NotificationListener notificationListener, @Nullable CustomActionReceiver customActionReceiver, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, @Nullable String str2) {
Context applicationContext = context.getApplicationContext();
this.context = applicationContext;
this.channelId = str;
this.notificationId = i;
this.mediaDescriptionAdapter = mediaDescriptionAdapter;
this.notificationListener = notificationListener;
this.customActionReceiver = customActionReceiver;
this.smallIconResourceId = i2;
this.groupKey = str2;
int i10 = instanceIdCounter;
instanceIdCounter = i10 + 1;
this.instanceId = i10;
this.mainHandler = Util.createHandler(Looper.getMainLooper(), new b2.o(this, 6));
this.notificationManager = r.a(applicationContext);
this.playerListener = new c();
this.notificationBroadcastReceiver = new b();
this.intentFilter = new IntentFilter();
this.usePreviousAction = true;
this.useNextAction = true;
this.usePlayPauseActions = true;
this.showPlayButtonIfSuppressed = true;
this.useRewindAction = true;
this.useFastForwardAction = true;
this.colorized = true;
this.useChronometer = true;
this.color = 0;
this.defaults = 0;
this.priority = -1;
this.badgeIconType = 1;
this.visibility = 1;
Map<String, NotificationCompat.a> createPlaybackActions = createPlaybackActions(applicationContext, i10, i3, i4, i5, i6, i7, i8, i9);
this.playbackActions = createPlaybackActions;
Iterator<String> it = createPlaybackActions.keySet().iterator();
while (it.hasNext()) {
this.intentFilter.addAction(it.next());
}
Map<String, NotificationCompat.a> createCustomActions = customActionReceiver != null ? customActionReceiver.createCustomActions(applicationContext, this.instanceId) : Collections.EMPTY_MAP;
this.customActions = createCustomActions;
Iterator<String> it2 = createCustomActions.keySet().iterator();
while (it2.hasNext()) {
this.intentFilter.addAction(it2.next());
}
this.dismissPendingIntent = createBroadcastIntent(ACTION_DISMISS, applicationContext, this.instanceId);
this.intentFilter.addAction(ACTION_DISMISS);
}
private static PendingIntent createBroadcastIntent(String str, Context context, int i) {
Intent intent = new Intent(str).setPackage(context.getPackageName());
intent.putExtra(EXTRA_INSTANCE_ID, i);
return PendingIntent.getBroadcast(context, i, intent, Util.SDK_INT >= 23 ? 201326592 : C.BUFFER_FLAG_FIRST_SAMPLE);
}
private static Map<String, NotificationCompat.a> createPlaybackActions(Context context, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
HashMap hashMap = new HashMap();
hashMap.put(ACTION_PLAY, new NotificationCompat.a(i2, context.getString(R.string.exo_controls_play_description), createBroadcastIntent(ACTION_PLAY, context, i)));
hashMap.put(ACTION_PAUSE, new NotificationCompat.a(i3, context.getString(R.string.exo_controls_pause_description), createBroadcastIntent(ACTION_PAUSE, context, i)));
hashMap.put(ACTION_STOP, new NotificationCompat.a(i4, context.getString(R.string.exo_controls_stop_description), createBroadcastIntent(ACTION_STOP, context, i)));
hashMap.put(ACTION_REWIND, new NotificationCompat.a(i5, context.getString(R.string.exo_controls_rewind_description), createBroadcastIntent(ACTION_REWIND, context, i)));
hashMap.put(ACTION_FAST_FORWARD, new NotificationCompat.a(i6, context.getString(R.string.exo_controls_fastforward_description), createBroadcastIntent(ACTION_FAST_FORWARD, context, i)));
hashMap.put(ACTION_PREVIOUS, new NotificationCompat.a(i7, context.getString(R.string.exo_controls_previous_description), createBroadcastIntent(ACTION_PREVIOUS, context, i)));
hashMap.put(ACTION_NEXT, new NotificationCompat.a(i8, context.getString(R.string.exo_controls_next_description), createBroadcastIntent(ACTION_NEXT, context, i)));
return hashMap;
}
public boolean handleMessage(Message message) {
int i = message.what;
if (i == 1) {
Player player = this.player;
if (player != null) {
startOrUpdateNotification(player, null);
}
} else {
if (i != 2) {
return false;
}
Player player2 = this.player;
if (player2 != null && this.isNotificationStarted && this.currentNotificationTag == message.arg1) {
startOrUpdateNotification(player2, (Bitmap) message.obj);
}
}
return true;
}
public void postStartOrUpdateNotification() {
if (this.mainHandler.hasMessages(1)) {
return;
}
this.mainHandler.sendEmptyMessage(1);
}
public void postUpdateNotificationBitmap(Bitmap bitmap, int i) {
this.mainHandler.obtainMessage(2, i, -1, bitmap).sendToTarget();
}
private static void setLargeIcon(NotificationCompat.h hVar, @Nullable Bitmap bitmap) {
hVar.j(bitmap);
}
private void startOrUpdateNotification(Player player, @Nullable Bitmap bitmap) {
boolean ongoing = getOngoing(player);
NotificationCompat.h createNotification = createNotification(player, this.builder, ongoing, bitmap);
this.builder = createNotification;
if (createNotification == null) {
stopNotification(false);
return;
}
Notification b2 = createNotification.b();
r rVar = this.notificationManager;
int i = this.notificationId;
rVar.getClass();
Bundle extras = NotificationCompat.getExtras(b2);
NotificationManager notificationManager = rVar.b;
if (extras == null || !extras.getBoolean("android.support.useSideChannel")) {
notificationManager.notify(null, i, b2);
} else {
r.a aVar = new r.a(rVar.a.getPackageName(), i, (String) null, b2);
synchronized (r.f) {
try {
if (r.g == null) {
r.g = new r.c(rVar.a.getApplicationContext());
}
r.g.b.obtainMessage(0, aVar).sendToTarget();
} catch (Throwable th) {
throw th;
}
}
notificationManager.cancel(null, i);
}
if (!this.isNotificationStarted) {
Util.registerReceiverNotExported(this.context, this.notificationBroadcastReceiver, this.intentFilter);
}
NotificationListener notificationListener = this.notificationListener;
if (notificationListener != null) {
notificationListener.onNotificationPosted(this.notificationId, b2, ongoing || !this.isNotificationStarted);
}
this.isNotificationStarted = true;
}
public void stopNotification(boolean z) {
if (this.isNotificationStarted) {
this.isNotificationStarted = false;
this.mainHandler.removeMessages(1);
r rVar = this.notificationManager;
rVar.b.cancel(null, this.notificationId);
this.context.unregisterReceiver(this.notificationBroadcastReceiver);
NotificationListener notificationListener = this.notificationListener;
if (notificationListener != null) {
notificationListener.onNotificationCancelled(this.notificationId, z);
}
}
}
@Nullable
public NotificationCompat.h createNotification(Player player, @Nullable NotificationCompat.h hVar, boolean z, @Nullable Bitmap bitmap) {
if (player.getPlaybackState() == 1 && player.isCommandAvailable(17) && player.getCurrentTimeline().isEmpty()) {
this.builderActions = null;
return null;
}
List<String> actions = getActions(player);
ArrayList arrayList = new ArrayList(actions.size());
for (int i = 0; i < actions.size(); i++) {
String str = actions.get(i);
NotificationCompat.a aVar = this.playbackActions.containsKey(str) ? this.playbackActions.get(str) : this.customActions.get(str);
if (aVar != null) {
arrayList.add(aVar);
}
}
if (hVar == null || !arrayList.equals(this.builderActions)) {
hVar = new NotificationCompat.h(this.context, this.channelId);
this.builderActions = arrayList;
for (int i2 = 0; i2 < arrayList.size(); i2++) {
hVar.a((NotificationCompat.a) arrayList.get(i2));
}
}
int[] actionIndicesForCompactView = getActionIndicesForCompactView(actions, player);
int i3 = Util.SDK_INT;
if (i3 >= 21) {
hVar.l(new a(this.mediaSessionToken, actionIndicesForCompactView));
} else {
x1.c cVar = new x1.c();
cVar.a = actionIndicesForCompactView;
hVar.l(cVar);
}
PendingIntent pendingIntent = this.dismissPendingIntent;
Notification notification = hVar.Q;
notification.deleteIntent = pendingIntent;
hVar.J = this.badgeIconType;
hVar.i(2, z);
hVar.D = this.color;
hVar.z = this.colorized;
hVar.A = true;
notification.icon = this.smallIconResourceId;
hVar.E = this.visibility;
hVar.l = this.priority;
hVar.h(this.defaults);
if (i3 >= 21 && this.useChronometer && player.isCommandAvailable(16) && player.isPlaying() && !player.isPlayingAd() && !player.isCurrentMediaItemDynamic() && player.getPlaybackParameters().speed == 1.0f) {
notification.when = System.currentTimeMillis() - player.getContentPosition();
hVar.m = true;
hVar.n = true;
} else {
hVar.m = false;
hVar.n = false;
}
hVar.g(this.mediaDescriptionAdapter.getCurrentContentTitle(player));
hVar.f(this.mediaDescriptionAdapter.getCurrentContentText(player));
hVar.q = NotificationCompat.h.d(this.mediaDescriptionAdapter.getCurrentSubText(player));
if (bitmap == null) {
MediaDescriptionAdapter mediaDescriptionAdapter = this.mediaDescriptionAdapter;
int i4 = this.currentNotificationTag + 1;
this.currentNotificationTag = i4;
bitmap = mediaDescriptionAdapter.getCurrentLargeIcon(player, new BitmapCallback(i4));
}
setLargeIcon(hVar, bitmap);
hVar.g = this.mediaDescriptionAdapter.createCurrentContentIntent(player);
String str2 = this.groupKey;
if (str2 != null) {
hVar.v = str2;
}
hVar.i(8, true);
return hVar;
}
public int[] getActionIndicesForCompactView(java.util.List<java.lang.String> r7, io.bidmachine.media3.common.Player r8) {
throw new UnsupportedOperationException("Method not decompiled: io.bidmachine.media3.ui.PlayerNotificationManager.getActionIndicesForCompactView(java.util.List, io.bidmachine.media3.common.Player):int[]");
}
public List<String> getActions(Player player) {
boolean isCommandAvailable = player.isCommandAvailable(7);
boolean isCommandAvailable2 = player.isCommandAvailable(11);
boolean isCommandAvailable3 = player.isCommandAvailable(12);
boolean isCommandAvailable4 = player.isCommandAvailable(9);
ArrayList arrayList = new ArrayList();
if (this.usePreviousAction && isCommandAvailable) {
arrayList.add(ACTION_PREVIOUS);
}
if (this.useRewindAction && isCommandAvailable2) {
arrayList.add(ACTION_REWIND);
}
if (this.usePlayPauseActions) {
if (Util.shouldShowPlayButton(player, this.showPlayButtonIfSuppressed)) {
arrayList.add(ACTION_PLAY);
} else {
arrayList.add(ACTION_PAUSE);
}
}
if (this.useFastForwardAction && isCommandAvailable3) {
arrayList.add(ACTION_FAST_FORWARD);
}
if (this.useNextAction && isCommandAvailable4) {
arrayList.add(ACTION_NEXT);
}
CustomActionReceiver customActionReceiver = this.customActionReceiver;
if (customActionReceiver != null) {
arrayList.addAll(customActionReceiver.getCustomActions(player));
}
if (this.useStopAction) {
arrayList.add(ACTION_STOP);
}
return arrayList;
}
public boolean getOngoing(Player player) {
int playbackState = player.getPlaybackState();
return (playbackState == 2 || playbackState == 3) && player.getPlayWhenReady();
}
public final void invalidate() {
if (this.isNotificationStarted) {
postStartOrUpdateNotification();
}
}
public final void setBadgeIconType(int i) {
if (this.badgeIconType == i) {
return;
}
if (i != 0 && i != 1 && i != 2) {
throw new IllegalArgumentException();
}
this.badgeIconType = i;
invalidate();
}
public final void setColor(int i) {
if (this.color != i) {
this.color = i;
invalidate();
}
}
public final void setColorized(boolean z) {
if (this.colorized != z) {
this.colorized = z;
invalidate();
}
}
public final void setDefaults(int i) {
if (this.defaults != i) {
this.defaults = i;
invalidate();
}
}
@Deprecated
public final void setMediaSessionToken(MediaSessionCompat.Token token) {
if (Util.SDK_INT >= 21) {
setMediaSessionToken((MediaSession.Token) token.getToken());
}
}
public final void setPlayer(@Nullable Player player) {
boolean z = true;
Assertions.checkState(Looper.myLooper() == Looper.getMainLooper());
if (player != null && player.getApplicationLooper() != Looper.getMainLooper()) {
z = false;
}
Assertions.checkArgument(z);
Player player2 = this.player;
if (player2 == player) {
return;
}
if (player2 != null) {
player2.removeListener(this.playerListener);
if (player == null) {
stopNotification(false);
}
}
this.player = player;
if (player != null) {
player.addListener(this.playerListener);
postStartOrUpdateNotification();
}
}
public final void setPriority(int i) {
if (this.priority == i) {
return;
}
if (i != -2 && i != -1 && i != 0 && i != 1 && i != 2) {
throw new IllegalArgumentException();
}
this.priority = i;
invalidate();
}
public void setShowPlayButtonIfPlaybackIsSuppressed(boolean z) {
if (this.showPlayButtonIfSuppressed != z) {
this.showPlayButtonIfSuppressed = z;
invalidate();
}
}
public final void setSmallIcon(int i) {
if (this.smallIconResourceId != i) {
this.smallIconResourceId = i;
invalidate();
}
}
public final void setUseChronometer(boolean z) {
if (this.useChronometer != z) {
this.useChronometer = z;
invalidate();
}
}
public final void setUseFastForwardAction(boolean z) {
if (this.useFastForwardAction != z) {
this.useFastForwardAction = z;
invalidate();
}
}
public final void setUseFastForwardActionInCompactView(boolean z) {
if (this.useFastForwardActionInCompactView != z) {
this.useFastForwardActionInCompactView = z;
if (z) {
this.useNextActionInCompactView = false;
}
invalidate();
}
}
public final void setUseNextAction(boolean z) {
if (this.useNextAction != z) {
this.useNextAction = z;
invalidate();
}
}
public final void setUseNextActionInCompactView(boolean z) {
if (this.useNextActionInCompactView != z) {
this.useNextActionInCompactView = z;
if (z) {
this.useFastForwardActionInCompactView = false;
}
invalidate();
}
}
public final void setUsePlayPauseActions(boolean z) {
if (this.usePlayPauseActions != z) {
this.usePlayPauseActions = z;
invalidate();
}
}
public final void setUsePreviousAction(boolean z) {
if (this.usePreviousAction != z) {
this.usePreviousAction = z;
invalidate();
}
}
public final void setUsePreviousActionInCompactView(boolean z) {
if (this.usePreviousActionInCompactView != z) {
this.usePreviousActionInCompactView = z;
if (z) {
this.useRewindActionInCompactView = false;
}
invalidate();
}
}
public final void setUseRewindAction(boolean z) {
if (this.useRewindAction != z) {
this.useRewindAction = z;
invalidate();
}
}
public final void setUseRewindActionInCompactView(boolean z) {
if (this.useRewindActionInCompactView != z) {
this.useRewindActionInCompactView = z;
if (z) {
this.usePreviousActionInCompactView = false;
}
invalidate();
}
}
public final void setUseStopAction(boolean z) {
if (this.useStopAction == z) {
return;
}
this.useStopAction = z;
invalidate();
}
public final void setVisibility(int i) {
if (this.visibility == i) {
return;
}
if (i != -1 && i != 0 && i != 1) {
throw new IllegalStateException();
}
this.visibility = i;
invalidate();
}
public static class Builder {
protected int channelDescriptionResourceId;
protected final String channelId;
protected int channelImportance;
protected int channelNameResourceId;
protected final Context context;
@Nullable
protected CustomActionReceiver customActionReceiver;
protected int fastForwardActionIconResourceId;
@Nullable
protected String groupKey;
protected MediaDescriptionAdapter mediaDescriptionAdapter;
protected int nextActionIconResourceId;
protected final int notificationId;
@Nullable
protected NotificationListener notificationListener;
protected int pauseActionIconResourceId;
protected int playActionIconResourceId;
protected int previousActionIconResourceId;
protected int rewindActionIconResourceId;
protected int smallIconResourceId;
protected int stopActionIconResourceId;
@Deprecated
public Builder(Context context, int i, String str, MediaDescriptionAdapter mediaDescriptionAdapter) {
this(context, i, str);
this.mediaDescriptionAdapter = mediaDescriptionAdapter;
}
public PlayerNotificationManager build() {
int i = this.channelNameResourceId;
if (i != 0) {
NotificationUtil.createNotificationChannel(this.context, this.channelId, i, this.channelDescriptionResourceId, this.channelImportance);
}
return new PlayerNotificationManager(this.context, this.channelId, this.notificationId, this.mediaDescriptionAdapter, this.notificationListener, this.customActionReceiver, this.smallIconResourceId, this.playActionIconResourceId, this.pauseActionIconResourceId, this.stopActionIconResourceId, this.rewindActionIconResourceId, this.fastForwardActionIconResourceId, this.previousActionIconResourceId, this.nextActionIconResourceId, this.groupKey);
}
public Builder setChannelDescriptionResourceId(int i) {
this.channelDescriptionResourceId = i;
return this;
}
public Builder setChannelImportance(int i) {
this.channelImportance = i;
return this;
}
public Builder setChannelNameResourceId(int i) {
this.channelNameResourceId = i;
return this;
}
public Builder setCustomActionReceiver(CustomActionReceiver customActionReceiver) {
this.customActionReceiver = customActionReceiver;
return this;
}
public Builder setFastForwardActionIconResourceId(int i) {
this.fastForwardActionIconResourceId = i;
return this;
}
public Builder setGroup(String str) {
this.groupKey = str;
return this;
}
public Builder setMediaDescriptionAdapter(MediaDescriptionAdapter mediaDescriptionAdapter) {
this.mediaDescriptionAdapter = mediaDescriptionAdapter;
return this;
}
public Builder setNextActionIconResourceId(int i) {
this.nextActionIconResourceId = i;
return this;
}
public Builder setNotificationListener(NotificationListener notificationListener) {
this.notificationListener = notificationListener;
return this;
}
public Builder setPauseActionIconResourceId(int i) {
this.pauseActionIconResourceId = i;
return this;
}
public Builder setPlayActionIconResourceId(int i) {
this.playActionIconResourceId = i;
return this;
}
public Builder setPreviousActionIconResourceId(int i) {
this.previousActionIconResourceId = i;
return this;
}
public Builder setRewindActionIconResourceId(int i) {
this.rewindActionIconResourceId = i;
return this;
}
public Builder setSmallIconResourceId(int i) {
this.smallIconResourceId = i;
return this;
}
public Builder setStopActionIconResourceId(int i) {
this.stopActionIconResourceId = i;
return this;
}
public Builder(Context context, int i, String str) {
Assertions.checkArgument(i > 0);
this.context = context;
this.notificationId = i;
this.channelId = str;
this.channelImportance = 2;
this.mediaDescriptionAdapter = new DefaultMediaDescriptionAdapter(null);
this.smallIconResourceId = R.drawable.exo_notification_small_icon;
this.playActionIconResourceId = R.drawable.exo_notification_play;
this.pauseActionIconResourceId = R.drawable.exo_notification_pause;
this.stopActionIconResourceId = R.drawable.exo_notification_stop;
this.rewindActionIconResourceId = R.drawable.exo_notification_rewind;
this.fastForwardActionIconResourceId = R.drawable.exo_notification_fastforward;
this.previousActionIconResourceId = R.drawable.exo_notification_previous;
this.nextActionIconResourceId = R.drawable.exo_notification_next;
}
}
public final void setMediaSessionToken(MediaSession.Token token) {
if (Util.areEqual(this.mediaSessionToken, token)) {
return;
}
this.mediaSessionToken = token;
invalidate();
}
}