package androidx.media3.session;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.session.MediaSession;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.DeviceInfo;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaMetadata;
import androidx.media3.common.PlaybackException;
import androidx.media3.common.PlaybackParameters;
import androidx.media3.common.Player;
import androidx.media3.common.Rating;
import androidx.media3.common.Timeline;
import androidx.media3.common.TrackSelectionParameters;
import androidx.media3.common.Tracks;
import androidx.media3.common.VideoSize;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import androidx.media3.datasource.DataSourceBitmapLoader;
import androidx.media3.session.MediaLibraryService;
import androidx.media3.session.MediaSession;
import androidx.media3.session.SessionCommands;
import androidx.media3.session.legacy.MediaSessionManager;
import defpackage.bj4;
import defpackage.hs0;
import defpackage.if7;
import defpackage.ks3;
import defpackage.l18;
import defpackage.pm2;
import defpackage.qj5;
import defpackage.qv;
import defpackage.qy3;
import defpackage.rq6;
import defpackage.sma;
import defpackage.xd2;
import defpackage.zb5;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
@xd2
public class MediaSession {
    private final MediaSessionImpl impl;
    private static final Object STATIC_LOCK = new Object();

    @qy3
    private static final HashMap<String, MediaSession> SESSION_ID_TO_SESSION_MAP = new HashMap<>();

    @l18
    public static final class Api31 {
        private Api31() {
        }

        public static boolean isActivity(PendingIntent pendingIntent) {
            return pendingIntent.isActivity();
        }
    }

    public static final class Builder extends BuilderBase<MediaSession, Builder, Callback> {
        private boolean useLegacySurfaceHandling;

        public Builder(Context context, Player player) {
            super(context, player, new Callback() { // from class: androidx.media3.session.MediaSession.Builder.1
            });
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        public MediaSession build() {
            ensureBitmapLoaderIsSizeLimited();
            return new MediaSession(this.context, this.id, this.player, this.sessionActivity, this.customLayout, this.mediaButtonPreferences, this.commandButtonsForMediaItems, this.callback, this.tokenExtras, this.sessionExtras, this.bitmapLoader, this.playIfSuppressed, this.isPeriodicPositionUpdateEnabled, 0, this.useLegacySurfaceHandling);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @UnstableApi
        public /* bridge */ /* synthetic */ BuilderBase setCommandButtonsForMediaItems(List list) {
            return setCommandButtonsForMediaItems((List<CommandButton>) list);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @hs0
        @UnstableApi
        public /* bridge */ /* synthetic */ BuilderBase setCustomLayout(List list) {
            return setCustomLayout((List<CommandButton>) list);
        }

        @hs0
        @UnstableApi
        public Builder setExperimentalSetUseLegacySurfaceHandling(boolean z) {
            this.useLegacySurfaceHandling = z;
            return this;
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @hs0
        @UnstableApi
        public /* bridge */ /* synthetic */ BuilderBase setMediaButtonPreferences(List list) {
            return setMediaButtonPreferences((List<CommandButton>) list);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @UnstableApi
        public Builder setBitmapLoader(androidx.media3.common.util.BitmapLoader bitmapLoader) {
            return (Builder) super.setBitmapLoader(bitmapLoader);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        public Builder setCallback(Callback callback) {
            return (Builder) super.setCallback(callback);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @UnstableApi
        public Builder setCommandButtonsForMediaItems(List<CommandButton> list) {
            return (Builder) super.setCommandButtonsForMediaItems(list);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @hs0
        @UnstableApi
        public Builder setCustomLayout(List<CommandButton> list) {
            return (Builder) super.setCustomLayout(list);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        public Builder setExtras(Bundle bundle) {
            return (Builder) super.setExtras(bundle);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        public Builder setId(String str) {
            return (Builder) super.setId(str);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @hs0
        @UnstableApi
        public Builder setMediaButtonPreferences(List<CommandButton> list) {
            return (Builder) super.setMediaButtonPreferences(list);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @UnstableApi
        public Builder setPeriodicPositionUpdateEnabled(boolean z) {
            return (Builder) super.setPeriodicPositionUpdateEnabled(z);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        public Builder setSessionActivity(PendingIntent pendingIntent) {
            return (Builder) super.setSessionActivity(pendingIntent);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        public Builder setSessionExtras(Bundle bundle) {
            return (Builder) super.setSessionExtras(bundle);
        }

        @Override // androidx.media3.session.MediaSession.BuilderBase
        @UnstableApi
        public Builder setShowPlayButtonIfPlaybackIsSuppressed(boolean z) {
            return (Builder) super.setShowPlayButtonIfPlaybackIsSuppressed(z);
        }
    }

    public static abstract class BuilderBase<SessionT extends MediaSession, BuilderT extends BuilderBase<SessionT, BuilderT, CallbackT>, CallbackT extends Callback> {
        androidx.media3.common.util.BitmapLoader bitmapLoader;
        CallbackT callback;
        bj4<CommandButton> commandButtonsForMediaItems;
        final Context context;
        bj4<CommandButton> customLayout;
        String id;
        boolean isPeriodicPositionUpdateEnabled;
        bj4<CommandButton> mediaButtonPreferences;
        boolean playIfSuppressed;
        final Player player;

        @rq6
        PendingIntent sessionActivity;
        Bundle sessionExtras;
        Bundle tokenExtras;

        public BuilderBase(Context context, Player player, CallbackT callbackt) {
            context.getClass();
            this.context = context;
            player.getClass();
            this.player = player;
            if7.e(player.canAdvertiseSession());
            this.id = "";
            this.callback = callbackt;
            this.tokenExtras = new Bundle();
            this.sessionExtras = new Bundle();
            this.customLayout = bj4.p();
            this.mediaButtonPreferences = bj4.p();
            this.playIfSuppressed = true;
            this.isPeriodicPositionUpdateEnabled = true;
            this.commandButtonsForMediaItems = bj4.p();
        }

        public abstract SessionT build();

        @pm2
        public final void ensureBitmapLoaderIsSizeLimited() {
            int bitmapDimensionLimit = MediaSession.getBitmapDimensionLimit(this.context);
            androidx.media3.common.util.BitmapLoader bitmapLoader = this.bitmapLoader;
            if (bitmapLoader == null) {
                this.bitmapLoader = new CacheBitmapLoader(new DataSourceBitmapLoader.Builder(this.context).setMaximumOutputDimension(bitmapDimensionLimit).setMakeShared(true).build());
            } else {
                this.bitmapLoader = new SizeLimitedBitmapLoader(bitmapLoader, bitmapDimensionLimit, true);
            }
        }

        @hs0
        public BuilderT setBitmapLoader(androidx.media3.common.util.BitmapLoader bitmapLoader) {
            bitmapLoader.getClass();
            this.bitmapLoader = bitmapLoader;
            return this;
        }

        @hs0
        public BuilderT setCallback(CallbackT callbackt) {
            callbackt.getClass();
            this.callback = callbackt;
            return this;
        }

        @hs0
        public BuilderT setCommandButtonsForMediaItems(List<CommandButton> list) {
            this.commandButtonsForMediaItems = bj4.l(list);
            return this;
        }

        @hs0
        public BuilderT setCustomLayout(List<CommandButton> list) {
            this.customLayout = bj4.l(list);
            return this;
        }

        @hs0
        public BuilderT setExtras(Bundle bundle) {
            bundle.getClass();
            this.tokenExtras = new Bundle(bundle);
            return this;
        }

        @hs0
        public BuilderT setId(String str) {
            str.getClass();
            this.id = str;
            return this;
        }

        @hs0
        public BuilderT setMediaButtonPreferences(List<CommandButton> list) {
            this.mediaButtonPreferences = bj4.l(list);
            return this;
        }

        @hs0
        public BuilderT setPeriodicPositionUpdateEnabled(boolean z) {
            this.isPeriodicPositionUpdateEnabled = z;
            return this;
        }

        @hs0
        public BuilderT setSessionActivity(PendingIntent pendingIntent) {
            if (Build.VERSION.SDK_INT >= 31) {
                if7.e(Api31.isActivity(pendingIntent));
            }
            pendingIntent.getClass();
            this.sessionActivity = pendingIntent;
            return this;
        }

        @hs0
        public BuilderT setSessionExtras(Bundle bundle) {
            bundle.getClass();
            this.sessionExtras = new Bundle(bundle);
            return this;
        }

        @hs0
        public BuilderT setShowPlayButtonIfPlaybackIsSuppressed(boolean z) {
            this.playIfSuppressed = z;
            return this;
        }
    }

    public interface Callback {
        /* JADX INFO: Access modifiers changed from: private */
        static /* synthetic */ zb5 lambda$onSetMediaItems$0(int i, long j, List list) throws Exception {
            return ks3.d(new MediaItemsWithStartPosition(list, i, j));
        }

        default zb5<List<MediaItem>> onAddMediaItems(MediaSession mediaSession, ControllerInfo controllerInfo, List<MediaItem> list) {
            Iterator<MediaItem> it = list.iterator();
            while (it.hasNext()) {
                if (it.next().localConfiguration == null) {
                    return ks3.c(new UnsupportedOperationException());
                }
            }
            return ks3.d(list);
        }

        default ConnectionResult onConnect(MediaSession mediaSession, ControllerInfo controllerInfo) {
            return new ConnectionResult.AcceptedResultBuilder(mediaSession).build();
        }

        default zb5<SessionResult> onCustomCommand(MediaSession mediaSession, ControllerInfo controllerInfo, SessionCommand sessionCommand, Bundle bundle) {
            return ks3.d(new SessionResult(-6));
        }

        default void onDisconnected(MediaSession mediaSession, ControllerInfo controllerInfo) {
        }

        @UnstableApi
        default boolean onMediaButtonEvent(MediaSession mediaSession, ControllerInfo controllerInfo, Intent intent) {
            return false;
        }

        @UnstableApi
        @Deprecated
        default zb5<MediaItemsWithStartPosition> onPlaybackResumption(MediaSession mediaSession, ControllerInfo controllerInfo) {
            return ks3.c(new UnsupportedOperationException());
        }

        @Deprecated
        default int onPlayerCommandRequest(MediaSession mediaSession, ControllerInfo controllerInfo, int i) {
            return 0;
        }

        @UnstableApi
        default void onPlayerInteractionFinished(MediaSession mediaSession, ControllerInfo controllerInfo, Player.Commands commands) {
        }

        default void onPostConnect(MediaSession mediaSession, ControllerInfo controllerInfo) {
        }

        @UnstableApi
        default zb5<MediaItemsWithStartPosition> onSetMediaItems(MediaSession mediaSession, ControllerInfo controllerInfo, List<MediaItem> list, final int i, final long j) {
            return Util.transformFutureAsync(onAddMediaItems(mediaSession, controllerInfo, list), new qv() { // from class: dt5
                @Override // defpackage.qv
                public final zb5 apply(Object obj) {
                    return MediaSession.Callback.lambda$onSetMediaItems$0(i, j, (List) obj);
                }
            });
        }

        default zb5<SessionResult> onSetRating(MediaSession mediaSession, ControllerInfo controllerInfo, String str, Rating rating) {
            return ks3.d(new SessionResult(-6));
        }

        @UnstableApi
        default zb5<SessionResult> onCustomCommand(MediaSession mediaSession, ControllerInfo controllerInfo, SessionCommand sessionCommand, Bundle bundle, @rq6 ProgressReporter progressReporter) {
            return onCustomCommand(mediaSession, controllerInfo, sessionCommand, bundle);
        }

        @UnstableApi
        default zb5<MediaItemsWithStartPosition> onPlaybackResumption(MediaSession mediaSession, ControllerInfo controllerInfo, boolean z) {
            return onPlaybackResumption(mediaSession, controllerInfo);
        }

        default zb5<SessionResult> onSetRating(MediaSession mediaSession, ControllerInfo controllerInfo, Rating rating) {
            return ks3.d(new SessionResult(-6));
        }
    }

    public static final class ConnectionResult {
        public final Player.Commands availablePlayerCommands;
        public final SessionCommands availableSessionCommands;

        @rq6
        @UnstableApi
        public final bj4<CommandButton> customLayout;
        public final boolean isAccepted;

        @rq6
        @UnstableApi
        public final bj4<CommandButton> mediaButtonPreferences;

        @rq6
        @UnstableApi
        public final PendingIntent sessionActivity;

        @rq6
        @UnstableApi
        public final Bundle sessionExtras;

        @UnstableApi
        public static final SessionCommands DEFAULT_SESSION_COMMANDS = new SessionCommands.Builder().addAllSessionCommands().build();

        @UnstableApi
        public static final SessionCommands DEFAULT_SESSION_AND_LIBRARY_COMMANDS = new SessionCommands.Builder().addAllLibraryCommands().addAllSessionCommands().build();

        @UnstableApi
        public static final Player.Commands DEFAULT_PLAYER_COMMANDS = new Player.Commands.Builder().addAllCommands().build();

        @UnstableApi
        public static class AcceptedResultBuilder {
            private Player.Commands availablePlayerCommands = ConnectionResult.DEFAULT_PLAYER_COMMANDS;
            private SessionCommands availableSessionCommands;

            @rq6
            private bj4<CommandButton> customLayout;

            @rq6
            private bj4<CommandButton> mediaButtonPreferences;

            @rq6
            private PendingIntent sessionActivity;

            @rq6
            private Bundle sessionExtras;

            public AcceptedResultBuilder(MediaSession mediaSession) {
                this.availableSessionCommands = mediaSession instanceof MediaLibraryService.MediaLibrarySession ? ConnectionResult.DEFAULT_SESSION_AND_LIBRARY_COMMANDS : ConnectionResult.DEFAULT_SESSION_COMMANDS;
            }

            public ConnectionResult build() {
                return new ConnectionResult(true, this.availableSessionCommands, this.availablePlayerCommands, this.customLayout, this.mediaButtonPreferences, this.sessionExtras, this.sessionActivity);
            }

            @hs0
            public AcceptedResultBuilder setAvailablePlayerCommands(Player.Commands commands) {
                commands.getClass();
                this.availablePlayerCommands = commands;
                return this;
            }

            @hs0
            public AcceptedResultBuilder setAvailableSessionCommands(SessionCommands sessionCommands) {
                sessionCommands.getClass();
                this.availableSessionCommands = sessionCommands;
                return this;
            }

            @hs0
            public AcceptedResultBuilder setCustomLayout(@rq6 List<CommandButton> list) {
                this.customLayout = list == null ? null : bj4.l(list);
                return this;
            }

            @hs0
            public AcceptedResultBuilder setMediaButtonPreferences(@rq6 List<CommandButton> list) {
                this.mediaButtonPreferences = list == null ? null : bj4.l(list);
                return this;
            }

            @hs0
            public AcceptedResultBuilder setSessionActivity(@rq6 PendingIntent pendingIntent) {
                this.sessionActivity = pendingIntent;
                return this;
            }

            @hs0
            public AcceptedResultBuilder setSessionExtras(Bundle bundle) {
                this.sessionExtras = bundle;
                return this;
            }
        }

        public static ConnectionResult accept(SessionCommands sessionCommands, Player.Commands commands) {
            return new ConnectionResult(true, sessionCommands, commands, null, null, null, null);
        }

        public static ConnectionResult reject() {
            return new ConnectionResult(false, SessionCommands.EMPTY, Player.Commands.EMPTY, bj4.p(), bj4.p(), Bundle.EMPTY, null);
        }

        private ConnectionResult(boolean z, SessionCommands sessionCommands, Player.Commands commands, @rq6 bj4<CommandButton> bj4Var, @rq6 bj4<CommandButton> bj4Var2, @rq6 Bundle bundle, @rq6 PendingIntent pendingIntent) {
            this.isAccepted = z;
            this.availableSessionCommands = sessionCommands;
            this.availablePlayerCommands = commands;
            this.customLayout = bj4Var;
            this.mediaButtonPreferences = bj4Var2;
            this.sessionExtras = bundle;
            this.sessionActivity = pendingIntent;
        }
    }

    public interface ControllerCb {
        default void onAudioAttributesChanged(int i, AudioAttributes audioAttributes) throws RemoteException {
        }

        default void onAudioSessionIdChanged(int i, int i2) throws RemoteException {
        }

        default void onAvailableCommandsChangedFromPlayer(int i, Player.Commands commands) throws RemoteException {
        }

        default void onAvailableCommandsChangedFromSession(int i, SessionCommands sessionCommands, Player.Commands commands) throws RemoteException {
        }

        default void onChildrenChanged(int i, String str, int i2, @rq6 MediaLibraryService.LibraryParams libraryParams) throws RemoteException {
        }

        default void onDeviceInfoChanged(int i, DeviceInfo deviceInfo) throws RemoteException {
        }

        default void onDeviceVolumeChanged(int i, int i2, boolean z) throws RemoteException {
        }

        default void onDisconnected(int i) {
        }

        default void onError(int i, SessionError sessionError) throws RemoteException {
        }

        default void onIsLoadingChanged(int i, boolean z) throws RemoteException {
        }

        default void onIsPlayingChanged(int i, boolean z) throws RemoteException {
        }

        default void onLibraryResult(int i, LibraryResult<?> libraryResult) throws RemoteException {
        }

        default void onMediaItemTransition(int i, @rq6 MediaItem mediaItem, int i2) throws RemoteException {
        }

        default void onMediaMetadataChanged(int i, MediaMetadata mediaMetadata) throws RemoteException {
        }

        default void onPeriodicSessionPositionInfoChanged(int i, SessionPositionInfo sessionPositionInfo, boolean z, boolean z2, int i2) throws RemoteException {
        }

        default void onPlayWhenReadyChanged(int i, boolean z, int i2) throws RemoteException {
        }

        default void onPlaybackParametersChanged(int i, PlaybackParameters playbackParameters) throws RemoteException {
        }

        default void onPlaybackStateChanged(int i, int i2, @rq6 PlaybackException playbackException) throws RemoteException {
        }

        default void onPlaybackSuppressionReasonChanged(int i, int i2) throws RemoteException {
        }

        default void onPlayerChanged(int i, @rq6 PlayerWrapper playerWrapper, PlayerWrapper playerWrapper2) throws RemoteException {
        }

        default void onPlayerError(int i, @rq6 PlaybackException playbackException) throws RemoteException {
        }

        default void onPlayerInfoChanged(int i, PlayerInfo playerInfo, Player.Commands commands, boolean z, boolean z2) throws RemoteException {
        }

        default void onPlaylistMetadataChanged(int i, MediaMetadata mediaMetadata) throws RemoteException {
        }

        default void onPositionDiscontinuity(int i, Player.PositionInfo positionInfo, Player.PositionInfo positionInfo2, int i2) throws RemoteException {
        }

        default void onRenderedFirstFrame(int i) throws RemoteException {
        }

        default void onRepeatModeChanged(int i, int i2) throws RemoteException {
        }

        default void onSearchResultChanged(int i, String str, int i2, @rq6 MediaLibraryService.LibraryParams libraryParams) throws RemoteException {
        }

        default void onSeekBackIncrementChanged(int i, long j) throws RemoteException {
        }

        default void onSeekForwardIncrementChanged(int i, long j) throws RemoteException {
        }

        default void onSessionActivityChanged(int i, @rq6 PendingIntent pendingIntent) throws RemoteException {
        }

        default void onSessionExtrasChanged(int i, Bundle bundle) throws RemoteException {
        }

        default void onSessionResult(int i, SessionResult sessionResult) throws RemoteException {
        }

        default void onShuffleModeEnabledChanged(int i, boolean z) throws RemoteException {
        }

        default void onSurfaceSizeChanged(int i, int i2, int i3) throws RemoteException {
        }

        default void onTimelineChanged(int i, Timeline timeline, int i2) throws RemoteException {
        }

        default void onTrackSelectionParametersChanged(int i, TrackSelectionParameters trackSelectionParameters) throws RemoteException {
        }

        default void onTracksChanged(int i, Tracks tracks) throws RemoteException {
        }

        default void onVideoSizeChanged(int i, VideoSize videoSize) throws RemoteException {
        }

        default void onVolumeChanged(int i, float f) throws RemoteException {
        }

        default void sendCustomCommand(int i, SessionCommand sessionCommand, Bundle bundle) throws RemoteException {
        }

        default void sendCustomCommandProgressUpdate(int i, SessionCommand sessionCommand, Bundle bundle, Bundle bundle2) throws RemoteException {
        }

        default void setCustomLayout(int i, List<CommandButton> list) throws RemoteException {
        }

        default void setMediaButtonPreferences(int i, List<CommandButton> list) throws RemoteException {
        }
    }

    public static final class ControllerInfo {

        @UnstableApi
        public static final int LEGACY_CONTROLLER_INTERFACE_VERSION = 0;
        public static final String LEGACY_CONTROLLER_PACKAGE_NAME = "android.media.session.MediaController";
        public static final int LEGACY_CONTROLLER_VERSION = 0;
        private final Bundle connectionHints;

        @rq6
        private final ControllerCb controllerCb;
        private final int interfaceVersion;
        private final boolean isPackageNameVerified;
        private final boolean isTrusted;
        private final int libraryVersion;
        private final int maxCommandsForMediaItems;
        private final MediaSessionManager.RemoteUserInfo remoteUserInfo;

        public ControllerInfo(MediaSessionManager.RemoteUserInfo remoteUserInfo, int i, int i2, boolean z, @rq6 ControllerCb controllerCb, Bundle bundle, int i3, boolean z2) {
            this.remoteUserInfo = remoteUserInfo;
            this.libraryVersion = i;
            this.interfaceVersion = i2;
            this.isTrusted = z;
            this.controllerCb = controllerCb;
            this.connectionHints = bundle;
            this.maxCommandsForMediaItems = i3;
            this.isPackageNameVerified = z2;
        }

        public static ControllerInfo createLegacyControllerInfo() {
            return new ControllerInfo(new MediaSessionManager.RemoteUserInfo("android.media.session.MediaController", -1, -1), 0, 0, false, null, Bundle.EMPTY, 0, false);
        }

        @sma
        @UnstableApi
        public static ControllerInfo createTestOnlyControllerInfo(String str, int i, int i2, int i3, int i4, boolean z, Bundle bundle, boolean z2) {
            return new ControllerInfo(new MediaSessionManager.RemoteUserInfo(str, i, i2), i3, i4, z, null, bundle, 0, z2);
        }

        public boolean equals(@rq6 Object obj) {
            if (!(obj instanceof ControllerInfo)) {
                return false;
            }
            if (this == obj) {
                return true;
            }
            ControllerInfo controllerInfo = (ControllerInfo) obj;
            ControllerCb controllerCb = this.controllerCb;
            return (controllerCb == null && controllerInfo.controllerCb == null) ? this.remoteUserInfo.equals(controllerInfo.remoteUserInfo) : Objects.equals(controllerCb, controllerInfo.controllerCb);
        }

        public Bundle getConnectionHints() {
            return new Bundle(this.connectionHints);
        }

        @rq6
        public ControllerCb getControllerCb() {
            return this.controllerCb;
        }

        public int getControllerVersion() {
            return this.libraryVersion;
        }

        @UnstableApi
        public int getInterfaceVersion() {
            return this.interfaceVersion;
        }

        @UnstableApi
        public int getMaxCommandsForMediaItems() {
            return this.maxCommandsForMediaItems;
        }

        public String getPackageName() {
            return this.remoteUserInfo.getPackageName();
        }

        public MediaSessionManager.RemoteUserInfo getRemoteUserInfo() {
            return this.remoteUserInfo;
        }

        public int getUid() {
            return this.remoteUserInfo.getUid();
        }

        public int hashCode() {
            return Objects.hash(this.controllerCb, this.remoteUserInfo);
        }

        @UnstableApi
        public boolean isPackageNameVerified() {
            return this.isPackageNameVerified;
        }

        @UnstableApi
        public boolean isTrusted() {
            return this.isTrusted;
        }

        public String toString() {
            return "ControllerInfo {pkg=" + this.remoteUserInfo.getPackageName() + ", uid=" + this.remoteUserInfo.getUid() + "}";
        }
    }

    public interface Listener {
        void onNotificationRefreshRequired(MediaSession mediaSession);

        boolean onPlayRequested(MediaSession mediaSession);
    }

    @UnstableApi
    public static final class MediaItemsWithStartPosition {
        public final bj4<MediaItem> mediaItems;
        public final int startIndex;
        public final long startPositionMs;

        public MediaItemsWithStartPosition(List<MediaItem> list, int i, long j) {
            this.mediaItems = bj4.l(list);
            this.startIndex = i;
            this.startPositionMs = j;
        }

        public boolean equals(@rq6 Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof MediaItemsWithStartPosition)) {
                return false;
            }
            MediaItemsWithStartPosition mediaItemsWithStartPosition = (MediaItemsWithStartPosition) obj;
            return this.mediaItems.equals(mediaItemsWithStartPosition.mediaItems) && this.startIndex == mediaItemsWithStartPosition.startIndex && this.startPositionMs == mediaItemsWithStartPosition.startPositionMs;
        }

        public int hashCode() {
            return qj5.b(this.startPositionMs) + (((this.mediaItems.hashCode() * 31) + this.startIndex) * 31);
        }
    }

    @UnstableApi
    public interface ProgressReporter {
        void sendProgressUpdate(Bundle bundle);
    }

    public MediaSession(Context context, String str, Player player, @rq6 PendingIntent pendingIntent, bj4<CommandButton> bj4Var, bj4<CommandButton> bj4Var2, bj4<CommandButton> bj4Var3, Callback callback, Bundle bundle, Bundle bundle2, androidx.media3.common.util.BitmapLoader bitmapLoader, boolean z, boolean z2, int i, boolean z3) {
        synchronized (STATIC_LOCK) {
            HashMap<String, MediaSession> map = SESSION_ID_TO_SESSION_MAP;
            if (map.containsKey(str)) {
                throw new IllegalStateException("Session ID must be unique. ID=" + str);
            }
            map.put(str, this);
        }
        this.impl = createImpl(context, str, player, pendingIntent, bj4Var, bj4Var2, bj4Var3, callback, bundle, bundle2, bitmapLoader, z, z2, i, z3);
    }

    public static int getBitmapDimensionLimit(Context context) {
        return MediaSessionImpl.getBitmapDimensionLimit(context);
    }

    @rq6
    public static MediaSession getSession(Uri uri) {
        synchronized (STATIC_LOCK) {
            try {
                for (MediaSession mediaSession : SESSION_ID_TO_SESSION_MAP.values()) {
                    if (Objects.equals(mediaSession.getUri(), uri)) {
                        return mediaSession;
                    }
                }
                return null;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void broadcastCustomCommand(SessionCommand sessionCommand, Bundle bundle) {
        sessionCommand.getClass();
        bundle.getClass();
        if7.f(sessionCommand.commandCode == 0, "command must be a custom command");
        this.impl.broadcastCustomCommand(sessionCommand, bundle);
    }

    public final void clearListener() {
        this.impl.clearMediaSessionListener();
    }

    public MediaSessionImpl createImpl(Context context, String str, Player player, @rq6 PendingIntent pendingIntent, bj4<CommandButton> bj4Var, bj4<CommandButton> bj4Var2, bj4<CommandButton> bj4Var3, Callback callback, Bundle bundle, Bundle bundle2, androidx.media3.common.util.BitmapLoader bitmapLoader, boolean z, boolean z2, int i, boolean z3) {
        return new MediaSessionImpl(this, context, str, player, pendingIntent, bj4Var, bj4Var2, bj4Var3, callback, bundle, bundle2, bitmapLoader, z, z2, z3);
    }

    @UnstableApi
    public final androidx.media3.common.util.BitmapLoader getBitmapLoader() {
        return this.impl.getBitmapLoader();
    }

    public final List<ControllerInfo> getConnectedControllers() {
        return this.impl.getConnectedControllers();
    }

    @rq6
    public final ControllerInfo getControllerForCurrentRequest() {
        return this.impl.getControllerForCurrentRequest();
    }

    @UnstableApi
    public bj4<CommandButton> getCustomLayout() {
        return this.impl.getCustomLayout();
    }

    public final String getId() {
        return this.impl.getId();
    }

    public MediaSessionImpl getImpl() {
        return this.impl;
    }

    @rq6
    public final IBinder getLegacyBrowserServiceBinder() {
        return this.impl.getLegacyBrowserServiceBinder();
    }

    @UnstableApi
    public bj4<CommandButton> getMediaButtonPreferences() {
        return this.impl.getMediaButtonPreferences();
    }

    @rq6
    @UnstableApi
    public ControllerInfo getMediaNotificationControllerInfo() {
        return this.impl.getMediaNotificationControllerInfo();
    }

    @UnstableApi
    public final MediaSession.Token getPlatformToken() {
        return this.impl.getPlatformToken();
    }

    public final Player getPlayer() {
        return this.impl.getPlayerWrapper().getWrappedPlayer();
    }

    @rq6
    public final PendingIntent getSessionActivity() {
        return this.impl.getSessionActivity();
    }

    public Bundle getSessionExtras() {
        return this.impl.getSessionExtras();
    }

    @UnstableApi
    public final boolean getShowPlayButtonIfPlaybackIsSuppressed() {
        return this.impl.shouldPlayIfSuppressed();
    }

    public final SessionToken getToken() {
        return this.impl.getToken();
    }

    @sma
    public final Uri getUri() {
        return this.impl.getUri();
    }

    public final void handleControllerConnectionFromService(IMediaController iMediaController, ControllerInfo controllerInfo) {
        this.impl.connectFromService(iMediaController, controllerInfo);
    }

    @UnstableApi
    public final boolean isAutoCompanionController(ControllerInfo controllerInfo) {
        return this.impl.isAutoCompanionController(controllerInfo);
    }

    @UnstableApi
    public final boolean isAutomotiveController(ControllerInfo controllerInfo) {
        return this.impl.isAutomotiveController(controllerInfo);
    }

    @UnstableApi
    public boolean isMediaNotificationController(ControllerInfo controllerInfo) {
        return this.impl.isMediaNotificationController(controllerInfo);
    }

    public final boolean isReleased() {
        return this.impl.isReleased();
    }

    public final void release() {
        try {
            synchronized (STATIC_LOCK) {
                SESSION_ID_TO_SESSION_MAP.remove(this.impl.getId());
            }
            this.impl.release();
        } catch (Exception unused) {
        }
    }

    public final zb5<SessionResult> sendCustomCommand(ControllerInfo controllerInfo, SessionCommand sessionCommand, Bundle bundle) {
        controllerInfo.getClass();
        sessionCommand.getClass();
        bundle.getClass();
        if7.f(sessionCommand.commandCode == 0, "command must be a custom command");
        return this.impl.sendCustomCommand(controllerInfo, sessionCommand, bundle);
    }

    @UnstableApi
    public final void sendError(ControllerInfo controllerInfo, SessionError sessionError) {
        this.impl.sendError(controllerInfo, sessionError);
    }

    public final void setAvailableCommands(ControllerInfo controllerInfo, SessionCommands sessionCommands, Player.Commands commands) {
        if7.l(controllerInfo, "controller must not be null");
        if7.l(sessionCommands, "sessionCommands must not be null");
        if7.l(commands, "playerCommands must not be null");
        this.impl.setAvailableCommands(controllerInfo, sessionCommands, commands);
    }

    @hs0
    public final zb5<SessionResult> setCustomLayout(ControllerInfo controllerInfo, List<CommandButton> list) {
        if7.l(controllerInfo, "controller must not be null");
        if7.l(list, "layout must not be null");
        return this.impl.setCustomLayout(controllerInfo, bj4.l(list));
    }

    public final void setLegacyControllerConnectionTimeoutMs(long j) {
        this.impl.setLegacyControllerConnectionTimeoutMs(j);
    }

    public final void setListener(Listener listener) {
        this.impl.setMediaSessionListener(listener);
    }

    @hs0
    @UnstableApi
    public final zb5<SessionResult> setMediaButtonPreferences(ControllerInfo controllerInfo, List<CommandButton> list) {
        if7.l(controllerInfo, "controller must not be null");
        if7.l(list, "media button preferences must not be null");
        return this.impl.setMediaButtonPreferences(controllerInfo, bj4.l(list));
    }

    @UnstableApi
    public final void setPlaybackException(ControllerInfo controllerInfo, @rq6 PlaybackException playbackException) {
        this.impl.setPlaybackException(controllerInfo, playbackException);
    }

    public final void setPlayer(Player player) {
        player.getClass();
        if7.e(player.canAdvertiseSession());
        if7.e(player.getApplicationLooper() == getPlayer().getApplicationLooper());
        if7.o(player.getApplicationLooper() == Looper.myLooper());
        this.impl.setPlayer(player);
    }

    @UnstableApi
    public final void setSessionActivity(@rq6 PendingIntent pendingIntent) {
        if (Build.VERSION.SDK_INT >= 31 && pendingIntent != null) {
            if7.e(Api31.isActivity(pendingIntent));
        }
        this.impl.setSessionActivity(pendingIntent);
    }

    public final void setSessionExtras(Bundle bundle) {
        this.impl.setSessionExtras(new Bundle(bundle));
    }

    @sma
    public final void setSessionPositionUpdateDelayMs(long j) {
        this.impl.setSessionPositionUpdateDelayMsOnHandler(j);
    }

    @UnstableApi
    public final void sendError(SessionError sessionError) {
        this.impl.sendError(sessionError);
    }

    @UnstableApi
    public final void setPlaybackException(@rq6 PlaybackException playbackException) {
        this.impl.setPlaybackException(playbackException);
    }

    public final void setSessionExtras(ControllerInfo controllerInfo, Bundle bundle) {
        if7.l(controllerInfo, "controller must not be null");
        this.impl.setSessionExtras(controllerInfo, new Bundle(bundle));
    }

    public final void setCustomLayout(List<CommandButton> list) {
        if7.l(list, "layout must not be null");
        this.impl.setCustomLayout(bj4.l(list));
    }

    @UnstableApi
    public final void setMediaButtonPreferences(List<CommandButton> list) {
        if7.l(list, "media button preferences must not be null");
        this.impl.setMediaButtonPreferences(bj4.l(list));
    }

    @UnstableApi
    public final void setSessionActivity(ControllerInfo controllerInfo, @rq6 PendingIntent pendingIntent) {
        if (Build.VERSION.SDK_INT >= 31 && pendingIntent != null) {
            if7.e(Api31.isActivity(pendingIntent));
        }
        this.impl.setSessionActivity(controllerInfo, pendingIntent);
    }
}
