Picsart v24.6版本的 MD5 值为:21a61631d94e54da68d2ad9268b8b9d9

以下内容为反编译后的 e.java 源代码,内容仅作参考


package com.applovin.impl.mediation.d;

import android.app.Activity;
import android.content.Context;
import android.os.SystemClock;
import androidx.annotation.NonNull;
import com.applovin.impl.mediation.MaxAdWaterfallInfoImpl;
import com.applovin.impl.mediation.MaxErrorImpl;
import com.applovin.impl.mediation.MaxMediatedNetworkInfoImpl;
import com.applovin.impl.mediation.MaxNetworkResponseInfoImpl;
import com.applovin.impl.mediation.ads.a;
import com.applovin.impl.mediation.d.e;
import com.applovin.impl.sdk.e.q;
import com.applovin.impl.sdk.n;
import com.applovin.impl.sdk.utils.JsonUtils;
import com.applovin.impl.sdk.utils.l;
import com.applovin.impl.sdk.utils.q;
import com.applovin.impl.sdk.utils.t;
import com.applovin.impl.sdk.x;
import com.applovin.mediation.MaxAd;
import com.applovin.mediation.MaxAdFormat;
import com.applovin.mediation.MaxAdListener;
import com.applovin.mediation.MaxError;
import com.applovin.mediation.MaxErrorCode;
import com.applovin.mediation.MaxNetworkResponseInfo;
import com.applovin.sdk.AppLovinSdkUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
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;
public class e extends com.applovin.impl.sdk.e.d {
    private static final AtomicBoolean axl = new AtomicBoolean();
    private final String adUnitId;
    private final WeakReference<Context> alV;
    private final List<MaxNetworkResponseInfo> alc;
    private final String alf;
    private final JSONObject axm;
    private final a.InterfaceC0142a axn;
    private final Queue<com.applovin.impl.mediation.b.a> axo;
    private final Object axp;
    private final Queue<com.applovin.impl.mediation.b.a> axq;
    private final Object axr;
    private final int axs;
    private final AtomicBoolean axt;
    private final AtomicBoolean axu;
    private final AtomicBoolean axv;
    private com.applovin.impl.mediation.b.a axw;
    private q axx;
    private final MaxAdFormat format;
    private long startTimeMillis;

    public class a extends com.applovin.impl.sdk.e.d {
        private final com.applovin.impl.mediation.b.a amu;
        private final int axA;
        private final String axy;
        private final b axz;
        private final long startTimeMillis;

        public class AnonymousClass1 extends com.applovin.impl.mediation.e.a {
            public AnonymousClass1(a.InterfaceC0142a interfaceC0142a) {
                super(interfaceC0142a);
                a.this = r1;
            }

            public void Ac() {
                e eVar = e.this;
                eVar.h(eVar.axw);
            }

            @Override
            public void onAdLoadFailed(@NonNull String str, @NonNull MaxError maxError) {
                long elapsedRealtime = SystemClock.elapsedRealtime() - a.this.startTimeMillis;
                x unused = ((com.applovin.impl.sdk.e.d) a.this).logger;
                if (x.FL()) {
                    x xVar = ((com.applovin.impl.sdk.e.d) a.this).logger;
                    String str2 = a.this.axy;
                    xVar.f(str2, "Ad (" + a.this.axA + ") failed to load in " + elapsedRealtime + "ms for " + e.this.format + " ad unit " + str + " with error: " + maxError);
                }
                a aVar = a.this;
                aVar.ci("failed to load ad: " + maxError.getCode());
                a aVar2 = a.this;
                e.this.a(aVar2.amu, MaxNetworkResponseInfo.AdLoadState.FAILED_TO_LOAD, elapsedRealtime, maxError);
                if (e.this.axv.get()) {
                    return;
                }
                if (e.this.axw != null) {
                    a aVar3 = a.this;
                    if (a.this.i(e.this.b(aVar3.axz))) {
                        e eVar = e.this;
                        eVar.h(eVar.axw);
                        return;
                    }
                }
                a aVar4 = a.this;
                if ((!e.this.a(aVar4.axz)) && e.this.axu.get() && e.this.axt.get()) {
                    e.this.f(new MaxErrorImpl(-5001, "MAX returned eligible ads from mediated networks, but all ads failed to load. Inspect getWaterfall() for more info."));
                }
            }

            @Override
            public void onAdLoaded(@NonNull MaxAd maxAd) {
                boolean z;
                long xM;
                com.applovin.impl.mediation.b.a aVar;
                int i;
                a.this.ci("loaded ad");
                com.applovin.impl.mediation.b.a aVar2 = (com.applovin.impl.mediation.b.a) maxAd;
                long elapsedRealtime = SystemClock.elapsedRealtime() - a.this.startTimeMillis;
                x unused = ((com.applovin.impl.sdk.e.d) a.this).logger;
                if (x.FL()) {
                    x xVar = ((com.applovin.impl.sdk.e.d) a.this).logger;
                    String str = a.this.axy;
                    xVar.f(str, "Ad (" + a.this.axA + ") loaded in " + elapsedRealtime + "ms for " + e.this.format + " ad unit " + e.this.adUnitId);
                }
                e.this.a(aVar2, MaxNetworkResponseInfo.AdLoadState.AD_LOADED, elapsedRealtime, null);
                a aVar3 = a.this;
                e.this.d(aVar3.axz);
                if (b.BIDDING == a.this.axz) {
                    z = e.this.axu.get();
                    xM = aVar2.xN();
                } else {
                    z = e.this.axt.get();
                    xM = aVar2.xM();
                }
                if (z || xM == 0) {
                    if (a.this.i(aVar2)) {
                        aVar = aVar2;
                        aVar2 = e.this.axw;
                    } else {
                        aVar = e.this.axw;
                    }
                    e.this.a(aVar2, aVar);
                    return;
                }
                e.this.axw = aVar2;
                if (i < 0) {
                    return;
                }
                a aVar4 = a.this;
                e.this.axx = q.b(xM, ((com.applovin.impl.sdk.e.d) aVar4).sdk, new Runnable() {
                    @Override
                    public final void run() {
                        e.a.AnonymousClass1.this.Ac();
                    }
                });
            }
        }

        private a(com.applovin.impl.mediation.b.a aVar, b bVar) {
            super(r3.tag, r3.sdk, r3.adUnitId);
            e.this = r3;
            this.axy = this.tag + ":" + bVar;
            this.startTimeMillis = SystemClock.elapsedRealtime();
            this.amu = aVar;
            this.axz = bVar;
            this.axA = aVar.ah() + 1;
        }

        public void ci(String str) {
        }

        public boolean i(com.applovin.impl.mediation.b.a aVar) {
            if (e.this.axw == null) {
                return false;
            }
            if (aVar == null) {
                return true;
            }
            double xO = e.this.axw.xO();
            double xO2 = aVar.xO();
            return (xO < 0.0d || xO2 < 0.0d) ? e.this.axw.ah() < aVar.ah() : xO > xO2;
        }

        @Override
        public void run() {
            if (x.FL()) {
                x xVar = this.logger;
                String str = this.axy;
                xVar.f(str, "Loading ad " + this.axA + " of " + e.this.axs + " from " + this.amu.yR() + " for " + e.this.format + " ad unit " + e.this.adUnitId);
            }
            ci("started to load ad");
            Context context = (Context) e.this.alV.get();
            this.sdk.CU().loadThirdPartyMediatedAd(e.this.adUnitId, this.amu, context instanceof Activity ? (Activity) context : this.sdk.Db(), new AnonymousClass1(e.this.axn));
        }
    }

    public enum b {
        BIDDING,
        TAG
    }

    public e(String str, MaxAdFormat maxAdFormat, Map<String, Object> map, JSONObject jSONObject, Context context, n nVar, a.InterfaceC0142a interfaceC0142a) {
        super("TaskProcessMediationWaterfallV2", nVar, str);
        this.axo = new LinkedList();
        this.axp = new Object();
        this.axq = new LinkedList();
        this.axr = new Object();
        this.axt = new AtomicBoolean();
        this.axu = new AtomicBoolean();
        this.axv = new AtomicBoolean();
        this.adUnitId = str;
        this.format = maxAdFormat;
        this.axm = jSONObject;
        this.axn = interfaceC0142a;
        this.alV = new WeakReference<>(context);
        this.alf = JsonUtils.getString(jSONObject, "mCode", "");
        JSONArray jSONArray = JsonUtils.getJSONArray(jSONObject, "ads", new JSONArray());
        for (int i = 0; i < jSONArray.length(); i++) {
            com.applovin.impl.mediation.b.a a2 = com.applovin.impl.mediation.b.a.a(i, map, JsonUtils.getJSONObject(jSONArray, i, (JSONObject) null), jSONObject, nVar);
            if (a2.isBidding()) {
                this.axq.add(a2);
            } else {
                this.axo.add(a2);
            }
        }
        int size = this.axq.size() + this.axo.size();
        this.axs = size;
        this.alc = new ArrayList(size);
    }

    private void Aa() {
        q qVar = this.axx;
        if (qVar == null) {
            return;
        }
        qVar.ue();
        this.axx = null;
    }

    public void Ab() {
        t.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.sdk.Db());
    }

    private com.applovin.impl.mediation.b.a a(b bVar, boolean z) {
        com.applovin.impl.mediation.b.a peek;
        com.applovin.impl.mediation.b.a peek2;
        if (bVar == b.BIDDING) {
            synchronized (this.axr) {
                try {
                    peek2 = z ? this.axq.peek() : this.axq.poll();
                } finally {
                }
            }
            return peek2;
        }
        synchronized (this.axp) {
            try {
                peek = z ? this.axo.peek() : this.axo.poll();
            } finally {
            }
        }
        return peek;
    }

    public void a(com.applovin.impl.mediation.b.a aVar, com.applovin.impl.mediation.b.a aVar2) {
        if (this.axv.compareAndSet(false, true)) {
            Aa();
            zZ();
            this.sdk.CY().b(aVar, aVar2);
            long elapsedRealtime = SystemClock.elapsedRealtime() - this.startTimeMillis;
            if (x.FL()) {
                x xVar = this.logger;
                String str = this.tag;
                StringBuilder j = myobfuscated.a0.a.j("Waterfall loaded in ", elapsedRealtime, "ms from ");
                j.append(aVar.yR());
                j.append(" for ");
                j.append(this.format);
                j.append(" ad unit ");
                j.append(this.adUnitId);
                xVar.g(str, j.toString());
            }
            aVar.setWaterfall(new MaxAdWaterfallInfoImpl(aVar, elapsedRealtime, this.alc, this.alf));
            l.a((MaxAdListener) this.axn, (MaxAd) aVar);
        }
    }

    public void a(com.applovin.impl.mediation.b.a aVar, MaxNetworkResponseInfo.AdLoadState adLoadState, long j, MaxError maxError) {
        this.alc.add(new MaxNetworkResponseInfoImpl(adLoadState, new MaxMediatedNetworkInfoImpl(com.applovin.impl.mediation.e.c.a(aVar.vH(), this.sdk)), aVar.getCredentials(), aVar.isBidding(), j, aVar.getBCode(), maxError));
    }

    private void a(Queue<com.applovin.impl.mediation.b.a> queue) {
        for (com.applovin.impl.mediation.b.a aVar : queue) {
            a(aVar, MaxNetworkResponseInfo.AdLoadState.AD_LOAD_NOT_ATTEMPTED, -1L, null);
        }
    }

    public boolean a(b bVar) {
        com.applovin.impl.mediation.b.a c = c(bVar);
        if (c == null) {
            d(bVar);
            return false;
        }
        this.sdk.Cj().a((com.applovin.impl.sdk.e.d) new a(c, bVar), q.a.MEDIATION);
        return true;
    }

    public com.applovin.impl.mediation.b.a b(b bVar) {
        return a(bVar, true);
    }

    private com.applovin.impl.mediation.b.a c(b bVar) {
        return a(bVar, false);
    }

    public void d(b bVar) {
        if (b.BIDDING == bVar) {
            this.axt.compareAndSet(false, true);
        } else if (b.TAG == bVar) {
            this.axu.compareAndSet(false, true);
        }
    }

    public void f(MaxError maxError) {
        int i = 0;
        if (this.axv.compareAndSet(false, true)) {
            if (maxError.getCode() == 204) {
                this.sdk.Cm().a(com.applovin.impl.sdk.d.c.aUo);
            } else if (maxError.getCode() == -5001) {
                this.sdk.Cm().a(com.applovin.impl.sdk.d.c.aUp);
            } else {
                this.sdk.Cm().a(com.applovin.impl.sdk.d.c.aUq);
            }
            ArrayList arrayList = new ArrayList(this.alc.size());
            for (MaxNetworkResponseInfo maxNetworkResponseInfo : this.alc) {
                if (maxNetworkResponseInfo.getAdLoadState() == MaxNetworkResponseInfo.AdLoadState.FAILED_TO_LOAD) {
                    arrayList.add(maxNetworkResponseInfo);
                }
            }
            if (arrayList.size() > 0) {
                StringBuilder sb = new StringBuilder("======FAILED AD LOADS======\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..code: ");
                    sb.append(maxNetworkResponseInfo2.getError().getCode());
                    sb.append("\n..message: ");
                    sb.append(maxNetworkResponseInfo2.getError().getMessage());
                    sb.append("\n");
                }
                ((MaxErrorImpl) maxError).setAdLoadFailureInfo(sb.toString());
            }
            long elapsedRealtime = SystemClock.elapsedRealtime() - this.startTimeMillis;
            if (x.FL()) {
                x xVar = this.logger;
                String str = this.tag;
                StringBuilder j = myobfuscated.a0.a.j("Waterfall failed in ", elapsedRealtime, "ms for ");
                j.append(this.format);
                j.append(" ad unit ");
                j.append(this.adUnitId);
                j.append(" with error: ");
                j.append(maxError);
                xVar.g(str, j.toString());
            }
            ((MaxErrorImpl) maxError).setWaterfall(new MaxAdWaterfallInfoImpl(null, JsonUtils.getString(this.axm, "waterfall_name", ""), JsonUtils.getString(this.axm, "waterfall_test_name", ""), elapsedRealtime, this.alc, JsonUtils.optList(JsonUtils.getJSONArray(this.axm, "mwf_info_urls", null), Collections.EMPTY_LIST), this.alf));
            l.a(this.axn, this.adUnitId, maxError);
        }
    }

    public void h(com.applovin.impl.mediation.b.a aVar) {
        a(aVar, (com.applovin.impl.mediation.b.a) null);
    }

    private void zZ() {
        a(this.axo);
        a(this.axq);
    }

    @Override
    public void run() {
        MaxErrorImpl maxErrorImpl;
        this.startTimeMillis = SystemClock.elapsedRealtime();
        if (this.axm.optBoolean("is_testing", false) && !this.sdk.Da().isEnabled() && axl.compareAndSet(false, true)) {
            AppLovinSdkUtils.runOnUiThread(new myobfuscated.y3.g(this, 11));
        }
        if (this.axs != 0) {
            if (x.FL()) {
                this.logger.f(this.tag, "Starting waterfall for " + this.format.getLabel() + " ad unit " + this.adUnitId + " with " + this.axs + " ad(s)...");
            }
            a(b.TAG);
            a(b.BIDDING);
            return;
        }
        if (x.FL()) {
            this.logger.h(this.tag, "No ads were returned from the server for " + this.format.getLabel() + " ad unit " + this.adUnitId);
        }
        t.a(this.adUnitId, this.format, this.axm, this.sdk);
        JSONObject jSONObject = JsonUtils.getJSONObject(this.axm, "settings", new JSONObject());
        long j = JsonUtils.getLong(jSONObject, "alfdcs", 0L);
        if (com.applovin.impl.mediation.e.c.b(this.axm, this.adUnitId, this.sdk)) {
            maxErrorImpl = new MaxErrorImpl(MaxErrorCode.INVALID_AD_UNIT_ID, defpackage.e.m(new StringBuilder("Ad Unit ID "), this.adUnitId, " 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://dash.applovin.com/documentation/mediation/max/get-started-with-max#step-2:-create-an-ad-unit\nNote: New ad units cannot load ads until 30-60 minutes after they are created"));
            if (t.b(n.getApplicationContext(), this.sdk) && ((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.aSC)).booleanValue()) {
                j = 0;
            }
        } else {
            maxErrorImpl = new MaxErrorImpl(204, "MAX returned no eligible ads from any mediated networks for this app/device");
        }
        if (j <= 0) {
            f(maxErrorImpl);
            return;
        }
        long millis = TimeUnit.SECONDS.toMillis(j);
        myobfuscated.a9.b bVar = new myobfuscated.a9.b(0, this, maxErrorImpl);
        if (JsonUtils.getBoolean(jSONObject, "alfdcs_iba", Boolean.FALSE).booleanValue()) {
            com.applovin.impl.sdk.utils.f.a(millis, this.sdk, bVar);
        } else {
            AppLovinSdkUtils.runOnUiThreadDelayed(bVar, millis);
        }
    }
}