discord-jadx/app/src/main/java/androidx/media/AudioAttributesImplBase.java

260 lines
8.2 KiB
Java

package androidx.media;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.media.AudioAttributesImpl;
import java.util.Arrays;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public class AudioAttributesImplBase implements AudioAttributesImpl {
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int mContentType = 0;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int mFlags = 0;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int mLegacyStream = -1;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int mUsage = 0;
public static class Builder implements AudioAttributesImpl.Builder {
private int mContentType = 0;
private int mFlags = 0;
private int mLegacyStream = -1;
private int mUsage = 0;
public Builder() {
}
public Builder(AudioAttributesCompat audioAttributesCompat) {
this.mUsage = audioAttributesCompat.getUsage();
this.mContentType = audioAttributesCompat.getContentType();
this.mFlags = audioAttributesCompat.getFlags();
this.mLegacyStream = audioAttributesCompat.getRawLegacyStreamType();
}
/* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
private Builder setInternalLegacyStreamType(int i) {
switch (i) {
case 0:
this.mContentType = 1;
break;
case 1:
this.mContentType = 4;
break;
case 2:
this.mContentType = 4;
break;
case 3:
this.mContentType = 2;
break;
case 4:
this.mContentType = 4;
break;
case 5:
this.mContentType = 4;
break;
case 6:
this.mContentType = 1;
this.mFlags |= 4;
break;
case 7:
this.mFlags = 1 | this.mFlags;
this.mContentType = 4;
break;
case 8:
this.mContentType = 4;
break;
case 9:
this.mContentType = 4;
break;
case 10:
this.mContentType = 1;
break;
default:
Log.e(AudioAttributesCompat.TAG, "Invalid stream type " + i + " for AudioAttributesCompat");
break;
}
this.mUsage = AudioAttributesImplBase.usageForStreamType(i);
return this;
}
@Override // androidx.media.AudioAttributesImpl.Builder
@NonNull
public AudioAttributesImpl build() {
return new AudioAttributesImplBase(this.mContentType, this.mFlags, this.mUsage, this.mLegacyStream);
}
@Override // androidx.media.AudioAttributesImpl.Builder
@NonNull
public Builder setContentType(int i) {
if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4) {
this.mContentType = i;
} else {
this.mContentType = 0;
}
return this;
}
@Override // androidx.media.AudioAttributesImpl.Builder
@NonNull
public Builder setFlags(int i) {
this.mFlags = (i & AudioAttributesCompat.FLAG_ALL) | this.mFlags;
return this;
}
@Override // androidx.media.AudioAttributesImpl.Builder
@NonNull
public Builder setLegacyStreamType(int i) {
if (i != 10) {
this.mLegacyStream = i;
return setInternalLegacyStreamType(i);
}
throw new IllegalArgumentException("STREAM_ACCESSIBILITY is not a legacy stream type that was used for audio playback");
}
@Override // androidx.media.AudioAttributesImpl.Builder
@NonNull
public Builder setUsage(int i) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
this.mUsage = i;
break;
case 16:
this.mUsage = 12;
break;
default:
this.mUsage = 0;
break;
}
return this;
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public AudioAttributesImplBase() {
}
public AudioAttributesImplBase(int i, int i2, int i3, int i4) {
this.mContentType = i;
this.mFlags = i2;
this.mUsage = i3;
this.mLegacyStream = i4;
}
public static int usageForStreamType(int i) {
switch (i) {
case 0:
return 2;
case 1:
case 7:
return 13;
case 2:
return 6;
case 3:
return 1;
case 4:
return 4;
case 5:
return 5;
case 6:
return 2;
case 8:
return 3;
case 9:
default:
return 0;
case 10:
return 11;
}
}
public boolean equals(Object obj) {
if (!(obj instanceof AudioAttributesImplBase)) {
return false;
}
AudioAttributesImplBase audioAttributesImplBase = (AudioAttributesImplBase) obj;
return this.mContentType == audioAttributesImplBase.getContentType() && this.mFlags == audioAttributesImplBase.getFlags() && this.mUsage == audioAttributesImplBase.getUsage() && this.mLegacyStream == audioAttributesImplBase.mLegacyStream;
}
@Override // androidx.media.AudioAttributesImpl
@Nullable
public Object getAudioAttributes() {
return null;
}
@Override // androidx.media.AudioAttributesImpl
public int getContentType() {
return this.mContentType;
}
@Override // androidx.media.AudioAttributesImpl
public int getFlags() {
int i = this.mFlags;
int legacyStreamType = getLegacyStreamType();
if (legacyStreamType == 6) {
i |= 4;
} else if (legacyStreamType == 7) {
i |= 1;
}
return i & AudioAttributesCompat.FLAG_ALL_PUBLIC;
}
@Override // androidx.media.AudioAttributesImpl
public int getLegacyStreamType() {
int i = this.mLegacyStream;
return i != -1 ? i : AudioAttributesCompat.toVolumeStreamType(false, this.mFlags, this.mUsage);
}
@Override // androidx.media.AudioAttributesImpl
public int getRawLegacyStreamType() {
return this.mLegacyStream;
}
@Override // androidx.media.AudioAttributesImpl
public int getUsage() {
return this.mUsage;
}
@Override // androidx.media.AudioAttributesImpl
public int getVolumeControlStream() {
return AudioAttributesCompat.toVolumeStreamType(true, this.mFlags, this.mUsage);
}
public int hashCode() {
return Arrays.hashCode(new Object[]{Integer.valueOf(this.mContentType), Integer.valueOf(this.mFlags), Integer.valueOf(this.mUsage), Integer.valueOf(this.mLegacyStream)});
}
@NonNull
public String toString() {
StringBuilder sb = new StringBuilder("AudioAttributesCompat:");
if (this.mLegacyStream != -1) {
sb.append(" stream=");
sb.append(this.mLegacyStream);
sb.append(" derived");
}
sb.append(" usage=");
sb.append(AudioAttributesCompat.usageToString(this.mUsage));
sb.append(" content=");
sb.append(this.mContentType);
sb.append(" flags=0x");
sb.append(Integer.toHexString(this.mFlags).toUpperCase());
return sb.toString();
}
}