正在查看: Bedrock Radio v1.1.1 应用的 MusicService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Bedrock Radio v1.1.1 应用的 MusicService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.doublesymmetry.trackplayer.service;
import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import androidx.core.app.NotificationCompat;
import com.doublesymmetry.kotlinaudio.event.EventHolder;
import com.doublesymmetry.kotlinaudio.models.AudioItem;
import com.doublesymmetry.kotlinaudio.models.AudioPlayerState;
import com.doublesymmetry.kotlinaudio.models.Capability;
import com.doublesymmetry.kotlinaudio.models.NotificationButton;
import com.doublesymmetry.kotlinaudio.models.NotificationConfig;
import com.doublesymmetry.kotlinaudio.models.PlaybackError;
import com.doublesymmetry.kotlinaudio.models.RepeatMode;
import com.doublesymmetry.kotlinaudio.players.QueuedAudioPlayer;
import com.doublesymmetry.trackplayer.R;
import com.doublesymmetry.trackplayer.extensions.AudioPlayerStateExtKt;
import com.doublesymmetry.trackplayer.extensions.NumberExt;
import com.doublesymmetry.trackplayer.model.Track;
import com.doublesymmetry.trackplayer.model.TrackAudioItem;
import com.doublesymmetry.trackplayer.module.MusicEvents;
import com.doublesymmetry.trackplayer.service.MusicService;
import com.doublesymmetry.trackplayer.utils.BundleUtils;
import com.facebook.react.HeadlessJsTaskService;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.horcrux.svg.TSpanView$;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;
import kotlin.Deprecated;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.PropertyReference1Impl;
import kotlin.jvm.internal.Ref;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.flow.FlowKt;
import timber.log.Timber;
@Metadata(d1 = {"\u0000®\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0010\u0006\n\u0002\b\n\n\u0002\u0010\u0007\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0018\u0002\n\u0002\b\u001d\b\u0007\u0018\u0000 \u008c\u00012\u00020\u0001:\u0006\u008b\u0001\u008c\u0001\u008d\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u00109\u001a\u00020:2\u0006\u0010;\u001a\u00020\fH\u0007J\u0016\u00109\u001a\u00020:2\f\u00106\u001a\b\u0012\u0004\u0012\u00020\f0\bH\u0007J\u001e\u00109\u001a\u00020:2\f\u00106\u001a\b\u0012\u0004\u0012\u00020\f0\b2\u0006\u0010<\u001a\u00020%H\u0007J\b\u0010=\u001a\u00020:H\u0007J\b\u0010>\u001a\u00020:H\u0007J\u001c\u0010?\u001a\u00020:2\u0006\u0010\u000f\u001a\u00020@2\n\b\u0002\u0010A\u001a\u0004\u0018\u00010\u0014H\u0003J \u0010B\u001a\u00020:2\u0006\u0010\u000f\u001a\u00020@2\u000e\b\u0002\u0010A\u001a\b\u0012\u0004\u0012\u00020\u00140\bH\u0003J)\u0010C\u001a\u00020:2\b\u0010D\u001a\u0004\u0018\u00010%2\b\u0010E\u001a\u0004\u0018\u00010%2\u0006\u0010F\u001a\u00020GH\u0002¢\u0006\u0002\u0010HJ\b\u0010I\u001a\u00020:H\u0002J\b\u0010J\u001a\u00020GH\u0007J\b\u0010K\u001a\u00020%H\u0007J\b\u0010L\u001a\u00020GH\u0007J\b\u0010M\u001a\u00020%H\u0002J\b\u0010N\u001a\u00020\u0014H\u0002J\u0010\u0010O\u001a\u00020\u00142\u0006\u0010-\u001a\u00020.H\u0007J\b\u0010P\u001a\u00020GH\u0007J\b\u0010Q\u001a\u00020RH\u0007J\b\u0010S\u001a\u00020TH\u0007J\u0012\u0010U\u001a\u00020V2\b\u0010W\u001a\u0004\u0018\u00010XH\u0014J\b\u0010Y\u001a\u00020RH\u0007J\u0010\u0010Z\u001a\u00020\u00172\u0006\u0010[\u001a\u00020\tH\u0002J\u0006\u0010\\\u001a\u00020\u0017J\u0010\u0010]\u001a\u00020:2\u0006\u0010;\u001a\u00020\fH\u0007J\u0018\u0010^\u001a\u00020:2\u0006\u0010_\u001a\u00020%2\u0006\u0010`\u001a\u00020%H\u0007J\b\u0010a\u001a\u00020:H\u0003J\u0012\u0010b\u001a\u00020c2\b\u0010W\u001a\u0004\u0018\u00010XH\u0017J\b\u0010d\u001a\u00020:H\u0017J\u0010\u0010e\u001a\u00020:2\u0006\u0010f\u001a\u00020%H\u0017J\"\u0010g\u001a\u00020%2\b\u0010W\u001a\u0004\u0018\u00010X2\u0006\u0010h\u001a\u00020%2\u0006\u0010i\u001a\u00020%H\u0016J\u0012\u0010j\u001a\u00020:2\b\u0010k\u001a\u0004\u0018\u00010XH\u0017J\b\u0010l\u001a\u00020:H\u0007J\b\u0010m\u001a\u00020:H\u0007J\u0011\u0010n\u001a\u00020\u0014H\u0083@ø\u0001\u0000¢\u0006\u0002\u0010oJ\u0016\u0010p\u001a\b\u0012\u0004\u0012\u00020\u00140q2\u0006\u0010r\u001a\u00020GH\u0003J\u0010\u0010s\u001a\u00020:2\u0006\u0010D\u001a\u00020%H\u0007J\u0016\u0010s\u001a\u00020:2\f\u0010t\u001a\b\u0012\u0004\u0012\u00020%0\bH\u0007J\b\u0010u\u001a\u00020:H\u0007J\b\u0010v\u001a\u00020:H\u0007J\b\u0010w\u001a\u00020:H\u0007J\u0010\u0010x\u001a\u00020:2\u0006\u0010y\u001a\u00020RH\u0007J\u0010\u0010z\u001a\u00020:2\u0006\u0010{\u001a\u00020RH\u0007J\u0010\u0010|\u001a\u00020:2\u0006\u0010\u0016\u001a\u00020RH\u0007J\u0010\u0010}\u001a\u00020:2\u0006\u0010\u0016\u001a\u00020TH\u0007J\u0010\u0010~\u001a\u00020:2\u0006\u0010\u0016\u001a\u00020RH\u0007J\b\u0010\u007f\u001a\u00020:H\u0003J\u0014\u0010\u0080\u0001\u001a\u00020:2\t\u0010\u0081\u0001\u001a\u0004\u0018\u00010\u0014H\u0007J\u0011\u0010\u0082\u0001\u001a\u00020:2\u0006\u0010D\u001a\u00020%H\u0007J\t\u0010\u0083\u0001\u001a\u00020:H\u0007J\t\u0010\u0084\u0001\u001a\u00020:H\u0007J\t\u0010\u0085\u0001\u001a\u00020:H\u0002J\t\u0010\u0086\u0001\u001a\u00020:H\u0007J\u0019\u0010\u0087\u0001\u001a\u00020:2\u0006\u0010D\u001a\u00020%2\u0006\u0010;\u001a\u00020\fH\u0007J\u0011\u0010\u0088\u0001\u001a\u00020:2\u0006\u0010;\u001a\u00020\fH\u0007J\u0012\u0010\u0089\u0001\u001a\u00020:2\u0007\u0010\u008a\u0001\u001a\u00020\u0014H\u0007R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0005\u001a\u00060\u0006R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0007\u001a\b\u0012\u0004\u0012\u00020\t0\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\n\u001a\b\u0012\u0004\u0012\u00020\t0\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0011\u0010\u000b\u001a\u00020\f8F¢\u0006\u0006\u001a\u0004\b\r\u0010\u000eR\u0011\u0010\u000f\u001a\u00020\u00108F¢\u0006\u0006\u001a\u0004\b\u0011\u0010\u0012R\u0010\u0010\u0013\u001a\u0004\u0018\u00010\u0014X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\t0\bX\u0082\u000e¢\u0006\u0002\n\u0000R$\u0010\u0018\u001a\u00020\u00172\u0006\u0010\u0016\u001a\u00020\u00178F@FX\u0086\u000e¢\u0006\f\u001a\u0004\b\u0019\u0010\u001a\"\u0004\b\u001b\u0010\u001cR\u0013\u0010\u001d\u001a\u0004\u0018\u00010\u001e8F¢\u0006\u0006\u001a\u0004\b\u001f\u0010 R\u000e\u0010!\u001a\u00020\"X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010#\u001a\u0004\u0018\u00010$X\u0082\u000e¢\u0006\u0002\n\u0000R$\u0010&\u001a\u00020%2\u0006\u0010\u0016\u001a\u00020%8F@FX\u0086\u000e¢\u0006\f\u001a\u0004\b'\u0010(\"\u0004\b)\u0010*R\u000e\u0010+\u001a\u00020,X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010-\u001a\u00020.8F¢\u0006\u0006\u001a\u0004\b/\u00100R\u000e\u00101\u001a\u00020%X\u0082\u000e¢\u0006\u0002\n\u0000R&\u00103\u001a\u00020\u00172\u0006\u00102\u001a\u00020\u00178\u0006@BX\u0087\u000e¢\u0006\u000e\n\u0000\u0012\u0004\b4\u0010\u0002\u001a\u0004\b5\u0010\u001aR\u0017\u00106\u001a\b\u0012\u0004\u0012\u00020\f0\b8F¢\u0006\u0006\u001a\u0004\b7\u00108\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u008e\u0001"}, d2 = {"Lcom/doublesymmetry/trackplayer/service/MusicService;", "Lcom/facebook/react/HeadlessJsTaskService;", "()V", MusicService.APP_KILLED_PLAYBACK_BEHAVIOR_KEY, "Lcom/doublesymmetry/trackplayer/service/MusicService$AppKilledPlaybackBehavior;", "binder", "Lcom/doublesymmetry/trackplayer/service/MusicService$MusicBinder;", "capabilities", "", "Lcom/doublesymmetry/kotlinaudio/models/Capability;", "compactCapabilities", "currentTrack", "Lcom/doublesymmetry/trackplayer/model/Track;", "getCurrentTrack", "()Lcom/doublesymmetry/trackplayer/model/Track;", MusicService.EVENT_KEY, "Lcom/doublesymmetry/kotlinaudio/event/EventHolder;", "getEvent", "()Lcom/doublesymmetry/kotlinaudio/event/EventHolder;", "latestOptions", "Landroid/os/Bundle;", "notificationCapabilities", AppMeasurementSdk.ConditionalUserProperty.VALUE, "", "playWhenReady", "getPlayWhenReady", "()Z", "setPlayWhenReady", "(Z)V", "playbackError", "Lcom/doublesymmetry/kotlinaudio/models/PlaybackError;", "getPlaybackError", "()Lcom/doublesymmetry/kotlinaudio/models/PlaybackError;", "player", "Lcom/doublesymmetry/kotlinaudio/players/QueuedAudioPlayer;", "progressUpdateJob", "Lkotlinx/coroutines/Job;", "", "ratingType", "getRatingType", "()I", "setRatingType", "(I)V", "scope", "Lkotlinx/coroutines/CoroutineScope;", MusicService.STATE_KEY, "Lcom/doublesymmetry/kotlinaudio/models/AudioPlayerState;", "getState", "()Lcom/doublesymmetry/kotlinaudio/models/AudioPlayerState;", MusicService.STOP_FOREGROUND_GRACE_PERIOD_KEY, "<set-?>", MusicService.STOPPING_APP_PAUSES_PLAYBACK_KEY, "getStoppingAppPausesPlayback$annotations", "getStoppingAppPausesPlayback", "tracks", "getTracks", "()Ljava/util/List;", "add", "", MusicService.TRACK_KEY, "atIndex", "clear", "clearNotificationMetadata", "emit", "", "data", "emitList", "emitPlaybackTrackChangedEvents", "index", "previousIndex", "oldPosition", "", "(Ljava/lang/Integer;Ljava/lang/Integer;D)V", "emitQueueEndedEvent", "getBufferedPositionInSeconds", "getCurrentTrackIndex", "getDurationInSeconds", "getPendingIntentFlags", "getPlaybackErrorBundle", "getPlayerStateBundle", "getPositionInSeconds", "getRate", "", "getRepeatMode", "Lcom/doublesymmetry/kotlinaudio/models/RepeatMode;", "getTaskConfig", "Lcom/facebook/react/jstasks/HeadlessJsTaskConfig;", "intent", "Landroid/content/Intent;", "getVolume", "isCompact", "capability", "isForegroundService", "load", "move", "fromIndex", "toIndex", "observeEvents", "onBind", "Landroid/os/IBinder;", "onDestroy", "onHeadlessJsTaskFinish", "taskId", "onStartCommand", "flags", "startId", "onTaskRemoved", "rootIntent", "pause", "play", "progressUpdateEvent", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "progressUpdateEventFlow", "Lkotlinx/coroutines/flow/Flow;", "interval", "remove", "indexes", "removePreviousTracks", "removeUpcomingTracks", "retry", "seekBy", "offset", "seekTo", "seconds", "setRate", "setRepeatMode", "setVolume", "setupForegrounding", "setupPlayer", "playerOptions", "skip", "skipToNext", "skipToPrevious", "startAndStopEmptyNotificationToAvoidANR", "stop", "updateMetadataForTrack", "updateNowPlayingMetadata", "updateOptions", "options", "AppKilledPlaybackBehavior", "Companion", "MusicBinder", "react-native-track-player_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class MusicService extends HeadlessJsTaskService {
public static final String ANDROID_AUDIO_CONTENT_TYPE = "androidAudioContentType";
public static final String ANDROID_OPTIONS_KEY = "android";
public static final String APP_KILLED_PLAYBACK_BEHAVIOR_KEY = "appKilledPlaybackBehavior";
public static final String AUTO_HANDLE_INTERRUPTIONS = "autoHandleInterruptions";
public static final String AUTO_UPDATE_METADATA = "autoUpdateMetadata";
public static final String BACKWARD_JUMP_INTERVAL_KEY = "backwardJumpInterval";
public static final String BACK_BUFFER_KEY = "backBuffer";
public static final String BUFFERED_POSITION_KEY = "buffered";
public static final String DATA_KEY = "data";
public static final double DEFAULT_JUMP_INTERVAL = 15.0d;
public static final int DEFAULT_STOP_FOREGROUND_GRACE_PERIOD = 5;
public static final String DURATION_KEY = "duration";
public static final int EMPTY_NOTIFICATION_ID = 1;
public static final String ERROR_KEY = "error";
public static final String EVENT_KEY = "event";
public static final String FORWARD_JUMP_INTERVAL_KEY = "forwardJumpInterval";
public static final String IS_FOCUS_LOSS_PERMANENT_KEY = "permanent";
public static final String IS_PAUSED_KEY = "paused";
public static final String MAX_BUFFER_KEY = "maxBuffer";
public static final String MAX_CACHE_SIZE_KEY = "maxCacheSize";
public static final String MIN_BUFFER_KEY = "minBuffer";
public static final String NEXT_TRACK_KEY = "nextTrack";
public static final String PAUSE_ON_INTERRUPTION_KEY = "alwaysPauseOnInterruption";
public static final String PLAY_BUFFER_KEY = "playBuffer";
public static final String POSITION_KEY = "position";
public static final String PROGRESS_UPDATE_EVENT_INTERVAL_KEY = "progressUpdateEventInterval";
public static final String STATE_KEY = "state";
public static final String STOPPING_APP_PAUSES_PLAYBACK_KEY = "stoppingAppPausesPlayback";
public static final String STOP_FOREGROUND_GRACE_PERIOD_KEY = "stopForegroundGracePeriod";
public static final String TASK_KEY = "TrackPlayer";
public static final String TRACK_KEY = "track";
private Bundle latestOptions;
private QueuedAudioPlayer player;
private Job progressUpdateJob;
private final MusicBinder binder = new MusicBinder();
private final CoroutineScope scope = CoroutineScopeKt.MainScope();
private boolean stoppingAppPausesPlayback = true;
private AppKilledPlaybackBehavior appKilledPlaybackBehavior = AppKilledPlaybackBehavior.CONTINUE_PLAYBACK;
private int stopForegroundGracePeriod = 5;
private List<? extends Capability> capabilities = CollectionsKt.emptyList();
private List<? extends Capability> notificationCapabilities = CollectionsKt.emptyList();
private List<? extends Capability> compactCapabilities = CollectionsKt.emptyList();
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
public static final int[] $EnumSwitchMapping$1;
static {
int[] iArr = new int[Capability.values().length];
try {
iArr[Capability.PLAY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[Capability.PAUSE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
iArr[Capability.STOP.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
iArr[Capability.SKIP_TO_NEXT.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
iArr[Capability.SKIP_TO_PREVIOUS.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
iArr[Capability.JUMP_FORWARD.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
iArr[Capability.JUMP_BACKWARD.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
iArr[Capability.SEEK_TO.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
$EnumSwitchMapping$0 = iArr;
int[] iArr2 = new int[AppKilledPlaybackBehavior.values().length];
try {
iArr2[AppKilledPlaybackBehavior.PAUSE_PLAYBACK.ordinal()] = 1;
} catch (NoSuchFieldError unused9) {
}
try {
iArr2[AppKilledPlaybackBehavior.STOP_PLAYBACK_AND_REMOVE_NOTIFICATION.ordinal()] = 2;
} catch (NoSuchFieldError unused10) {
}
$EnumSwitchMapping$1 = iArr2;
}
}
@Deprecated(message = "This will be removed soon")
public static void getStoppingAppPausesPlayback$annotations() {
}
@Override
public void onHeadlessJsTaskFinish(int taskId) {
}
public final boolean getStoppingAppPausesPlayback() {
return this.stoppingAppPausesPlayback;
}
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0007\b\u0086\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u000f\b\u0002\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006j\u0002\b\u0007j\u0002\b\bj\u0002\b\t¨\u0006\n"}, d2 = {"Lcom/doublesymmetry/trackplayer/service/MusicService$AppKilledPlaybackBehavior;", "", "string", "", "(Ljava/lang/String;ILjava/lang/String;)V", "getString", "()Ljava/lang/String;", "CONTINUE_PLAYBACK", "PAUSE_PLAYBACK", "STOP_PLAYBACK_AND_REMOVE_NOTIFICATION", "react-native-track-player_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public enum AppKilledPlaybackBehavior {
CONTINUE_PLAYBACK("continue-playback"),
PAUSE_PLAYBACK("pause-playback"),
STOP_PLAYBACK_AND_REMOVE_NOTIFICATION("stop-playback-and-remove-notification");
private final String string;
AppKilledPlaybackBehavior(String str) {
this.string = str;
}
public final String getString() {
return this.string;
}
}
public final List<Track> getTracks() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
List<AudioItem> items = queuedAudioPlayer.getItems();
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(items, 10));
for (AudioItem audioItem : items) {
Intrinsics.checkNotNull(audioItem, "null cannot be cast to non-null type com.doublesymmetry.trackplayer.model.TrackAudioItem");
arrayList.add(((TrackAudioItem) audioItem).getTrack());
}
return arrayList;
}
public final Track getCurrentTrack() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
AudioItem currentItem = queuedAudioPlayer.getCurrentItem();
Intrinsics.checkNotNull(currentItem, "null cannot be cast to non-null type com.doublesymmetry.trackplayer.model.TrackAudioItem");
return ((TrackAudioItem) currentItem).getTrack();
}
public final AudioPlayerState getState() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getPlayerState();
}
public final int getRatingType() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getRatingType();
}
public final void setRatingType(int i) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.setRatingType(i);
}
public final PlaybackError getPlaybackError() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getPlaybackError();
}
public final EventHolder getEvent() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getEvent();
}
public final boolean getPlayWhenReady() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getPlayWhenReady();
}
public final void setPlayWhenReady(boolean z) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.setPlayWhenReady(z);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
startTask(getTaskConfig(intent));
startAndStopEmptyNotificationToAvoidANR();
return 1;
}
private final void startAndStopEmptyNotificationToAvoidANR() {
Object systemService = getSystemService("notification");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
NotificationManager notificationManager = (NotificationManager) systemService;
if (Build.VERSION.SDK_INT >= 26) {
TSpanView$.ExternalSyntheticApiModelOutline0.m();
TSpanView$.ExternalSyntheticApiModelOutline0.m(notificationManager, TSpanView$.ExternalSyntheticApiModelOutline0.m(getString(R.string.rntp_temporary_channel_id), getString(R.string.rntp_temporary_channel_name), 2));
}
NotificationCompat.Builder smallIcon = new NotificationCompat.Builder(this, getString(R.string.rntp_temporary_channel_id)).setPriority(-1).setCategory("service").setSmallIcon(com.google.android.exoplayer2.ui.R.drawable.exo_notification_small_icon);
Intrinsics.checkNotNullExpressionValue(smallIcon, "Builder(this, getString(…_notification_small_icon)");
if (Build.VERSION.SDK_INT >= 31) {
smallIcon.setForegroundServiceBehavior(1);
}
Notification build = smallIcon.build();
Intrinsics.checkNotNullExpressionValue(build, "notificationBuilder.build()");
startForeground(1, build);
stopForeground(true);
}
public final void setupPlayer(android.os.Bundle r14) {
throw new UnsupportedOperationException("Method not decompiled: com.doublesymmetry.trackplayer.service.MusicService.setupPlayer(android.os.Bundle):void");
}
public final void updateOptions(Bundle options) {
AppKilledPlaybackBehavior appKilledPlaybackBehavior;
ArrayList emptyList;
ArrayList emptyList2;
ArrayList emptyList3;
NotificationButton play_pause;
Intrinsics.checkNotNullParameter(options, "options");
this.latestOptions = options;
Bundle bundle = options.getBundle("android");
Function1 function1 = new PropertyReference1Impl() {
public Object get(Object obj) {
return ((MusicService.AppKilledPlaybackBehavior) obj).getString();
}
};
String string = bundle != null ? bundle.getString(APP_KILLED_PLAYBACK_BEHAVIOR_KEY) : null;
AppKilledPlaybackBehavior[] values = AppKilledPlaybackBehavior.values();
int length = values.length;
int i = 0;
while (true) {
if (i >= length) {
appKilledPlaybackBehavior = null;
break;
}
appKilledPlaybackBehavior = values[i];
if (Intrinsics.areEqual(function1.invoke(appKilledPlaybackBehavior), string)) {
break;
} else {
i++;
}
}
AppKilledPlaybackBehavior appKilledPlaybackBehavior2 = appKilledPlaybackBehavior;
if (appKilledPlaybackBehavior2 == null) {
appKilledPlaybackBehavior2 = AppKilledPlaybackBehavior.CONTINUE_PLAYBACK;
}
this.appKilledPlaybackBehavior = appKilledPlaybackBehavior2;
Integer intOrNull = BundleUtils.INSTANCE.getIntOrNull(bundle, STOP_FOREGROUND_GRACE_PERIOD_KEY);
if (intOrNull != null) {
this.stopForegroundGracePeriod = intOrNull.intValue();
}
options.getBoolean(STOPPING_APP_PAUSES_PLAYBACK_KEY);
boolean z = options.getBoolean(STOPPING_APP_PAUSES_PLAYBACK_KEY);
this.stoppingAppPausesPlayback = z;
if (z) {
this.appKilledPlaybackBehavior = AppKilledPlaybackBehavior.PAUSE_PLAYBACK;
}
setRatingType(BundleUtils.INSTANCE.getInt(options, "ratingType", 0));
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.getPlayerOptions().setAlwaysPauseOnInterruption(bundle != null ? bundle.getBoolean(PAUSE_ON_INTERRUPTION_KEY) : false);
ArrayList<Integer> integerArrayList = options.getIntegerArrayList("capabilities");
if (integerArrayList == null) {
emptyList = CollectionsKt.emptyList();
} else {
ArrayList<Integer> arrayList = integerArrayList;
ArrayList arrayList2 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList, 10));
for (Integer num : arrayList) {
Capability[] values2 = Capability.values();
Intrinsics.checkNotNullExpressionValue(num, "it");
arrayList2.add(values2[num.intValue()]);
}
emptyList = arrayList2;
}
this.capabilities = emptyList;
ArrayList<Integer> integerArrayList2 = options.getIntegerArrayList("notificationCapabilities");
if (integerArrayList2 == null) {
emptyList2 = CollectionsKt.emptyList();
} else {
ArrayList<Integer> arrayList3 = integerArrayList2;
ArrayList arrayList4 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList3, 10));
for (Integer num2 : arrayList3) {
Capability[] values3 = Capability.values();
Intrinsics.checkNotNullExpressionValue(num2, "it");
arrayList4.add(values3[num2.intValue()]);
}
emptyList2 = arrayList4;
}
this.notificationCapabilities = emptyList2;
ArrayList<Integer> integerArrayList3 = options.getIntegerArrayList("compactCapabilities");
if (integerArrayList3 == null) {
emptyList3 = CollectionsKt.emptyList();
} else {
ArrayList<Integer> arrayList5 = integerArrayList3;
ArrayList arrayList6 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList5, 10));
for (Integer num3 : arrayList5) {
Capability[] values4 = Capability.values();
Intrinsics.checkNotNullExpressionValue(num3, "it");
arrayList6.add(values4[num3.intValue()]);
}
emptyList3 = arrayList6;
}
this.compactCapabilities = emptyList3;
if (this.notificationCapabilities.isEmpty()) {
this.notificationCapabilities = this.capabilities;
}
List<? extends Capability> list = this.notificationCapabilities;
ArrayList arrayList7 = new ArrayList();
for (Capability capability : list) {
switch (WhenMappings.$EnumSwitchMapping$0[capability.ordinal()]) {
case 1:
case 2:
MusicService musicService = this;
play_pause = new NotificationButton.PLAY_PAUSE(BundleUtils.INSTANCE.getIconOrNull(musicService, options, "playIcon"), BundleUtils.INSTANCE.getIconOrNull(musicService, options, "pauseIcon"));
break;
case 3:
play_pause = new NotificationButton.STOP(BundleUtils.INSTANCE.getIconOrNull(this, options, "stopIcon"));
break;
case 4:
play_pause = new NotificationButton.NEXT(BundleUtils.INSTANCE.getIconOrNull(this, options, "nextIcon"), isCompact(capability));
break;
case 5:
play_pause = new NotificationButton.PREVIOUS(BundleUtils.INSTANCE.getIconOrNull(this, options, "previousIcon"), isCompact(capability));
break;
case 6:
play_pause = new NotificationButton.FORWARD(Integer.valueOf(BundleUtils.INSTANCE.getIcon(this, options, "forwardIcon", R.drawable.forward)), isCompact(capability));
break;
case 7:
play_pause = new NotificationButton.BACKWARD(Integer.valueOf(BundleUtils.INSTANCE.getIcon(this, options, "rewindIcon", R.drawable.rewind)), isCompact(capability));
break;
case 8:
play_pause = NotificationButton.SEEK_TO.INSTANCE;
break;
default:
play_pause = null;
break;
}
if (play_pause != null) {
arrayList7.add(play_pause);
}
}
ArrayList arrayList8 = arrayList7;
Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName());
if (launchIntentForPackage != null) {
launchIntentForPackage.setFlags(603979776);
launchIntentForPackage.setData(Uri.parse("trackplayer://notification.click"));
launchIntentForPackage.setAction("android.intent.action.VIEW");
} else {
launchIntentForPackage = null;
}
MusicService musicService2 = this;
NotificationConfig notificationConfig = new NotificationConfig(arrayList8, BundleUtils.INSTANCE.getIntOrNull(options, "color"), BundleUtils.INSTANCE.getIconOrNull(musicService2, options, "icon"), PendingIntent.getActivity(musicService2, 0, launchIntentForPackage, getPendingIntentFlags()));
QueuedAudioPlayer queuedAudioPlayer2 = this.player;
if (queuedAudioPlayer2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer2 = null;
}
queuedAudioPlayer2.getNotificationManager().createNotification(notificationConfig);
Job job = this.progressUpdateJob;
if (job != null) {
Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
}
Double doubleOrNull = BundleUtils.INSTANCE.getDoubleOrNull(options, PROGRESS_UPDATE_EVENT_INTERVAL_KEY);
if (doubleOrNull == null || doubleOrNull.doubleValue() <= 0.0d) {
return;
}
this.progressUpdateJob = BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$updateOptions$7(this, doubleOrNull, null), 3, (Object) null);
}
public final Flow<Bundle> progressUpdateEventFlow(double interval) {
return FlowKt.flow(new MusicService$progressUpdateEventFlow$1(this, interval, null));
}
public final Object progressUpdateEvent(Continuation<? super Bundle> continuation) {
return BuildersKt.withContext(Dispatchers.getMain(), new MusicService$progressUpdateEvent$2(this, null), continuation);
}
private final int getPendingIntentFlags() {
return Build.VERSION.SDK_INT >= 23 ? 335544320 : 268435456;
}
private final boolean isCompact(Capability capability) {
return this.compactCapabilities.contains(capability);
}
public final void add(Track track) {
Intrinsics.checkNotNullParameter(track, TRACK_KEY);
add(CollectionsKt.listOf(track));
}
public final void add(List<Track> tracks) {
Intrinsics.checkNotNullParameter(tracks, "tracks");
List<Track> list = tracks;
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(list, 10));
Iterator<T> it = list.iterator();
while (it.hasNext()) {
arrayList.add(((Track) it.next()).toAudioItem());
}
ArrayList arrayList2 = arrayList;
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.add(arrayList2);
}
public final void add(List<Track> tracks, int atIndex) {
Intrinsics.checkNotNullParameter(tracks, "tracks");
List<Track> list = tracks;
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(list, 10));
Iterator<T> it = list.iterator();
while (it.hasNext()) {
arrayList.add(((Track) it.next()).toAudioItem());
}
ArrayList arrayList2 = arrayList;
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.add(arrayList2, atIndex);
}
public final void load(Track track) {
Intrinsics.checkNotNullParameter(track, TRACK_KEY);
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.load(track.toAudioItem());
}
public final void move(int fromIndex, int toIndex) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.move(fromIndex, toIndex);
}
public final void remove(int index) {
remove(CollectionsKt.listOf(Integer.valueOf(index)));
}
public final void remove(List<Integer> indexes) {
Intrinsics.checkNotNullParameter(indexes, "indexes");
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.remove(indexes);
}
public final void clear() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.clear();
}
public final void play() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.play();
}
public final void pause() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.pause();
}
public final void stop() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.stop();
}
public final void removeUpcomingTracks() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.removeUpcomingItems();
}
public final void removePreviousTracks() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.removePreviousItems();
}
public final void skip(int index) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.jumpToItem(index);
}
public final void skipToNext() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.next();
}
public final void skipToPrevious() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.previous();
}
public final void seekTo(float seconds) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.seek((long) (seconds * 1000), TimeUnit.MILLISECONDS);
}
public final void seekBy(float offset) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.seekBy((long) offset, TimeUnit.SECONDS);
}
public final void retry() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.prepare();
}
public final int getCurrentTrackIndex() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getCurrentIndex();
}
public final float getRate() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getPlaybackSpeed();
}
public final void setRate(float value) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.setPlaybackSpeed(value);
}
public final RepeatMode getRepeatMode() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getPlayerOptions().getRepeatMode();
}
public final void setRepeatMode(RepeatMode value) {
Intrinsics.checkNotNullParameter(value, AppMeasurementSdk.ConditionalUserProperty.VALUE);
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.getPlayerOptions().setRepeatMode(value);
}
public final float getVolume() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return queuedAudioPlayer.getVolume();
}
public final void setVolume(float value) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.setVolume(value);
}
public final double getDurationInSeconds() {
NumberExt.Companion companion = NumberExt.INSTANCE;
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return companion.toSeconds(Long.valueOf(queuedAudioPlayer.getDuration()));
}
public final double getPositionInSeconds() {
NumberExt.Companion companion = NumberExt.INSTANCE;
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return companion.toSeconds(Long.valueOf(queuedAudioPlayer.getPosition()));
}
public final double getBufferedPositionInSeconds() {
NumberExt.Companion companion = NumberExt.INSTANCE;
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
return companion.toSeconds(Long.valueOf(queuedAudioPlayer.getBufferedPosition()));
}
public final Bundle getPlayerStateBundle(AudioPlayerState state) {
Intrinsics.checkNotNullParameter(state, STATE_KEY);
Bundle bundle = new Bundle();
bundle.putString(STATE_KEY, AudioPlayerStateExtKt.getAsLibState(state).getState());
if (state == AudioPlayerState.ERROR) {
bundle.putBundle(ERROR_KEY, getPlaybackErrorBundle());
}
return bundle;
}
public final void updateMetadataForTrack(int index, Track track) {
Intrinsics.checkNotNullParameter(track, TRACK_KEY);
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.replaceItem(index, track.toAudioItem());
}
public final void updateNowPlayingMetadata(Track track) {
Intrinsics.checkNotNullParameter(track, TRACK_KEY);
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.getNotificationManager().overrideMetadata(track.toAudioItem());
}
public final void clearNotificationMetadata() {
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.getNotificationManager().hideNotification();
}
public final void emitPlaybackTrackChangedEvents(Integer index, Integer previousIndex, double oldPosition) {
Bundle bundle = new Bundle();
bundle.putDouble("position", oldPosition);
if (index != null) {
bundle.putInt(NEXT_TRACK_KEY, index.intValue());
}
if (previousIndex != null) {
bundle.putInt(TRACK_KEY, previousIndex.intValue());
}
emit(MusicEvents.PLAYBACK_TRACK_CHANGED, bundle);
Bundle bundle2 = new Bundle();
bundle2.putDouble("lastPosition", oldPosition);
if (!getTracks().isEmpty()) {
QueuedAudioPlayer queuedAudioPlayer = this.player;
QueuedAudioPlayer queuedAudioPlayer2 = null;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
bundle2.putInt("index", queuedAudioPlayer.getCurrentIndex());
List<Track> tracks = getTracks();
QueuedAudioPlayer queuedAudioPlayer3 = this.player;
if (queuedAudioPlayer3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
} else {
queuedAudioPlayer2 = queuedAudioPlayer3;
}
bundle2.putBundle(TRACK_KEY, tracks.get(queuedAudioPlayer2.getCurrentIndex()).getOriginalItem());
if (previousIndex != null) {
bundle2.putInt("lastIndex", previousIndex.intValue());
bundle2.putBundle("lastTrack", getTracks().get(previousIndex.intValue()).getOriginalItem());
}
}
emit(MusicEvents.PLAYBACK_ACTIVE_TRACK_CHANGED, bundle2);
}
public final void emitQueueEndedEvent() {
Bundle bundle = new Bundle();
QueuedAudioPlayer queuedAudioPlayer = this.player;
QueuedAudioPlayer queuedAudioPlayer2 = null;
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
bundle.putInt(TRACK_KEY, queuedAudioPlayer.getCurrentIndex());
NumberExt.Companion companion = NumberExt.INSTANCE;
QueuedAudioPlayer queuedAudioPlayer3 = this.player;
if (queuedAudioPlayer3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
} else {
queuedAudioPlayer2 = queuedAudioPlayer3;
}
bundle.putDouble("position", companion.toSeconds(Long.valueOf(queuedAudioPlayer2.getPosition())));
emit(MusicEvents.PLAYBACK_QUEUE_ENDED, bundle);
}
public final boolean isForegroundService() {
Object systemService = getBaseContext().getSystemService("activity");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.ActivityManager");
for (ActivityManager.RunningServiceInfo runningServiceInfo : ((ActivityManager) systemService).getRunningServices(Integer.MAX_VALUE)) {
if (Intrinsics.areEqual(MusicService.class.getName(), runningServiceInfo.service.getClassName())) {
return runningServiceInfo.foreground;
}
}
Timber.Forest.e("isForegroundService found no matching service", new Object[0]);
return false;
}
private final void setupForegrounding() {
Ref.ObjectRef objectRef = new Ref.ObjectRef();
Ref.ObjectRef objectRef2 = new Ref.ObjectRef();
Ref.BooleanRef booleanRef = new Ref.BooleanRef();
Ref.BooleanRef booleanRef2 = new Ref.BooleanRef();
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$setupForegrounding$1(this, booleanRef, booleanRef2, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$setupForegrounding$2(this, objectRef, objectRef2, booleanRef, booleanRef2, null), 3, (Object) null);
}
public static final void setupForegrounding$startForegroundIfNecessary(MusicService musicService, Ref.ObjectRef<Notification> objectRef, Ref.ObjectRef<Integer> objectRef2) {
if (musicService.isForegroundService()) {
Timber.Forest.d("skipping foregrounding as the service is already foregrounded", new Object[0]);
return;
}
if (objectRef.element == null) {
Timber.Forest.d("can't startForeground as the notification is null", new Object[0]);
return;
}
try {
if (Build.VERSION.SDK_INT >= 29) {
Object obj = objectRef2.element;
Intrinsics.checkNotNull(obj);
int intValue = ((Number) obj).intValue();
Object obj2 = objectRef.element;
Intrinsics.checkNotNull(obj2);
TSpanView$.ExternalSyntheticApiModelOutline0.m(musicService, intValue, (Notification) obj2, 2);
} else {
Object obj3 = objectRef2.element;
Intrinsics.checkNotNull(obj3);
musicService.startForeground(((Number) obj3).intValue(), (Notification) objectRef.element);
}
Timber.Forest.d("notification has been foregrounded", new Object[0]);
} catch (Exception e) {
if (Build.VERSION.SDK_INT < 31 || !TSpanView$.ExternalSyntheticApiModelOutline0.m(e)) {
return;
}
Timber.Forest.e("ForegroundServiceStartNotAllowedException: App tried to start a foreground Service when it was not allowed to do so.", new Object[]{e});
Bundle bundle = new Bundle();
bundle.putString("message", e.getMessage());
bundle.putString("code", "android-foreground-service-start-not-allowed");
Unit unit = Unit.INSTANCE;
musicService.emit(MusicEvents.PLAYER_ERROR, bundle);
}
}
public static final boolean setupForegrounding$shouldStopForeground(Ref.BooleanRef booleanRef, Ref.BooleanRef booleanRef2, MusicService musicService) {
return booleanRef.element && (booleanRef2.element || musicService.isForegroundService());
}
private final void observeEvents() {
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$1(this, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$2(this, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$3(this, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$4(this, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$5(this, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$6(this, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$7(this, null), 3, (Object) null);
BuildersKt.launch$default(this.scope, (CoroutineContext) null, (CoroutineStart) null, new MusicService$observeEvents$8(this, null), 3, (Object) null);
}
public final Bundle getPlaybackErrorBundle() {
Bundle bundle = new Bundle();
PlaybackError playbackError = getPlaybackError();
if ((playbackError != null ? playbackError.getMessage() : null) != null) {
bundle.putString("message", playbackError.getMessage());
}
if ((playbackError != null ? playbackError.getCode() : null) != null) {
bundle.putString("code", "android-" + playbackError.getCode());
}
return bundle;
}
static void emit$default(MusicService musicService, String str, Bundle bundle, int i, Object obj) {
if ((i & 2) != 0) {
bundle = null;
}
musicService.emit(str, bundle);
}
public final void emit(String event, Bundle data) {
DeviceEventManagerModule.RCTDeviceEventEmitter rCTDeviceEventEmitter;
ReactContext currentReactContext = getReactNativeHost().getReactInstanceManager().getCurrentReactContext();
if (currentReactContext == null || (rCTDeviceEventEmitter = (DeviceEventManagerModule.RCTDeviceEventEmitter) currentReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)) == null) {
return;
}
rCTDeviceEventEmitter.emit(event, data != null ? Arguments.fromBundle(data) : null);
}
static void emitList$default(MusicService musicService, String str, List list, int i, Object obj) {
if ((i & 2) != 0) {
list = CollectionsKt.emptyList();
}
musicService.emitList(str, list);
}
private final void emitList(String event, List<Bundle> data) {
DeviceEventManagerModule.RCTDeviceEventEmitter rCTDeviceEventEmitter;
WritableArray createArray = Arguments.createArray();
Iterator<T> it = data.iterator();
while (it.hasNext()) {
createArray.pushMap(Arguments.fromBundle((Bundle) it.next()));
}
ReactContext currentReactContext = getReactNativeHost().getReactInstanceManager().getCurrentReactContext();
if (currentReactContext == null || (rCTDeviceEventEmitter = (DeviceEventManagerModule.RCTDeviceEventEmitter) currentReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)) == null) {
return;
}
rCTDeviceEventEmitter.emit(event, createArray);
}
@Override
protected HeadlessJsTaskConfig getTaskConfig(Intent intent) {
return new HeadlessJsTaskConfig(TASK_KEY, Arguments.createMap(), 0L, true);
}
@Override
public IBinder onBind(Intent intent) {
return this.binder;
}
@Override
public void onTaskRemoved(Intent rootIntent) {
super.onTaskRemoved(rootIntent);
if (this.player == null) {
return;
}
int i = WhenMappings.$EnumSwitchMapping$1[this.appKilledPlaybackBehavior.ordinal()];
QueuedAudioPlayer queuedAudioPlayer = null;
if (i == 1) {
QueuedAudioPlayer queuedAudioPlayer2 = this.player;
if (queuedAudioPlayer2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
} else {
queuedAudioPlayer = queuedAudioPlayer2;
}
queuedAudioPlayer.pause();
return;
}
if (i != 2) {
return;
}
QueuedAudioPlayer queuedAudioPlayer3 = this.player;
if (queuedAudioPlayer3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer3 = null;
}
queuedAudioPlayer3.clear();
QueuedAudioPlayer queuedAudioPlayer4 = this.player;
if (queuedAudioPlayer4 == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
} else {
queuedAudioPlayer = queuedAudioPlayer4;
}
queuedAudioPlayer.stop();
if (Build.VERSION.SDK_INT >= 24) {
TSpanView$.ExternalSyntheticApiModelOutline0.m(this, 1);
} else {
stopForeground(true);
}
stopSelf();
System.exit(0);
throw new RuntimeException("System.exit returned normally, while it was supposed to halt JVM.");
}
@Override
public void onDestroy() {
super.onDestroy();
QueuedAudioPlayer queuedAudioPlayer = this.player;
if (queuedAudioPlayer != null) {
if (queuedAudioPlayer == null) {
Intrinsics.throwUninitializedPropertyAccessException("player");
queuedAudioPlayer = null;
}
queuedAudioPlayer.destroy();
}
Job job = this.progressUpdateJob;
if (job != null) {
Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
}
}
@Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0087\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002R\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\u0007"}, d2 = {"Lcom/doublesymmetry/trackplayer/service/MusicService$MusicBinder;", "Landroid/os/Binder;", "(Lcom/doublesymmetry/trackplayer/service/MusicService;)V", "service", "Lcom/doublesymmetry/trackplayer/service/MusicService;", "getService", "()Lcom/doublesymmetry/trackplayer/service/MusicService;", "react-native-track-player_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class MusicBinder extends Binder {
private final MusicService service;
public MusicBinder() {
this.service = MusicService.this;
}
public final MusicService getService() {
return this.service;
}
}
}