discord-jadx/app/src/main/java/c/i/a/c/z1/a0.java

128 lines
4.6 KiB
Java

package c.i.a.c.z1;
import android.net.Uri;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import c.i.a.c.h0;
import c.i.a.c.h2.k;
import c.i.a.c.h2.l;
import c.i.a.c.h2.q;
import c.i.a.c.h2.s;
import c.i.a.c.h2.v;
import c.i.a.c.i2.f0;
import c.i.a.c.z1.x;
import c.i.b.b.r0;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.google.android.exoplayer2.drm.MediaDrmCallbackException;
import com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
/* compiled from: HttpMediaDrmCallback */
public final class a0 implements b0 {
public final s a;
@Nullable
public final String b;
/* renamed from: c reason: collision with root package name */
public final boolean f1010c;
public final Map<String, String> d;
public a0(@Nullable String str, boolean z2, s sVar) {
AnimatableValueParser.k(!z2 || !TextUtils.isEmpty(str));
this.a = sVar;
this.b = str;
this.f1010c = z2;
this.d = new HashMap();
}
public static byte[] b(s sVar, String str, @Nullable byte[] bArr, Map<String, String> map) throws MediaDrmCallbackException {
List<String> list;
v vVar = new v(((q.b) sVar).a());
Collections.emptyMap();
Uri parse = Uri.parse(str);
AnimatableValueParser.I(parse, "The uri must be set.");
l lVar = new l(parse, 0, 2, bArr, map, 0, -1, null, 1, null);
l lVar2 = lVar;
int i = 0;
while (true) {
try {
k kVar = new k(vVar, lVar2);
try {
byte[] J = f0.J(kVar);
int i2 = f0.a;
try {
kVar.close();
} catch (IOException unused) {
}
return J;
} catch (HttpDataSource$InvalidResponseCodeException e) {
int i3 = e.responseCode;
String str2 = null;
if ((i3 == 307 || i3 == 308) && i < 5) {
Map<String, List<String>> map2 = e.headerFields;
if (!(map2 == null || (list = map2.get("Location")) == null || list.isEmpty())) {
str2 = list.get(0);
}
}
if (str2 != null) {
i++;
l.b a = lVar2.a();
a.a = Uri.parse(str2);
lVar2 = a.a();
int i4 = f0.a;
try {
kVar.close();
} catch (IOException unused2) {
}
} else {
throw e;
}
} catch (Throwable th) {
int i5 = f0.a;
try {
kVar.close();
} catch (IOException unused3) {
}
throw th;
}
} catch (Exception e2) {
Uri uri = vVar.f886c;
Objects.requireNonNull(uri);
throw new MediaDrmCallbackException(lVar, uri, vVar.j(), vVar.b, e2);
}
}
}
public byte[] a(UUID uuid, x.a aVar) throws MediaDrmCallbackException {
String str = aVar.b;
if (this.f1010c || TextUtils.isEmpty(str)) {
str = this.b;
}
if (!TextUtils.isEmpty(str)) {
HashMap hashMap = new HashMap();
UUID uuid2 = h0.e;
hashMap.put("Content-Type", uuid2.equals(uuid) ? "text/xml" : h0.f873c.equals(uuid) ? "application/json" : "application/octet-stream");
if (uuid2.equals(uuid)) {
hashMap.put("SOAPAction", "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
}
synchronized (this.d) {
hashMap.putAll(this.d);
}
return b(this.a, str, aVar.a, hashMap);
}
Map emptyMap = Collections.emptyMap();
Uri uri = Uri.EMPTY;
AnimatableValueParser.I(uri, "The uri must be set.");
throw new MediaDrmCallbackException(new l(uri, 0, 1, null, emptyMap, 0, -1, null, 0, null), Uri.EMPTY, r0.l, 0, new IllegalStateException("No license URL"));
}
public byte[] c(UUID uuid, x.d dVar) throws MediaDrmCallbackException {
return b(this.a, dVar.b + "&signedRequest=" + f0.l(dVar.a), null, Collections.emptyMap());
}
}