- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
467 lines
18 KiB
Java
467 lines
18 KiB
Java
package com.applovin.impl;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.os.SystemClock;
|
|
import com.applovin.impl.mediation.MaxAdWaterfallInfoImpl;
|
|
import com.applovin.impl.mediation.MaxErrorImpl;
|
|
import com.applovin.impl.mediation.MaxNetworkResponseInfoImpl;
|
|
import com.applovin.impl.mediation.ads.a;
|
|
import com.applovin.impl.sdk.utils.JsonUtils;
|
|
import com.applovin.impl.tm;
|
|
import com.applovin.impl.wm;
|
|
import com.applovin.mediation.MaxAd;
|
|
import com.applovin.mediation.MaxAdFormat;
|
|
import com.applovin.mediation.MaxError;
|
|
import com.applovin.mediation.MaxErrorCode;
|
|
import com.applovin.mediation.MaxNetworkResponseInfo;
|
|
import com.applovin.sdk.AppLovinSdkUtils;
|
|
import com.facebook.internal.security.CertificateUtil;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Queue;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class wm extends yl {
|
|
private static final AtomicBoolean z = new AtomicBoolean();
|
|
private final String h;
|
|
private final MaxAdFormat i;
|
|
private final JSONObject j;
|
|
private final a.InterfaceC0026a k;
|
|
private final WeakReference l;
|
|
private final String m;
|
|
private final Queue n;
|
|
private final Object o;
|
|
private final Queue p;
|
|
private final Object q;
|
|
private final int r;
|
|
private long s;
|
|
private final List t;
|
|
private final AtomicBoolean u;
|
|
private final AtomicBoolean v;
|
|
private final AtomicBoolean w;
|
|
private ge x;
|
|
private go y;
|
|
|
|
public enum c {
|
|
BIDDING,
|
|
TAG
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
final MaxErrorImpl maxErrorImpl;
|
|
this.s = SystemClock.elapsedRealtime();
|
|
if (this.j.optBoolean("is_testing", false) && !this.a.l0().c() && z.compareAndSet(false, true)) {
|
|
AppLovinSdkUtils.runOnUiThread(new Runnable() { // from class: com.applovin.impl.wm$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
wm.this.e();
|
|
}
|
|
});
|
|
}
|
|
if (this.r != 0) {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.a(this.b, "Starting waterfall for " + this.i.getLabel() + " ad unit " + this.h + " with " + this.r + " ad(s)...");
|
|
}
|
|
d(c.TAG);
|
|
d(c.BIDDING);
|
|
return;
|
|
}
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.k(this.b, "No ads were returned from the server for " + this.i.getLabel() + " ad unit " + this.h);
|
|
}
|
|
yp.a(this.h, this.i, this.j, this.a);
|
|
JSONObject jSONObject = JsonUtils.getJSONObject(this.j, "settings", new JSONObject());
|
|
long j = JsonUtils.getLong(jSONObject, "alfdcs", 0L);
|
|
if (af.a(this.j, this.h, this.a)) {
|
|
maxErrorImpl = new MaxErrorImpl(MaxErrorCode.INVALID_AD_UNIT_ID, "Ad Unit ID " + this.h + " is invalid or disabled.\nMake sure to use an Ad Unit ID from the MAX dashboard that is enabled and configured for the current application.\nFor more information, see https://developers.applovin.com/en/getting-started#step-2-create-an-ad-unit\nNote: New ad units cannot load ads until 30-60 minutes after they are created");
|
|
if (yp.c(this.a) && ((Boolean) this.a.a(sj.s6)).booleanValue()) {
|
|
j = 0;
|
|
}
|
|
} else {
|
|
maxErrorImpl = new MaxErrorImpl(204, "MAX returned no eligible ads from any mediated networks for this app/device");
|
|
}
|
|
if (j <= 0) {
|
|
b(maxErrorImpl);
|
|
return;
|
|
}
|
|
long millis = TimeUnit.SECONDS.toMillis(j);
|
|
Runnable runnable = new Runnable() { // from class: com.applovin.impl.wm$$ExternalSyntheticLambda1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
wm.this.b(maxErrorImpl);
|
|
}
|
|
};
|
|
if (JsonUtils.getBoolean(jSONObject, "alfdcs_iba", Boolean.FALSE).booleanValue()) {
|
|
x1.a(millis, this.a, runnable);
|
|
} else {
|
|
AppLovinSdkUtils.runOnUiThreadDelayed(runnable, millis);
|
|
}
|
|
}
|
|
|
|
public wm(String str, MaxAdFormat maxAdFormat, Map map, JSONObject jSONObject, Context context, com.applovin.impl.sdk.j jVar, a.InterfaceC0026a interfaceC0026a) {
|
|
super("TaskProcessMediationWaterfallV2", jVar, str);
|
|
this.n = new LinkedList();
|
|
this.o = new Object();
|
|
this.p = new LinkedList();
|
|
this.q = new Object();
|
|
this.u = new AtomicBoolean();
|
|
this.v = new AtomicBoolean();
|
|
this.w = new AtomicBoolean();
|
|
this.h = str;
|
|
this.i = maxAdFormat;
|
|
this.j = jSONObject;
|
|
this.k = interfaceC0026a;
|
|
this.l = new WeakReference(context);
|
|
this.m = JsonUtils.getString(jSONObject, "mCode", "");
|
|
JSONArray jSONArray = JsonUtils.getJSONArray(jSONObject, com.mbridge.msdk.foundation.entity.b.JSON_KEY_ADS, new JSONArray());
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
ge a2 = ge.a(i, map, JsonUtils.getJSONObject(jSONArray, i, (JSONObject) null), jSONObject, jVar);
|
|
if (a2.Z()) {
|
|
this.p.add(a2);
|
|
} else {
|
|
this.n.add(a2);
|
|
}
|
|
}
|
|
int size = this.n.size() + this.p.size();
|
|
this.r = size;
|
|
this.t = new ArrayList(size);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public /* synthetic */ void e() {
|
|
yp.a("MAX SDK Not Initialized In Test Mode", "Test ads may not load. Please force close and restart the app if you experience issues.", this.a.n0());
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public boolean d(c cVar) {
|
|
ge a2 = a(cVar);
|
|
if (a2 == null) {
|
|
b(cVar);
|
|
return false;
|
|
}
|
|
this.a.j0().a((yl) new b(a2, cVar), tm.b.MEDIATION);
|
|
return true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public ge c(c cVar) {
|
|
return a(cVar, true);
|
|
}
|
|
|
|
public class b extends yl {
|
|
private final String h;
|
|
private final long i;
|
|
private final ge j;
|
|
private final c k;
|
|
private final int l;
|
|
private boolean m;
|
|
private int n;
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void b(String str) {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
com.applovin.impl.sdk.n nVar = this.c;
|
|
String str = this.h;
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(this.m ? "Retrying loading" : "Loading");
|
|
sb.append(" ad ");
|
|
sb.append(this.l);
|
|
sb.append(" of ");
|
|
sb.append(wm.this.r);
|
|
sb.append(" from ");
|
|
sb.append(this.j.c());
|
|
sb.append(" for ");
|
|
sb.append(wm.this.i);
|
|
sb.append(" ad unit ");
|
|
sb.append(wm.this.h);
|
|
nVar.a(str, sb.toString());
|
|
}
|
|
b("started to load ad");
|
|
Context context = (Context) wm.this.l.get();
|
|
Activity n0 = context instanceof Activity ? (Activity) context : this.a.n0();
|
|
this.a.T().b(this.j);
|
|
this.a.Q().loadThirdPartyMediatedAd(wm.this.h, this.j, this.m, n0, new a(wm.this.k));
|
|
}
|
|
|
|
public static /* synthetic */ int l(b bVar) {
|
|
int i = bVar.n;
|
|
bVar.n = i - 1;
|
|
return i;
|
|
}
|
|
|
|
private b(ge geVar, c cVar) {
|
|
super(wm.this.b, wm.this.a, wm.this.h);
|
|
this.h = this.b + CertificateUtil.DELIMITER + cVar;
|
|
this.i = SystemClock.elapsedRealtime();
|
|
this.j = geVar;
|
|
this.k = cVar;
|
|
this.l = geVar.J() + 1;
|
|
this.n = geVar.N();
|
|
}
|
|
|
|
public class a extends oe {
|
|
@Override // com.applovin.mediation.MaxAdListener
|
|
public void onAdLoadFailed(String str, MaxError maxError) {
|
|
long elapsedRealtime = SystemClock.elapsedRealtime() - b.this.i;
|
|
com.applovin.impl.sdk.n unused = b.this.c;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
b.this.c.a(b.this.h, "Ad (" + b.this.l + ") failed to load in " + elapsedRealtime + "ms for " + wm.this.i + " ad unit " + str + " with error: " + maxError);
|
|
}
|
|
b.this.b("failed to load ad: " + maxError.getCode());
|
|
if (!b.this.m) {
|
|
b bVar = b.this;
|
|
wm.this.a(bVar.j, MaxNetworkResponseInfo.AdLoadState.FAILED_TO_LOAD, elapsedRealtime, maxError);
|
|
}
|
|
if (wm.this.w.get()) {
|
|
return;
|
|
}
|
|
if (wm.this.x != null) {
|
|
b bVar2 = b.this;
|
|
if (b.this.b(wm.this.c(bVar2.k))) {
|
|
wm wmVar = wm.this;
|
|
wmVar.b(wmVar.x);
|
|
return;
|
|
}
|
|
}
|
|
if (b.this.n > 0) {
|
|
if (!b.this.a.a(ve.K7, String.valueOf(maxError.getCode()))) {
|
|
b.l(b.this);
|
|
b.this.m = true;
|
|
b.this.a.j0().a(b.this, tm.b.MEDIATION, b.this.j.V());
|
|
return;
|
|
}
|
|
com.applovin.impl.sdk.n unused2 = b.this.c;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
b.this.c.a(b.this.b, "Ignoring failed ad load retry for error code " + maxError.getCode());
|
|
}
|
|
}
|
|
b bVar3 = b.this;
|
|
if ((!wm.this.d(bVar3.k)) && wm.this.v.get() && wm.this.u.get()) {
|
|
wm.this.b(new MaxErrorImpl(-5001, "MAX returned eligible ads from mediated networks, but all ads failed to load. Inspect getWaterfall() for more info."));
|
|
}
|
|
}
|
|
|
|
public a(a.InterfaceC0026a interfaceC0026a) {
|
|
super(interfaceC0026a);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.MaxAdListener
|
|
public void onAdLoaded(MaxAd maxAd) {
|
|
boolean z;
|
|
long E;
|
|
ge geVar;
|
|
b.this.b("loaded ad");
|
|
ge geVar2 = (ge) maxAd;
|
|
long elapsedRealtime = SystemClock.elapsedRealtime() - b.this.i;
|
|
com.applovin.impl.sdk.n unused = b.this.c;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
b.this.c.a(b.this.h, "Ad (" + b.this.l + ") loaded in " + elapsedRealtime + "ms for " + wm.this.i + " ad unit " + wm.this.h);
|
|
}
|
|
wm.this.a(geVar2, MaxNetworkResponseInfo.AdLoadState.AD_LOADED, elapsedRealtime, null);
|
|
b bVar = b.this;
|
|
wm.this.b(bVar.k);
|
|
if (c.BIDDING == b.this.k) {
|
|
z = wm.this.v.get();
|
|
E = geVar2.T();
|
|
} else {
|
|
z = wm.this.u.get();
|
|
E = geVar2.E();
|
|
}
|
|
if (!z && E != 0) {
|
|
wm.this.x = geVar2;
|
|
if (E < 0) {
|
|
return;
|
|
}
|
|
b bVar2 = b.this;
|
|
wm.this.y = go.a(E, bVar2.a, new Runnable() { // from class: com.applovin.impl.wm$b$a$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
wm.b.a.this.a();
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
if (b.this.b(geVar2)) {
|
|
geVar = geVar2;
|
|
geVar2 = wm.this.x;
|
|
} else {
|
|
geVar = wm.this.x;
|
|
}
|
|
wm.this.a(geVar2, geVar);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public /* synthetic */ void a() {
|
|
wm wmVar = wm.this;
|
|
wmVar.b(wmVar.x);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public boolean b(ge geVar) {
|
|
if (wm.this.x == null) {
|
|
return false;
|
|
}
|
|
if (geVar == null) {
|
|
return true;
|
|
}
|
|
double O = wm.this.x.O();
|
|
double O2 = geVar.O();
|
|
return (O < 0.0d || O2 < 0.0d) ? wm.this.x.J() < geVar.J() : O > O2;
|
|
}
|
|
}
|
|
|
|
private void g() {
|
|
a(this.n);
|
|
a(this.p);
|
|
}
|
|
|
|
private void f() {
|
|
go goVar = this.y;
|
|
if (goVar == null) {
|
|
return;
|
|
}
|
|
goVar.a();
|
|
this.y = null;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void b(ge geVar) {
|
|
a(geVar, (ge) null);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void b(c cVar) {
|
|
if (c.BIDDING == cVar) {
|
|
this.u.compareAndSet(false, true);
|
|
} else if (c.TAG == cVar) {
|
|
this.v.compareAndSet(false, true);
|
|
}
|
|
}
|
|
|
|
private ge a(c cVar) {
|
|
return a(cVar, false);
|
|
}
|
|
|
|
private ge a(c cVar, boolean z2) {
|
|
Object poll;
|
|
ge geVar;
|
|
Object poll2;
|
|
ge geVar2;
|
|
if (cVar == c.BIDDING) {
|
|
synchronized (this.q) {
|
|
try {
|
|
if (z2) {
|
|
poll2 = this.p.peek();
|
|
} else {
|
|
poll2 = this.p.poll();
|
|
}
|
|
geVar2 = (ge) poll2;
|
|
} finally {
|
|
}
|
|
}
|
|
return geVar2;
|
|
}
|
|
synchronized (this.o) {
|
|
try {
|
|
if (z2) {
|
|
poll = this.n.peek();
|
|
} else {
|
|
poll = this.n.poll();
|
|
}
|
|
geVar = (ge) poll;
|
|
} finally {
|
|
}
|
|
}
|
|
return geVar;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(ge geVar, ge geVar2) {
|
|
if (this.w.compareAndSet(false, true)) {
|
|
f();
|
|
g();
|
|
this.a.T().a(geVar, geVar2);
|
|
long elapsedRealtime = SystemClock.elapsedRealtime() - this.s;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.d(this.b, "Waterfall loaded in " + elapsedRealtime + "ms from " + geVar.c() + " for " + this.i + " ad unit " + this.h);
|
|
}
|
|
geVar.a(new MaxAdWaterfallInfoImpl(geVar, elapsedRealtime, this.t, this.m));
|
|
gc.f(this.k, geVar);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void b(MaxError maxError) {
|
|
int i = 0;
|
|
if (this.w.compareAndSet(false, true)) {
|
|
if (maxError.getCode() == 204) {
|
|
this.a.D().c(ca.u);
|
|
} else if (maxError.getCode() == -5001) {
|
|
this.a.D().c(ca.v);
|
|
} else {
|
|
this.a.D().c(ca.w);
|
|
}
|
|
ArrayList arrayList = new ArrayList(this.t.size());
|
|
for (MaxNetworkResponseInfo maxNetworkResponseInfo : this.t) {
|
|
if (maxNetworkResponseInfo.getAdLoadState() == MaxNetworkResponseInfo.AdLoadState.FAILED_TO_LOAD) {
|
|
arrayList.add(maxNetworkResponseInfo);
|
|
}
|
|
}
|
|
if (arrayList.size() > 0) {
|
|
StringBuilder sb = new StringBuilder("======FAILED AD LOADS======");
|
|
sb.append("\n");
|
|
while (i < arrayList.size()) {
|
|
MaxNetworkResponseInfo maxNetworkResponseInfo2 = (MaxNetworkResponseInfo) arrayList.get(i);
|
|
i++;
|
|
sb.append(i);
|
|
sb.append(") ");
|
|
sb.append(maxNetworkResponseInfo2.getMediatedNetwork().getName());
|
|
sb.append("\n");
|
|
sb.append("..code: ");
|
|
sb.append(maxNetworkResponseInfo2.getError().getCode());
|
|
sb.append("\n");
|
|
sb.append("..message: ");
|
|
sb.append(maxNetworkResponseInfo2.getError().getMessage());
|
|
sb.append("\n");
|
|
}
|
|
((MaxErrorImpl) maxError).setAdLoadFailureInfo(sb.toString());
|
|
}
|
|
long elapsedRealtime = SystemClock.elapsedRealtime() - this.s;
|
|
if (com.applovin.impl.sdk.n.a()) {
|
|
this.c.d(this.b, "Waterfall failed in " + elapsedRealtime + "ms for " + this.i + " ad unit " + this.h + " with error: " + maxError);
|
|
}
|
|
((MaxErrorImpl) maxError).setWaterfall(new MaxAdWaterfallInfoImpl(null, JsonUtils.getString(this.j, "waterfall_name", ""), JsonUtils.getString(this.j, "waterfall_test_name", ""), elapsedRealtime, this.t, JsonUtils.optList(JsonUtils.getJSONArray(this.j, "mwf_info_urls", null), Collections.EMPTY_LIST), this.m));
|
|
gc.a(this.k, this.h, maxError);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(ge geVar, MaxNetworkResponseInfo.AdLoadState adLoadState, long j, MaxError maxError) {
|
|
this.t.add(new MaxNetworkResponseInfoImpl(adLoadState, af.a(geVar.b()), geVar.F(), geVar.Z(), j, geVar.B(), maxError));
|
|
}
|
|
|
|
private void a(Queue queue) {
|
|
Iterator it = queue.iterator();
|
|
while (it.hasNext()) {
|
|
a((ge) it.next(), MaxNetworkResponseInfo.AdLoadState.AD_LOAD_NOT_ATTEMPTED, -1L, null);
|
|
}
|
|
}
|
|
}
|