- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
543 lines
15 KiB
Java
543 lines
15 KiB
Java
package com.applovin.impl;
|
|
|
|
import android.media.NotProvisionedException;
|
|
import android.os.Handler;
|
|
import android.os.HandlerThread;
|
|
import android.os.Looper;
|
|
import android.os.Message;
|
|
import android.os.SystemClock;
|
|
import android.util.Pair;
|
|
import com.applovin.impl.a7;
|
|
import com.applovin.impl.mc;
|
|
import com.applovin.impl.z6;
|
|
import com.applovin.impl.z7;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.C;
|
|
import java.io.IOException;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
/* loaded from: classes.dex */
|
|
class x5 implements z6 {
|
|
public final List a;
|
|
private final z7 b;
|
|
private final a c;
|
|
private final b d;
|
|
private final int e;
|
|
private final boolean f;
|
|
private final boolean g;
|
|
private final HashMap h;
|
|
private final u4 i;
|
|
private final mc j;
|
|
final qd k;
|
|
final UUID l;
|
|
final e m;
|
|
private int n;
|
|
private int o;
|
|
private HandlerThread p;
|
|
private c q;
|
|
private z4 r;
|
|
private z6.a s;
|
|
private byte[] t;
|
|
private byte[] u;
|
|
private z7.a v;
|
|
private z7.d w;
|
|
|
|
public interface a {
|
|
void a();
|
|
|
|
void a(x5 x5Var);
|
|
|
|
void a(Exception exc, boolean z);
|
|
}
|
|
|
|
public interface b {
|
|
void a(x5 x5Var, int i);
|
|
|
|
void b(x5 x5Var, int i);
|
|
}
|
|
|
|
private boolean g() {
|
|
int i = this.n;
|
|
return i == 3 || i == 4;
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public final int b() {
|
|
return this.n;
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public boolean c() {
|
|
return this.f;
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public final UUID e() {
|
|
return this.l;
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public final z4 f() {
|
|
return this.r;
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public final z6.a getError() {
|
|
if (this.n == 1) {
|
|
return this.s;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static final class f extends IOException {
|
|
public f(Throwable th) {
|
|
super(th);
|
|
}
|
|
}
|
|
|
|
public x5(UUID uuid, z7 z7Var, a aVar, b bVar, List list, int i, boolean z, boolean z2, byte[] bArr, HashMap hashMap, qd qdVar, Looper looper, mc mcVar) {
|
|
if (i == 1 || i == 3) {
|
|
b1.a(bArr);
|
|
}
|
|
this.l = uuid;
|
|
this.c = aVar;
|
|
this.d = bVar;
|
|
this.b = z7Var;
|
|
this.e = i;
|
|
this.f = z;
|
|
this.g = z2;
|
|
if (bArr != null) {
|
|
this.u = bArr;
|
|
this.a = null;
|
|
} else {
|
|
this.a = Collections.unmodifiableList((List) b1.a(list));
|
|
}
|
|
this.h = hashMap;
|
|
this.k = qdVar;
|
|
this.i = new u4();
|
|
this.j = mcVar;
|
|
this.n = 2;
|
|
this.m = new e(looper);
|
|
}
|
|
|
|
public void k() {
|
|
this.w = this.b.b();
|
|
((c) xp.a(this.q)).a(0, b1.a(this.w), true);
|
|
}
|
|
|
|
public void i() {
|
|
if (j()) {
|
|
a(true);
|
|
}
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public Map d() {
|
|
byte[] bArr = this.t;
|
|
if (bArr == null) {
|
|
return null;
|
|
}
|
|
return this.b.b(bArr);
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public void b(a7.a aVar) {
|
|
b1.b(this.o >= 0);
|
|
if (aVar != null) {
|
|
this.i.a(aVar);
|
|
}
|
|
int i = this.o + 1;
|
|
this.o = i;
|
|
if (i == 1) {
|
|
b1.b(this.n == 2);
|
|
HandlerThread handlerThread = new HandlerThread("ExoPlayer:DrmRequestHandler");
|
|
this.p = handlerThread;
|
|
handlerThread.start();
|
|
this.q = new c(this.p.getLooper());
|
|
if (j()) {
|
|
a(true);
|
|
}
|
|
} else if (aVar != null && g() && this.i.b(aVar) == 1) {
|
|
aVar.a(this.n);
|
|
}
|
|
this.d.a(this, this.o);
|
|
}
|
|
|
|
private boolean j() {
|
|
if (g()) {
|
|
return true;
|
|
}
|
|
try {
|
|
byte[] d2 = this.b.d();
|
|
this.t = d2;
|
|
this.r = this.b.d(d2);
|
|
final int i = 3;
|
|
this.n = 3;
|
|
a(new r4() { // from class: com.applovin.impl.x5$$ExternalSyntheticLambda2
|
|
@Override // com.applovin.impl.r4
|
|
public final void accept(Object obj) {
|
|
((a7.a) obj).a(i);
|
|
}
|
|
});
|
|
b1.a(this.t);
|
|
return true;
|
|
} catch (NotProvisionedException unused) {
|
|
this.c.a(this);
|
|
return false;
|
|
} catch (Exception e2) {
|
|
a(e2, 1);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private boolean l() {
|
|
try {
|
|
this.b.a(this.t, this.u);
|
|
return true;
|
|
} catch (Exception e2) {
|
|
a(e2, 1);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void h() {
|
|
if (this.e == 0 && this.n == 4) {
|
|
xp.a((Object) this.t);
|
|
a(false);
|
|
}
|
|
}
|
|
|
|
public class e extends Handler {
|
|
public e(Looper looper) {
|
|
super(looper);
|
|
}
|
|
|
|
@Override // android.os.Handler
|
|
public void handleMessage(Message message) {
|
|
Pair pair = (Pair) message.obj;
|
|
Object obj = pair.first;
|
|
Object obj2 = pair.second;
|
|
int i = message.what;
|
|
if (i == 0) {
|
|
x5.this.b(obj, obj2);
|
|
} else {
|
|
if (i != 1) {
|
|
return;
|
|
}
|
|
x5.this.a(obj, obj2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class c extends Handler {
|
|
private boolean a;
|
|
|
|
public c(Looper looper) {
|
|
super(looper);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // android.os.Handler
|
|
public void handleMessage(Message message) {
|
|
Throwable th;
|
|
d dVar = (d) message.obj;
|
|
try {
|
|
int i = message.what;
|
|
if (i == 0) {
|
|
x5 x5Var = x5.this;
|
|
th = x5Var.k.a(x5Var.l, (z7.d) dVar.d);
|
|
} else if (i == 1) {
|
|
x5 x5Var2 = x5.this;
|
|
th = x5Var2.k.a(x5Var2.l, (z7.a) dVar.d);
|
|
} else {
|
|
throw new RuntimeException();
|
|
}
|
|
} catch (rd e) {
|
|
boolean a = a(message, e);
|
|
th = e;
|
|
if (a) {
|
|
return;
|
|
}
|
|
} catch (Exception e2) {
|
|
pc.c("DefaultDrmSession", "Key/provisioning request produced an unexpected exception. Not retrying.", e2);
|
|
th = e2;
|
|
}
|
|
x5.this.j.a(dVar.a);
|
|
synchronized (this) {
|
|
try {
|
|
if (!this.a) {
|
|
x5.this.m.obtainMessage(message.what, Pair.create(dVar.d, th)).sendToTarget();
|
|
}
|
|
} finally {
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean a(Message message, rd rdVar) {
|
|
IOException fVar;
|
|
d dVar = (d) message.obj;
|
|
if (!dVar.b) {
|
|
return false;
|
|
}
|
|
int i = dVar.e + 1;
|
|
dVar.e = i;
|
|
if (i > x5.this.j.a(3)) {
|
|
return false;
|
|
}
|
|
nc ncVar = new nc(dVar.a, rdVar.a, rdVar.b, rdVar.c, SystemClock.elapsedRealtime(), SystemClock.elapsedRealtime() - dVar.c, rdVar.d);
|
|
ud udVar = new ud(3);
|
|
if (rdVar.getCause() instanceof IOException) {
|
|
fVar = (IOException) rdVar.getCause();
|
|
} else {
|
|
fVar = new f(rdVar.getCause());
|
|
}
|
|
long a = x5.this.j.a(new mc.a(ncVar, udVar, fVar, dVar.e));
|
|
if (a == C.TIME_UNSET) {
|
|
return false;
|
|
}
|
|
synchronized (this) {
|
|
try {
|
|
if (this.a) {
|
|
return false;
|
|
}
|
|
sendMessageDelayed(Message.obtain(message), a);
|
|
return true;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void a(int i, Object obj, boolean z) {
|
|
obtainMessage(i, new d(nc.a(), z, SystemClock.elapsedRealtime(), obj)).sendToTarget();
|
|
}
|
|
|
|
public synchronized void a() {
|
|
removeCallbacksAndMessages(null);
|
|
this.a = true;
|
|
}
|
|
}
|
|
|
|
private void a(r4 r4Var) {
|
|
Iterator it = this.i.a().iterator();
|
|
while (it.hasNext()) {
|
|
r4Var.accept((a7.a) it.next());
|
|
}
|
|
}
|
|
|
|
public static final class d {
|
|
public final long a;
|
|
public final boolean b;
|
|
public final long c;
|
|
public final Object d;
|
|
public int e;
|
|
|
|
public d(long j, boolean z, long j2, Object obj) {
|
|
this.a = j;
|
|
this.b = z;
|
|
this.c = j2;
|
|
this.d = obj;
|
|
}
|
|
}
|
|
|
|
public void b(Exception exc, boolean z) {
|
|
a(exc, z ? 1 : 3);
|
|
}
|
|
|
|
private void a(boolean z) {
|
|
if (this.g) {
|
|
return;
|
|
}
|
|
byte[] bArr = (byte[]) xp.a((Object) this.t);
|
|
int i = this.e;
|
|
if (i != 0 && i != 1) {
|
|
if (i == 2) {
|
|
if (this.u == null || l()) {
|
|
a(bArr, 2, z);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (i != 3) {
|
|
return;
|
|
}
|
|
b1.a(this.u);
|
|
b1.a(this.t);
|
|
a(this.u, 3, z);
|
|
return;
|
|
}
|
|
if (this.u == null) {
|
|
a(bArr, 1, z);
|
|
return;
|
|
}
|
|
if (this.n == 4 || l()) {
|
|
long a2 = a();
|
|
if (this.e != 0 || a2 > 60) {
|
|
if (a2 <= 0) {
|
|
a(new zb(), 2);
|
|
return;
|
|
} else {
|
|
this.n = 4;
|
|
a(new r4() { // from class: com.applovin.impl.x5$$ExternalSyntheticLambda1
|
|
@Override // com.applovin.impl.r4
|
|
public final void accept(Object obj) {
|
|
((a7.a) obj).c();
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
pc.a("DefaultDrmSession", "Offline license has expired or will expire soon. Remaining seconds: " + a2);
|
|
a(bArr, 2, z);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void b(Object obj, Object obj2) {
|
|
if (obj == this.w) {
|
|
if (this.n == 2 || g()) {
|
|
this.w = null;
|
|
if (obj2 instanceof Exception) {
|
|
this.c.a((Exception) obj2, false);
|
|
return;
|
|
}
|
|
try {
|
|
this.b.a((byte[]) obj2);
|
|
this.c.a();
|
|
} catch (Exception e2) {
|
|
this.c.a(e2, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public boolean a(byte[] bArr) {
|
|
return Arrays.equals(this.t, bArr);
|
|
}
|
|
|
|
private void a(final Exception exc, int i) {
|
|
this.s = new z6.a(exc, d7.a(exc, i));
|
|
pc.a("DefaultDrmSession", "DRM session error", exc);
|
|
a(new r4() { // from class: com.applovin.impl.x5$$ExternalSyntheticLambda0
|
|
@Override // com.applovin.impl.r4
|
|
public final void accept(Object obj) {
|
|
((a7.a) obj).a(exc);
|
|
}
|
|
});
|
|
if (this.n != 4) {
|
|
this.n = 1;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(Object obj, Object obj2) {
|
|
if (obj == this.v && g()) {
|
|
this.v = null;
|
|
if (obj2 instanceof Exception) {
|
|
a((Exception) obj2, false);
|
|
return;
|
|
}
|
|
try {
|
|
byte[] bArr = (byte[]) obj2;
|
|
if (this.e == 3) {
|
|
this.b.b((byte[]) xp.a((Object) this.u), bArr);
|
|
a(new r4() { // from class: com.applovin.impl.x5$$ExternalSyntheticLambda3
|
|
@Override // com.applovin.impl.r4
|
|
public final void accept(Object obj3) {
|
|
((a7.a) obj3).b();
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
byte[] b2 = this.b.b(this.t, bArr);
|
|
int i = this.e;
|
|
if ((i == 2 || (i == 0 && this.u != null)) && b2 != null && b2.length != 0) {
|
|
this.u = b2;
|
|
}
|
|
this.n = 4;
|
|
a(new r4() { // from class: com.applovin.impl.x5$$ExternalSyntheticLambda4
|
|
@Override // com.applovin.impl.r4
|
|
public final void accept(Object obj3) {
|
|
((a7.a) obj3).a();
|
|
}
|
|
});
|
|
} catch (Exception e2) {
|
|
a(e2, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(Exception exc, boolean z) {
|
|
if (exc instanceof NotProvisionedException) {
|
|
this.c.a(this);
|
|
} else {
|
|
a(exc, z ? 1 : 2);
|
|
}
|
|
}
|
|
|
|
public void a(int i) {
|
|
if (i != 2) {
|
|
return;
|
|
}
|
|
h();
|
|
}
|
|
|
|
private void a(byte[] bArr, int i, boolean z) {
|
|
try {
|
|
this.v = this.b.a(bArr, this.a, i, this.h);
|
|
((c) xp.a(this.q)).a(1, b1.a(this.v), z);
|
|
} catch (Exception e2) {
|
|
a(e2, true);
|
|
}
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public void a(a7.a aVar) {
|
|
b1.b(this.o > 0);
|
|
int i = this.o - 1;
|
|
this.o = i;
|
|
if (i == 0) {
|
|
this.n = 0;
|
|
((e) xp.a(this.m)).removeCallbacksAndMessages(null);
|
|
((c) xp.a(this.q)).a();
|
|
this.q = null;
|
|
((HandlerThread) xp.a(this.p)).quit();
|
|
this.p = null;
|
|
this.r = null;
|
|
this.s = null;
|
|
this.v = null;
|
|
this.w = null;
|
|
byte[] bArr = this.t;
|
|
if (bArr != null) {
|
|
this.b.c(bArr);
|
|
this.t = null;
|
|
}
|
|
}
|
|
if (aVar != null) {
|
|
this.i.c(aVar);
|
|
if (this.i.b(aVar) == 0) {
|
|
aVar.d();
|
|
}
|
|
}
|
|
this.d.b(this, this.o);
|
|
}
|
|
|
|
@Override // com.applovin.impl.z6
|
|
public boolean a(String str) {
|
|
return this.b.a((byte[]) b1.b(this.t), str);
|
|
}
|
|
|
|
private long a() {
|
|
if (!t2.d.equals(this.l)) {
|
|
return Long.MAX_VALUE;
|
|
}
|
|
Pair pair = (Pair) b1.a(bs.a(this));
|
|
return Math.min(((Long) pair.first).longValue(), ((Long) pair.second).longValue());
|
|
}
|
|
}
|