- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
521 lines
18 KiB
Java
521 lines
18 KiB
Java
package com.applovin.impl;
|
|
|
|
import android.net.Uri;
|
|
import android.text.TextUtils;
|
|
import android.webkit.URLUtil;
|
|
import com.applovin.impl.aq;
|
|
import com.applovin.impl.bm;
|
|
import com.applovin.impl.f1;
|
|
import com.applovin.impl.iq;
|
|
import com.applovin.impl.sdk.utils.StringUtils;
|
|
import com.applovin.sdk.AppLovinAdLoadListener;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
|
|
/* loaded from: classes.dex */
|
|
class dm extends bm {
|
|
private final aq r;
|
|
|
|
public dm(aq aqVar, com.applovin.impl.sdk.j jVar, AppLovinAdLoadListener appLovinAdLoadListener) {
|
|
super("TaskCacheVastAd", aqVar, jVar, appLovinAdLoadListener);
|
|
this.r = aqVar;
|
|
}
|
|
|
|
@Override // com.applovin.impl.bm, java.lang.Runnable
|
|
public void run() {
|
|
super.run();
|
|
boolean I0 = this.r.I0();
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
com.applovin.impl.sdk.n nVar = this.c;
|
|
String str = this.b;
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Begin caching for VAST ");
|
|
sb.append(I0 ? "streaming " : "");
|
|
sb.append("ad #");
|
|
sb.append(this.h.getAdIdNumber());
|
|
sb.append("...");
|
|
nVar.a(str, sb.toString());
|
|
}
|
|
if (I0) {
|
|
if (((Boolean) this.a.a(sj.c1)).booleanValue()) {
|
|
if (!z3.f()) {
|
|
a(e());
|
|
}
|
|
if (this.r.w1()) {
|
|
f();
|
|
ArrayList arrayList = new ArrayList();
|
|
d1 p = p();
|
|
if (p != null) {
|
|
arrayList.add(p);
|
|
}
|
|
e1 q = q();
|
|
if (q != null) {
|
|
arrayList.add(q);
|
|
}
|
|
f1 r = r();
|
|
if (r != null) {
|
|
arrayList.add(r);
|
|
}
|
|
a(arrayList);
|
|
} else {
|
|
ArrayList arrayList2 = new ArrayList();
|
|
ArrayList arrayList3 = new ArrayList();
|
|
if (this.r.n1() == aq.c.COMPANION_AD) {
|
|
d1 p2 = p();
|
|
if (p2 != null) {
|
|
arrayList2.add(p2);
|
|
}
|
|
e1 q2 = q();
|
|
if (q2 != null) {
|
|
arrayList2.add(q2);
|
|
}
|
|
a(arrayList2);
|
|
f();
|
|
f1 r2 = r();
|
|
if (r2 != null) {
|
|
arrayList3.add(r2);
|
|
}
|
|
a(arrayList3);
|
|
} else {
|
|
f1 r3 = r();
|
|
if (r3 != null) {
|
|
arrayList2.add(r3);
|
|
}
|
|
a(arrayList2);
|
|
f();
|
|
d1 p3 = p();
|
|
if (p3 != null) {
|
|
arrayList3.add(p3);
|
|
}
|
|
e1 q3 = q();
|
|
if (q3 != null) {
|
|
arrayList3.add(q3);
|
|
}
|
|
a(arrayList3);
|
|
}
|
|
}
|
|
} else {
|
|
j();
|
|
if (this.r.w1()) {
|
|
f();
|
|
}
|
|
aq.c n1 = this.r.n1();
|
|
aq.c cVar = aq.c.COMPANION_AD;
|
|
if (n1 == cVar) {
|
|
m();
|
|
n();
|
|
a(this.r);
|
|
} else {
|
|
o();
|
|
}
|
|
if (!this.r.w1()) {
|
|
f();
|
|
}
|
|
if (this.r.n1() == cVar) {
|
|
o();
|
|
} else {
|
|
m();
|
|
n();
|
|
a(this.r);
|
|
}
|
|
}
|
|
} else if (((Boolean) this.a.a(sj.c1)).booleanValue()) {
|
|
ArrayList arrayList4 = new ArrayList();
|
|
if (!z3.f()) {
|
|
arrayList4.addAll(e());
|
|
}
|
|
d1 p4 = p();
|
|
if (p4 != null) {
|
|
arrayList4.add(p4);
|
|
}
|
|
f1 r4 = r();
|
|
if (r4 != null) {
|
|
arrayList4.add(r4);
|
|
}
|
|
e1 q4 = q();
|
|
if (q4 != null) {
|
|
arrayList4.add(q4);
|
|
}
|
|
a(arrayList4);
|
|
f();
|
|
} else {
|
|
j();
|
|
m();
|
|
o();
|
|
n();
|
|
a(this.r);
|
|
f();
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Finished caching VAST ad #" + this.r.getAdIdNumber());
|
|
}
|
|
this.r.x1();
|
|
k();
|
|
}
|
|
|
|
private void m() {
|
|
if (l()) {
|
|
return;
|
|
}
|
|
if (this.r.y1()) {
|
|
dq j1 = this.r.j1();
|
|
if (j1 != null) {
|
|
iq d2 = j1.d();
|
|
if (d2 != null) {
|
|
Uri b2 = d2.b();
|
|
String uri = b2 != null ? b2.toString() : "";
|
|
String a2 = d2.a();
|
|
if (!URLUtil.isValidUrl(uri) && !StringUtils.isValidString(a2)) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.k(this.b, "Companion ad does not have any resources attached. Skipping...");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (d2.c() == iq.a.STATIC) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Caching static companion ad at " + uri + "...");
|
|
}
|
|
Uri a3 = a(uri, Collections.emptyList(), false);
|
|
if (a3 != null) {
|
|
d2.a(a3);
|
|
this.r.b(true);
|
|
return;
|
|
} else {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.b(this.b, "Failed to cache static companion ad");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (d2.c() == iq.a.HTML) {
|
|
if (StringUtils.isValidString(uri)) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Begin caching HTML companion ad. Fetching from " + uri + "...");
|
|
}
|
|
String d3 = d(uri, null, false);
|
|
if (StringUtils.isValidString(d3)) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "HTML fetched. Caching HTML now...");
|
|
}
|
|
d2.a(a(d3, Collections.emptyList(), this.r));
|
|
this.r.b(true);
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.b(this.b, "Unable to load companion ad resources from " + uri);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Caching provided HTML for companion ad. No fetch required. HTML: " + a2);
|
|
}
|
|
if (((Boolean) this.a.a(sj.k5)).booleanValue()) {
|
|
a2 = d(a2);
|
|
}
|
|
d2.a(a(a2, Collections.emptyList(), this.r));
|
|
this.r.b(true);
|
|
return;
|
|
}
|
|
if (d2.c() == iq.a.IFRAME && com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Skip caching of iFrame resource...");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.b(this.b, "Failed to retrieve non-video resources from companion ad. Skipping...");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "No companion ad provided. Skipping...");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Companion ad caching disabled. Skipping...");
|
|
}
|
|
}
|
|
|
|
private void o() {
|
|
oq u1;
|
|
Uri d2;
|
|
if (l()) {
|
|
return;
|
|
}
|
|
if (this.r.z1()) {
|
|
if (this.r.t1() == null || (u1 = this.r.u1()) == null || (d2 = u1.d()) == null) {
|
|
return;
|
|
}
|
|
Uri c2 = c(d2.toString(), Collections.emptyList(), false);
|
|
if (c2 != null) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Video file successfully cached into: " + c2);
|
|
}
|
|
u1.a(c2);
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.b(this.b, "Failed to cache video file: " + u1);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Video caching disabled. Skipping...");
|
|
}
|
|
}
|
|
|
|
private void n() {
|
|
String l1;
|
|
if (l() || !mq.a(this.r)) {
|
|
return;
|
|
}
|
|
if (this.r.m1() != null) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Begin caching HTML template. Fetching from " + this.r.m1() + "...");
|
|
}
|
|
l1 = b(this.r.m1().toString(), this.r.X(), true);
|
|
} else {
|
|
l1 = this.r.l1();
|
|
}
|
|
if (StringUtils.isValidString(l1)) {
|
|
String a2 = a(l1, this.r.X(), this.h);
|
|
if (this.r.isOpenMeasurementEnabled()) {
|
|
a2 = this.a.W().a(a2);
|
|
}
|
|
this.r.b(a2);
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Finish caching HTML template " + this.r.l1() + " for ad #" + this.r.getAdIdNumber());
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Unable to load HTML template");
|
|
}
|
|
}
|
|
|
|
private String d(String str) {
|
|
for (String str2 : StringUtils.getRegexMatches(StringUtils.match(str, (String) this.a.a(sj.m5)), 1)) {
|
|
if (!TextUtils.isEmpty(str2)) {
|
|
Uri a2 = a(str2, Collections.emptyList(), false);
|
|
if (a2 != null) {
|
|
str = str.replace(str2, a2.toString());
|
|
this.h.a(a2);
|
|
this.i.d();
|
|
} else {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.b(this.b, "Failed to cache JavaScript resource: " + str2);
|
|
}
|
|
this.i.c();
|
|
}
|
|
}
|
|
}
|
|
return str;
|
|
}
|
|
|
|
private d1 p() {
|
|
if (!this.r.y1()) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Companion ad caching disabled. Skipping...");
|
|
}
|
|
return null;
|
|
}
|
|
dq j1 = this.r.j1();
|
|
if (j1 == null) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "No companion ad provided. Skipping...");
|
|
}
|
|
return null;
|
|
}
|
|
iq d2 = j1.d();
|
|
if (d2 == null) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.b(this.b, "Failed to retrieve non-video resources from companion ad. Skipping...");
|
|
}
|
|
return null;
|
|
}
|
|
Uri b2 = d2.b();
|
|
String uri = b2 != null ? b2.toString() : "";
|
|
String a2 = d2.a();
|
|
if (!URLUtil.isValidUrl(uri) && !StringUtils.isValidString(a2)) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.k(this.b, "Companion ad does not have any resources attached. Skipping...");
|
|
}
|
|
} else {
|
|
if (d2.c() == iq.a.STATIC) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Caching static companion ad at " + uri + "...");
|
|
}
|
|
return new f1(uri, this.r, Collections.emptyList(), false, this.i, this.a, new a(d2));
|
|
}
|
|
if (d2.c() == iq.a.HTML) {
|
|
if (StringUtils.isValidString(uri)) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Begin caching HTML companion ad. Fetching from " + uri + "...");
|
|
}
|
|
String d3 = d(uri, null, false);
|
|
if (StringUtils.isValidString(d3)) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "HTML fetched. Caching HTML now...");
|
|
}
|
|
return a(d3, Collections.emptyList(), new b(d2));
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.b(this.b, "Unable to load companion ad resources from " + uri);
|
|
}
|
|
} else {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Caching provided HTML for companion ad. No fetch required. HTML: " + a2);
|
|
}
|
|
return a(a2, Collections.emptyList(), new c(d2));
|
|
}
|
|
} else if (d2.c() == iq.a.IFRAME && com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Skip caching of iFrame resource...");
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public class a implements f1.a {
|
|
final /* synthetic */ iq a;
|
|
|
|
public a(iq iqVar) {
|
|
this.a = iqVar;
|
|
}
|
|
|
|
@Override // com.applovin.impl.f1.a
|
|
public void a(Uri uri) {
|
|
if (uri != null) {
|
|
this.a.a(uri);
|
|
dm.this.r.b(true);
|
|
return;
|
|
}
|
|
com.applovin.impl.sdk.n nVar = dm.this.c;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
dm dmVar = dm.this;
|
|
dmVar.c.b(dmVar.b, "Failed to cache static companion ad");
|
|
}
|
|
}
|
|
}
|
|
|
|
public class b implements bm.e {
|
|
final /* synthetic */ iq a;
|
|
|
|
public b(iq iqVar) {
|
|
this.a = iqVar;
|
|
}
|
|
|
|
@Override // com.applovin.impl.bm.e
|
|
public void a(String str) {
|
|
this.a.a(str);
|
|
dm.this.r.b(true);
|
|
}
|
|
}
|
|
|
|
public class c implements bm.e {
|
|
final /* synthetic */ iq a;
|
|
|
|
public c(iq iqVar) {
|
|
this.a = iqVar;
|
|
}
|
|
|
|
@Override // com.applovin.impl.bm.e
|
|
public void a(String str) {
|
|
this.a.a(str);
|
|
dm.this.r.b(true);
|
|
}
|
|
}
|
|
|
|
public f1 r() {
|
|
oq u1;
|
|
Uri d2;
|
|
if (!this.r.z1()) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Video caching disabled. Skipping...");
|
|
}
|
|
return null;
|
|
}
|
|
if (this.r.t1() == null || (u1 = this.r.u1()) == null || (d2 = u1.d()) == null) {
|
|
return null;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Caching video file " + u1 + " creative...");
|
|
}
|
|
return a(d2.toString(), Collections.emptyList(), false, (f1.a) new d(u1));
|
|
}
|
|
|
|
public class d implements f1.a {
|
|
final /* synthetic */ oq a;
|
|
|
|
public d(oq oqVar) {
|
|
this.a = oqVar;
|
|
}
|
|
|
|
@Override // com.applovin.impl.f1.a
|
|
public void a(Uri uri) {
|
|
if (uri != null) {
|
|
com.applovin.impl.sdk.n nVar = dm.this.c;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
dm dmVar = dm.this;
|
|
dmVar.c.a(dmVar.b, "Video file successfully cached into: " + uri);
|
|
}
|
|
this.a.a(uri);
|
|
return;
|
|
}
|
|
com.applovin.impl.sdk.n nVar2 = dm.this.c;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
dm dmVar2 = dm.this;
|
|
dmVar2.c.b(dmVar2.b, "Failed to cache video file: " + this.a);
|
|
}
|
|
}
|
|
}
|
|
|
|
public e1 q() {
|
|
if (TextUtils.isEmpty(this.r.l1())) {
|
|
if (!com.applovin.impl.sdk.n.a()) {
|
|
return null;
|
|
}
|
|
this.c.a(this.b, "Unable to load HTML template");
|
|
return null;
|
|
}
|
|
return a(this.r.l1(), this.r.X(), new e());
|
|
}
|
|
|
|
public class e implements bm.e {
|
|
public e() {
|
|
}
|
|
|
|
@Override // com.applovin.impl.bm.e
|
|
public void a(String str) {
|
|
if (dm.this.r.isOpenMeasurementEnabled()) {
|
|
str = dm.this.a.W().a(str);
|
|
}
|
|
dm.this.r.b(str);
|
|
com.applovin.impl.sdk.n nVar = dm.this.c;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
dm dmVar = dm.this;
|
|
dmVar.c.a(dmVar.b, "Finish caching HTML template " + dm.this.r.l1() + " for ad #" + dm.this.r.getAdIdNumber());
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.applovin.impl.bm
|
|
public void f() {
|
|
this.r.getAdEventTracker().h();
|
|
super.f();
|
|
}
|
|
|
|
@Override // com.applovin.impl.bm
|
|
public void a(int i) {
|
|
this.r.getAdEventTracker().f();
|
|
super.a(i);
|
|
}
|
|
}
|