383 lines
16 KiB
Java
383 lines
16 KiB
Java
package com.discord.utilities.voice;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import androidx.annotation.StringRes;
|
|
import c.d.b.a.a;
|
|
import com.discord.rtcconnection.RtcConnection;
|
|
import com.discord.stores.StoreAudioDevices;
|
|
import com.discord.stores.StoreAudioManagerV2;
|
|
import com.discord.stores.StoreMediaSettings;
|
|
import com.discord.stores.StoreRtcConnection;
|
|
import com.discord.stores.StoreVoiceChannelSelected;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.voice.VoiceEngineForegroundService;
|
|
import d0.g;
|
|
import d0.z.d.m;
|
|
import kotlin.Lazy;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: VoiceEngineServiceController.kt */
|
|
public final class VoiceEngineServiceController {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final Lazy INSTANCE$delegate = g.lazy(VoiceEngineServiceController$Companion$INSTANCE$2.INSTANCE);
|
|
private static final NotificationData NOTIFICATION_DATA_DISCONNECTED = new NotificationData(new RtcConnection.State.d(false), "", false, false, false, false, -1, null, false, false);
|
|
private final StoreAudioDevices audioDevicesStore;
|
|
private final StoreAudioManagerV2 audioManagerStore;
|
|
private final StoreMediaSettings mediaSettingsStore;
|
|
private final Observable<NotificationData> notificationDataObservable;
|
|
private VoiceEngineForegroundService.Connection serviceBinding;
|
|
private final StoreVoiceChannelSelected voiceChannelSelectedStore;
|
|
|
|
/* compiled from: VoiceEngineServiceController.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final VoiceEngineServiceController getINSTANCE() {
|
|
Lazy access$getINSTANCE$cp = VoiceEngineServiceController.access$getINSTANCE$cp();
|
|
Companion companion = VoiceEngineServiceController.Companion;
|
|
return (VoiceEngineServiceController) access$getINSTANCE$cp.getValue();
|
|
}
|
|
}
|
|
|
|
/* compiled from: VoiceEngineServiceController.kt */
|
|
public static final class NotificationData {
|
|
private final boolean canSpeak;
|
|
private final long channelId;
|
|
private final String channelName;
|
|
private final Long guildId;
|
|
private final boolean isSelfDeafened;
|
|
private final boolean isSelfMuted;
|
|
private final boolean isSelfStreaming;
|
|
private final boolean isVideo;
|
|
private final boolean proximityLockEnabled;
|
|
private final RtcConnection.State rtcConnectionState;
|
|
@StringRes
|
|
private final int stateString;
|
|
|
|
public NotificationData(RtcConnection.State state, String str, boolean z2, boolean z3, boolean z4, boolean z5, long j, Long l, boolean z6, boolean z7) {
|
|
int i;
|
|
m.checkNotNullParameter(state, "rtcConnectionState");
|
|
m.checkNotNullParameter(str, "channelName");
|
|
this.rtcConnectionState = state;
|
|
this.channelName = str;
|
|
this.isSelfMuted = z2;
|
|
this.isSelfDeafened = z3;
|
|
this.isSelfStreaming = z4;
|
|
this.isVideo = z5;
|
|
this.channelId = j;
|
|
this.guildId = l;
|
|
this.proximityLockEnabled = z6;
|
|
this.canSpeak = z7;
|
|
if (state instanceof RtcConnection.State.d) {
|
|
i = 2131887535;
|
|
} else if (m.areEqual(state, RtcConnection.State.b.a)) {
|
|
i = 2131887532;
|
|
} else if (m.areEqual(state, RtcConnection.State.a.a)) {
|
|
i = 2131887531;
|
|
} else if (m.areEqual(state, RtcConnection.State.c.a)) {
|
|
i = 2131887534;
|
|
} else if (m.areEqual(state, RtcConnection.State.h.a)) {
|
|
i = 2131887539;
|
|
} else if (m.areEqual(state, RtcConnection.State.g.a)) {
|
|
i = 2131887538;
|
|
} else if (m.areEqual(state, RtcConnection.State.f.a)) {
|
|
i = z4 ? 2131887541 : z5 ? 2131887542 : 2131887543;
|
|
} else if (m.areEqual(state, RtcConnection.State.e.a)) {
|
|
i = 2131887537;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
this.stateString = i;
|
|
}
|
|
|
|
public static /* synthetic */ NotificationData copy$default(NotificationData notificationData, RtcConnection.State state, String str, boolean z2, boolean z3, boolean z4, boolean z5, long j, Long l, boolean z6, boolean z7, int i, Object obj) {
|
|
return notificationData.copy((i & 1) != 0 ? notificationData.rtcConnectionState : state, (i & 2) != 0 ? notificationData.channelName : str, (i & 4) != 0 ? notificationData.isSelfMuted : z2, (i & 8) != 0 ? notificationData.isSelfDeafened : z3, (i & 16) != 0 ? notificationData.isSelfStreaming : z4, (i & 32) != 0 ? notificationData.isVideo : z5, (i & 64) != 0 ? notificationData.channelId : j, (i & 128) != 0 ? notificationData.guildId : l, (i & 256) != 0 ? notificationData.proximityLockEnabled : z6, (i & 512) != 0 ? notificationData.canSpeak : z7);
|
|
}
|
|
|
|
public final RtcConnection.State component1() {
|
|
return this.rtcConnectionState;
|
|
}
|
|
|
|
public final boolean component10() {
|
|
return this.canSpeak;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.channelName;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.isSelfMuted;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isSelfDeafened;
|
|
}
|
|
|
|
public final boolean component5() {
|
|
return this.isSelfStreaming;
|
|
}
|
|
|
|
public final boolean component6() {
|
|
return this.isVideo;
|
|
}
|
|
|
|
public final long component7() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final Long component8() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final boolean component9() {
|
|
return this.proximityLockEnabled;
|
|
}
|
|
|
|
public final NotificationData copy(RtcConnection.State state, String str, boolean z2, boolean z3, boolean z4, boolean z5, long j, Long l, boolean z6, boolean z7) {
|
|
m.checkNotNullParameter(state, "rtcConnectionState");
|
|
m.checkNotNullParameter(str, "channelName");
|
|
return new NotificationData(state, str, z2, z3, z4, z5, j, l, z6, z7);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof NotificationData)) {
|
|
return false;
|
|
}
|
|
NotificationData notificationData = (NotificationData) obj;
|
|
return m.areEqual(this.rtcConnectionState, notificationData.rtcConnectionState) && m.areEqual(this.channelName, notificationData.channelName) && this.isSelfMuted == notificationData.isSelfMuted && this.isSelfDeafened == notificationData.isSelfDeafened && this.isSelfStreaming == notificationData.isSelfStreaming && this.isVideo == notificationData.isVideo && this.channelId == notificationData.channelId && m.areEqual(this.guildId, notificationData.guildId) && this.proximityLockEnabled == notificationData.proximityLockEnabled && this.canSpeak == notificationData.canSpeak;
|
|
}
|
|
|
|
public final boolean getCanSpeak() {
|
|
return this.canSpeak;
|
|
}
|
|
|
|
public final long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final String getChannelName() {
|
|
return this.channelName;
|
|
}
|
|
|
|
public final Long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final boolean getProximityLockEnabled() {
|
|
return this.proximityLockEnabled;
|
|
}
|
|
|
|
public final RtcConnection.State getRtcConnectionState() {
|
|
return this.rtcConnectionState;
|
|
}
|
|
|
|
public final int getStateString() {
|
|
return this.stateString;
|
|
}
|
|
|
|
public int hashCode() {
|
|
RtcConnection.State state = this.rtcConnectionState;
|
|
int i = 0;
|
|
int hashCode = (state != null ? state.hashCode() : 0) * 31;
|
|
String str = this.channelName;
|
|
int hashCode2 = (hashCode + (str != null ? str.hashCode() : 0)) * 31;
|
|
boolean z2 = this.isSelfMuted;
|
|
int i2 = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = (hashCode2 + i3) * 31;
|
|
boolean z3 = this.isSelfDeafened;
|
|
if (z3) {
|
|
z3 = true;
|
|
}
|
|
int i7 = z3 ? 1 : 0;
|
|
int i8 = z3 ? 1 : 0;
|
|
int i9 = z3 ? 1 : 0;
|
|
int i10 = (i6 + i7) * 31;
|
|
boolean z4 = this.isSelfStreaming;
|
|
if (z4) {
|
|
z4 = true;
|
|
}
|
|
int i11 = z4 ? 1 : 0;
|
|
int i12 = z4 ? 1 : 0;
|
|
int i13 = z4 ? 1 : 0;
|
|
int i14 = (i10 + i11) * 31;
|
|
boolean z5 = this.isVideo;
|
|
if (z5) {
|
|
z5 = true;
|
|
}
|
|
int i15 = z5 ? 1 : 0;
|
|
int i16 = z5 ? 1 : 0;
|
|
int i17 = z5 ? 1 : 0;
|
|
int a = (b.a(this.channelId) + ((i14 + i15) * 31)) * 31;
|
|
Long l = this.guildId;
|
|
if (l != null) {
|
|
i = l.hashCode();
|
|
}
|
|
int i18 = (a + i) * 31;
|
|
boolean z6 = this.proximityLockEnabled;
|
|
if (z6) {
|
|
z6 = true;
|
|
}
|
|
int i19 = z6 ? 1 : 0;
|
|
int i20 = z6 ? 1 : 0;
|
|
int i21 = z6 ? 1 : 0;
|
|
int i22 = (i18 + i19) * 31;
|
|
boolean z7 = this.canSpeak;
|
|
if (!z7) {
|
|
i2 = z7 ? 1 : 0;
|
|
}
|
|
return i22 + i2;
|
|
}
|
|
|
|
public final boolean isSelfDeafened() {
|
|
return this.isSelfDeafened;
|
|
}
|
|
|
|
public final boolean isSelfMuted() {
|
|
return this.isSelfMuted;
|
|
}
|
|
|
|
public final boolean isSelfStreaming() {
|
|
return this.isSelfStreaming;
|
|
}
|
|
|
|
public final boolean isVideo() {
|
|
return this.isVideo;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("NotificationData(rtcConnectionState=");
|
|
L.append(this.rtcConnectionState);
|
|
L.append(", channelName=");
|
|
L.append(this.channelName);
|
|
L.append(", isSelfMuted=");
|
|
L.append(this.isSelfMuted);
|
|
L.append(", isSelfDeafened=");
|
|
L.append(this.isSelfDeafened);
|
|
L.append(", isSelfStreaming=");
|
|
L.append(this.isSelfStreaming);
|
|
L.append(", isVideo=");
|
|
L.append(this.isVideo);
|
|
L.append(", channelId=");
|
|
L.append(this.channelId);
|
|
L.append(", guildId=");
|
|
L.append(this.guildId);
|
|
L.append(", proximityLockEnabled=");
|
|
L.append(this.proximityLockEnabled);
|
|
L.append(", canSpeak=");
|
|
return a.G(L, this.canSpeak, ")");
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
StoreMediaSettings.SelfMuteFailure.values();
|
|
int[] iArr = new int[1];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[StoreMediaSettings.SelfMuteFailure.CANNOT_USE_VAD.ordinal()] = 1;
|
|
}
|
|
}
|
|
|
|
public VoiceEngineServiceController(StoreAudioDevices storeAudioDevices, StoreAudioManagerV2 storeAudioManagerV2, StoreMediaSettings storeMediaSettings, StoreVoiceChannelSelected storeVoiceChannelSelected, StoreRtcConnection storeRtcConnection) {
|
|
m.checkNotNullParameter(storeAudioDevices, "audioDevicesStore");
|
|
m.checkNotNullParameter(storeAudioManagerV2, "audioManagerStore");
|
|
m.checkNotNullParameter(storeMediaSettings, "mediaSettingsStore");
|
|
m.checkNotNullParameter(storeVoiceChannelSelected, "voiceChannelSelectedStore");
|
|
m.checkNotNullParameter(storeRtcConnection, "rtcConnectionStore");
|
|
this.audioDevicesStore = storeAudioDevices;
|
|
this.audioManagerStore = storeAudioManagerV2;
|
|
this.mediaSettingsStore = storeMediaSettings;
|
|
this.voiceChannelSelectedStore = storeVoiceChannelSelected;
|
|
Observable<R> Y = storeRtcConnection.getConnectionState().Y(new VoiceEngineServiceController$notificationDataObservable$1(this));
|
|
m.checkNotNullExpressionValue(Y, "rtcConnectionStore\n … }\n }");
|
|
this.notificationDataObservable = ObservableExtensionsKt.computationLatest(Y).r();
|
|
}
|
|
|
|
public static final /* synthetic */ StoreAudioDevices access$getAudioDevicesStore$p(VoiceEngineServiceController voiceEngineServiceController) {
|
|
return voiceEngineServiceController.audioDevicesStore;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreAudioManagerV2 access$getAudioManagerStore$p(VoiceEngineServiceController voiceEngineServiceController) {
|
|
return voiceEngineServiceController.audioManagerStore;
|
|
}
|
|
|
|
public static final /* synthetic */ Lazy access$getINSTANCE$cp() {
|
|
return INSTANCE$delegate;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreMediaSettings access$getMediaSettingsStore$p(VoiceEngineServiceController voiceEngineServiceController) {
|
|
return voiceEngineServiceController.mediaSettingsStore;
|
|
}
|
|
|
|
public static final /* synthetic */ NotificationData access$getNOTIFICATION_DATA_DISCONNECTED$cp() {
|
|
return NOTIFICATION_DATA_DISCONNECTED;
|
|
}
|
|
|
|
public static final /* synthetic */ VoiceEngineForegroundService.Connection access$getServiceBinding$p(VoiceEngineServiceController voiceEngineServiceController) {
|
|
VoiceEngineForegroundService.Connection connection = voiceEngineServiceController.serviceBinding;
|
|
if (connection == null) {
|
|
m.throwUninitializedPropertyAccessException("serviceBinding");
|
|
}
|
|
return connection;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreVoiceChannelSelected access$getVoiceChannelSelectedStore$p(VoiceEngineServiceController voiceEngineServiceController) {
|
|
return voiceEngineServiceController.voiceChannelSelectedStore;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setServiceBinding$p(VoiceEngineServiceController voiceEngineServiceController, VoiceEngineForegroundService.Connection connection) {
|
|
voiceEngineServiceController.serviceBinding = connection;
|
|
}
|
|
|
|
public final void init(Context context) {
|
|
m.checkNotNullParameter(context, "context");
|
|
VoiceEngineForegroundService.Companion companion = VoiceEngineForegroundService.Companion;
|
|
companion.setOnDisconnect(new VoiceEngineServiceController$init$1(this));
|
|
companion.setOnToggleSelfDeafen(new VoiceEngineServiceController$init$2(this));
|
|
companion.setOnToggleSelfMute(new VoiceEngineServiceController$init$3(this, context));
|
|
this.serviceBinding = new VoiceEngineForegroundService.Connection(context);
|
|
Observable<NotificationData> observable = this.notificationDataObservable;
|
|
m.checkNotNullExpressionValue(observable, "notificationDataObservable");
|
|
ObservableExtensionsKt.appSubscribe$default(observable, VoiceEngineServiceController.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new VoiceEngineServiceController$init$4(this, context), 62, (Object) null);
|
|
}
|
|
|
|
public final void startStream(Intent intent) {
|
|
m.checkNotNullParameter(intent, "permissionIntent");
|
|
VoiceEngineForegroundService.Companion companion = VoiceEngineForegroundService.Companion;
|
|
VoiceEngineForegroundService.Connection connection = this.serviceBinding;
|
|
if (connection == null) {
|
|
m.throwUninitializedPropertyAccessException("serviceBinding");
|
|
}
|
|
companion.startStream(connection, intent);
|
|
}
|
|
|
|
public final void stopStream() {
|
|
VoiceEngineForegroundService.Companion companion = VoiceEngineForegroundService.Companion;
|
|
VoiceEngineForegroundService.Connection connection = this.serviceBinding;
|
|
if (connection == null) {
|
|
m.throwUninitializedPropertyAccessException("serviceBinding");
|
|
}
|
|
companion.stopStream(connection);
|
|
}
|
|
}
|