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

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


package com.applovin.impl.mediation;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import com.applovin.impl.mediation.MediationServiceImpl;
import com.applovin.impl.mediation.ads.a;
import com.applovin.impl.mediation.b.g;
import com.applovin.impl.mediation.d;
import com.applovin.impl.mediation.g;
import com.applovin.impl.sdk.AppLovinBroadcastManager;
import com.applovin.impl.sdk.e.q;
import com.applovin.impl.sdk.r;
import com.applovin.impl.sdk.u;
import com.applovin.impl.sdk.utils.CollectionUtils;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.mediation.MaxAd;
import com.applovin.mediation.MaxAdFormat;
import com.applovin.mediation.MaxAdListener;
import com.applovin.mediation.MaxAdRequestListener;
import com.applovin.mediation.MaxAdRevenueListener;
import com.applovin.mediation.MaxAdViewAdListener;
import com.applovin.mediation.MaxError;
import com.applovin.mediation.MaxMediatedNetworkInfo;
import com.applovin.mediation.MaxNetworkResponseInfo;
import com.applovin.mediation.MaxReward;
import com.applovin.mediation.MaxRewardedAdListener;
import com.applovin.mediation.adapter.MaxAdapter;
import com.applovin.mediation.adapter.MaxAdapterError;
import com.applovin.sdk.AppLovinSdkUtils;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.json.JSONObject;
public class MediationServiceImpl implements AppLovinBroadcastManager.Receiver {
    private final j amN;
    private final AtomicReference<JSONObject> amO = new AtomicReference<>();
    private final com.applovin.impl.sdk.x logger;
    private final com.applovin.impl.sdk.n sdk;

    public class a implements a.InterfaceC0142a, MaxAdListener, MaxAdRevenueListener, MaxAdViewAdListener, MaxRewardedAdListener {
        private final com.applovin.impl.mediation.b.a amV;
        private a.InterfaceC0142a amW;

        public a(com.applovin.impl.mediation.b.a aVar, a.InterfaceC0142a interfaceC0142a) {
            MediationServiceImpl.this = r1;
            this.amV = aVar;
            this.amW = interfaceC0142a;
        }

        public void a(MaxAd maxAd) {
            if (maxAd.getFormat().isFullscreenAd()) {
                MediationServiceImpl.this.sdk.CA().ac(maxAd);
            }
            com.applovin.impl.sdk.utils.l.c(this.amW, maxAd);
        }

        public void a(a.InterfaceC0142a interfaceC0142a) {
            this.amW = interfaceC0142a;
        }

        public void a(@NonNull MaxAd maxAd, Bundle bundle) {
            this.amV.S(bundle);
            this.amV.yf();
            MediationServiceImpl.this.d(this.amV);
            com.applovin.impl.sdk.utils.l.a((MaxAdListener) this.amW, maxAd);
        }

        public void a(@NonNull MaxAd maxAd, @NonNull MaxError maxError, Bundle bundle) {
            this.amV.S(bundle);
            MediationServiceImpl.this.b(this.amV, maxError, this.amW);
            if ((maxAd.getFormat() == MaxAdFormat.REWARDED || maxAd.getFormat() == MaxAdFormat.REWARDED_INTERSTITIAL) && (maxAd instanceof com.applovin.impl.mediation.b.c)) {
                ((com.applovin.impl.mediation.b.c) maxAd).yx();
            }
        }

        public void a(@NonNull MaxAd maxAd, @NonNull MaxReward maxReward, Bundle bundle) {
            this.amV.S(bundle);
            com.applovin.impl.sdk.utils.l.a(this.amW, maxAd, maxReward);
            MediationServiceImpl.this.sdk.Cj().a((com.applovin.impl.sdk.e.d) new com.applovin.impl.mediation.d.g((com.applovin.impl.mediation.b.c) maxAd, MediationServiceImpl.this.sdk), q.a.OTHER);
        }

        public void b(@NonNull MaxAd maxAd, Bundle bundle) {
            this.amV.S(bundle);
            com.applovin.impl.sdk.x unused = MediationServiceImpl.this.logger;
            if (com.applovin.impl.sdk.x.FL()) {
                MediationServiceImpl.this.logger.f("MediationService", "Scheduling impression for ad via callback...");
            }
            MediationServiceImpl.this.processCallbackAdImpressionPostback(this.amV, this.amW);
            MediationServiceImpl.this.sdk.Cm().a(com.applovin.impl.sdk.d.c.aTZ);
            MediationServiceImpl.this.sdk.Cm().a(com.applovin.impl.sdk.d.c.aUc);
            if (!maxAd.getFormat().isFullscreenAd()) {
                MediationServiceImpl.this.sdk.CC().a(this.amV, "DID_DISPLAY");
                com.applovin.impl.sdk.utils.l.b(this.amW, maxAd);
                return;
            }
            com.applovin.impl.mediation.b.c cVar = (com.applovin.impl.mediation.b.c) maxAd;
            if (cVar.yB()) {
                MediationServiceImpl.this.sdk.CC().a(this.amV, "DID_DISPLAY");
                MediationServiceImpl.this.sdk.CA().ab(this.amV);
                com.applovin.impl.sdk.utils.l.b(this.amW, maxAd);
                return;
            }
            com.applovin.impl.sdk.x unused2 = MediationServiceImpl.this.logger;
            if (com.applovin.impl.sdk.x.FL()) {
                MediationServiceImpl.this.logger.h("MediationService", "Received ad display callback before attempting show".concat(cVar.xX() ? " for hybrid ad" : ""));
            }
        }

        public void c(@NonNull MaxAd maxAd, Bundle bundle) {
            this.amV.S(bundle);
            MediationServiceImpl.this.sdk.CC().a((com.applovin.impl.mediation.b.a) maxAd, "DID_HIDE");
            AppLovinSdkUtils.runOnUiThreadDelayed(new myobfuscated.y8.c(this, maxAd, 0), maxAd instanceof com.applovin.impl.mediation.b.c ? ((com.applovin.impl.mediation.b.c) maxAd).yu() : 0L);
        }

        public void d(@NonNull MaxAd maxAd, Bundle bundle) {
            this.amV.S(bundle);
            MediationServiceImpl.this.a(this.amV, this.amW);
            com.applovin.impl.sdk.utils.l.d(this.amW, maxAd);
        }

        public void e(@NonNull MaxAd maxAd, Bundle bundle) {
            this.amV.S(bundle);
            com.applovin.impl.sdk.utils.l.g(this.amW, maxAd);
        }

        public void f(@NonNull MaxAd maxAd, Bundle bundle) {
            this.amV.S(bundle);
            com.applovin.impl.sdk.utils.l.h(this.amW, maxAd);
        }

        @Override
        public void onAdClicked(@NonNull MaxAd maxAd) {
            d(maxAd, null);
        }

        @Override
        public void onAdCollapsed(@NonNull MaxAd maxAd) {
            f(maxAd, null);
        }

        @Override
        public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
            a(maxAd, maxError, (Bundle) null);
        }

        @Override
        public void onAdDisplayed(@NonNull MaxAd maxAd) {
            b(maxAd, null);
        }

        @Override
        public void onAdExpanded(@NonNull MaxAd maxAd) {
            e(maxAd, null);
        }

        @Override
        public void onAdHidden(@NonNull MaxAd maxAd) {
            c(maxAd, null);
        }

        @Override
        public void onAdLoadFailed(@NonNull String str, @NonNull MaxError maxError) {
            this.amV.yf();
            MediationServiceImpl.this.a(this.amV, maxError, this.amW);
        }

        @Override
        public void onAdLoaded(@NonNull MaxAd maxAd) {
            a(maxAd, (Bundle) null);
        }

        @Override
        public void onAdRequestStarted(@NonNull String str) {
        }

        @Override
        public void onAdRevenuePaid(@NonNull MaxAd maxAd) {
        }

        @Override
        public void onRewardedVideoCompleted(@NonNull MaxAd maxAd) {
            com.applovin.impl.sdk.utils.l.f(this.amW, maxAd);
        }

        @Override
        public void onRewardedVideoStarted(@NonNull MaxAd maxAd) {
            com.applovin.impl.sdk.utils.l.e(this.amW, maxAd);
        }

        @Override
        public void onUserRewarded(@NonNull MaxAd maxAd, @NonNull MaxReward maxReward) {
            a(maxAd, maxReward, (Bundle) null);
        }
    }

    public MediationServiceImpl(com.applovin.impl.sdk.n nVar) {
        this.sdk = nVar;
        this.logger = nVar.Ci();
        this.amN = new j(nVar);
        AppLovinBroadcastManager.registerReceiver(this, new IntentFilter("com.applovin.render_process_gone"));
    }

    public void a(com.applovin.impl.mediation.b.a aVar, a.InterfaceC0142a interfaceC0142a) {
        this.sdk.CC().a(aVar, "DID_CLICKED");
        this.sdk.CC().a(aVar, "DID_CLICK");
        if (aVar.xS().endsWith(com.inmobi.media.e.CLICK_BEACON)) {
            this.sdk.CC().j(aVar);
            com.applovin.impl.sdk.utils.l.a((MaxAdRevenueListener) interfaceC0142a, (MaxAd) aVar);
        }
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.sdk.BU());
        if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.aQg)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mclick", hashMap, aVar);
    }

    public void a(com.applovin.impl.mediation.b.a aVar, MaxError maxError, MaxAdListener maxAdListener) {
        a(maxError, aVar);
        destroyAd(aVar);
        com.applovin.impl.sdk.utils.l.a(maxAdListener, aVar.getAdUnitId(), maxError);
    }

    private void a(com.applovin.impl.mediation.b.c cVar, a.InterfaceC0142a interfaceC0142a) {
        this.sdk.CA().aN(false);
        a(cVar, (MaxAdListener) interfaceC0142a);
        if (com.applovin.impl.sdk.x.FL()) {
            this.logger.f("MediationService", "Scheduling impression for ad manually...");
        }
        processRawAdImpression(cVar, interfaceC0142a);
    }

    public void a(com.applovin.impl.mediation.b.c cVar, g gVar, Activity activity, a.InterfaceC0142a interfaceC0142a) {
        cVar.aH(true);
        h(cVar);
        gVar.a(cVar, activity);
        a(cVar, interfaceC0142a);
    }

    public void a(com.applovin.impl.mediation.b.c cVar, g gVar, ViewGroup viewGroup, Lifecycle lifecycle, Activity activity, a.InterfaceC0142a interfaceC0142a) {
        cVar.aH(true);
        h(cVar);
        gVar.a(cVar, viewGroup, lifecycle, activity);
        a(cVar, interfaceC0142a);
    }

    private void a(com.applovin.impl.mediation.b.c cVar, MaxAdListener maxAdListener) {
        Long l = (Long) this.sdk.a(com.applovin.impl.sdk.c.a.aKP);
        if (l.longValue() <= 0) {
            return;
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new s(this, cVar, l, maxAdListener), l.longValue());
    }

    public void a(com.applovin.impl.mediation.b.c cVar, Long l, MaxAdListener maxAdListener) {
        if (cVar.yg().get()) {
            return;
        }
        String str = "Ad (" + cVar.yS() + ") has not been displayed after " + l + "ms. Failing ad display...";
        com.applovin.impl.sdk.x.I("MediationService", str);
        b(cVar, new MaxErrorImpl(-1, str), maxAdListener);
        this.sdk.CA().ac(cVar);
    }

    public void a(com.applovin.impl.mediation.b.g gVar, com.applovin.impl.mediation.b.h hVar, g gVar2) {
        HashMap hashMap = new HashMap(3);
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(gVar.za()));
        CollectionUtils.putStringIfValid("{ADAPTER_VERSION}", gVar2.getAdapterVersion(), hashMap);
        CollectionUtils.putStringIfValid("{SDK_VERSION}", gVar2.getSdkVersion(), hashMap);
        a("serr", hashMap, gVar.getError(), hVar);
    }

    private void a(MaxError maxError, com.applovin.impl.mediation.b.a aVar) {
        HashMap hashMap = new HashMap(3);
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(aVar.yb()));
        if (aVar.getFormat().isFullscreenAd()) {
            u.a cI = this.sdk.CA().cI(aVar.getAdUnitId());
            hashMap.put("{SHOW_ATTEMPT_COUNT}", String.valueOf(cI.FD()));
            hashMap.put("{SHOW_ATTEMPT_TIMESTAMP_MS}", String.valueOf(cI.FC()));
        }
        a("mlerr", hashMap, maxError, aVar);
    }

    private void a(MaxError maxError, com.applovin.impl.mediation.b.a aVar, boolean z) {
        a("mierr", Collections.EMPTY_MAP, maxError, aVar, z);
    }

    private void a(String str, List<String> list, Map<String, String> map, Map<String, Object> map2, MaxError maxError, com.applovin.impl.mediation.b.f fVar, boolean z) {
        this.sdk.Cj().a((com.applovin.impl.sdk.e.d) new com.applovin.impl.mediation.d.d(str, list, map, map2, maxError, fVar, this.sdk, z), q.a.OTHER);
    }

    private void a(String str, Map<String, String> map, com.applovin.impl.mediation.b.f fVar) {
        a(str, map, (MaxError) null, fVar);
    }

    private void a(String str, Map<String, String> map, MaxError maxError, com.applovin.impl.mediation.b.f fVar) {
        a(str, map, maxError, fVar, true);
    }

    private void a(String str, Map<String, String> map, MaxError maxError, com.applovin.impl.mediation.b.f fVar, boolean z) {
        Map<String, String> map2 = CollectionUtils.map(map);
        map2.put("{PLACEMENT}", z ? StringUtils.emptyIfNull(fVar.getPlacement()) : "");
        map2.put("{CUSTOM_DATA}", z ? StringUtils.emptyIfNull(fVar.yX()) : "");
        if (fVar instanceof com.applovin.impl.mediation.b.a) {
            map2.put("{CREATIVE_ID}", z ? StringUtils.emptyIfNull(((com.applovin.impl.mediation.b.a) fVar).getCreativeId()) : "");
        }
        a(str, (List<String>) null, map2, (Map<String, Object>) null, maxError, fVar, z);
    }

    public void b(com.applovin.impl.mediation.b.a aVar, MaxError maxError, MaxAdListener maxAdListener) {
        this.sdk.CC().a(aVar, "DID_FAIL_DISPLAY");
        a(maxError, aVar, true);
        if (aVar.yg().compareAndSet(false, true)) {
            com.applovin.impl.sdk.utils.l.a(maxAdListener, aVar, maxError);
        }
    }

    public void d(com.applovin.impl.mediation.b.a aVar) {
        this.sdk.CC().a(aVar, "DID_LOAD");
        if (aVar.xS().endsWith("load")) {
            this.sdk.CC().j(aVar);
        }
        HashMap hashMap = new HashMap(3);
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(aVar.yb()));
        if (aVar.getFormat().isFullscreenAd()) {
            u.a cI = this.sdk.CA().cI(aVar.getAdUnitId());
            hashMap.put("{SHOW_ATTEMPT_COUNT}", String.valueOf(cI.FD()));
            hashMap.put("{SHOW_ATTEMPT_TIMESTAMP_MS}", String.valueOf(cI.FC()));
        }
        a("load", hashMap, aVar);
    }

    private g g(com.applovin.impl.mediation.b.c cVar) {
        g xU = cVar.xU();
        if (xU == null) {
            this.sdk.CA().aN(false);
            if (com.applovin.impl.sdk.x.FL()) {
                com.applovin.impl.sdk.x xVar = this.logger;
                xVar.h("MediationService", "Failed to show " + cVar + ": adapter not found");
            }
            com.applovin.impl.sdk.x.I("MediationService", "There may be an integration problem with the adapter for Ad Unit ID '" + cVar.getAdUnitId() + "'. Please check if you have a supported version of that SDK integrated into your project.");
            throw new IllegalStateException("Could not find adapter for provided ad");
        }
        return xU;
    }

    private void h(com.applovin.impl.mediation.b.c cVar) {
        if (cVar.getFormat() == MaxAdFormat.REWARDED || cVar.getFormat() == MaxAdFormat.REWARDED_INTERSTITIAL) {
            this.sdk.Cj().a((com.applovin.impl.sdk.e.d) new com.applovin.impl.mediation.d.h(cVar, this.sdk), q.a.OTHER);
        }
    }

    public void collectSignal(final String str, final MaxAdFormat maxAdFormat, final com.applovin.impl.mediation.b.h hVar, Context context, final g.a aVar) {
        if (hVar == null) {
            throw new IllegalArgumentException("No spec specified");
        }
        if (context == null) {
            throw new IllegalArgumentException("No context specified");
        }
        if (aVar == null) {
            throw new IllegalArgumentException("No callback specified");
        }
        com.applovin.impl.mediation.b.g b = this.amN.b(hVar, str, maxAdFormat);
        if (b != null) {
            aVar.b(com.applovin.impl.mediation.b.g.a(b));
            return;
        }
        final g a2 = this.sdk.CS().a(hVar, hVar.zd());
        if (a2 == null) {
            aVar.b(com.applovin.impl.mediation.b.g.a(hVar, new MaxErrorImpl("Could not load adapter")));
            return;
        }
        Activity Db = context instanceof Activity ? (Activity) context : this.sdk.Db();
        MaxAdapterParametersImpl a3 = MaxAdapterParametersImpl.a(hVar, str, maxAdFormat);
        this.sdk.CT().a(hVar, Db);
        final long elapsedRealtime = SystemClock.elapsedRealtime();
        g.a aVar2 = new g.a() {
            {
                MediationServiceImpl.this = this;
            }

            @Override
            public void a(MaxError maxError) {
                com.applovin.impl.sdk.x unused = MediationServiceImpl.this.logger;
                if (com.applovin.impl.sdk.x.FL()) {
                    com.applovin.impl.sdk.x xVar = MediationServiceImpl.this.logger;
                    xVar.i("MediationService", "Signal collection failed from: " + a2.getName() + " for Ad Unit ID: " + str + " with error message: \"" + maxError.getMessage() + "\"");
                }
                long elapsedRealtime2 = SystemClock.elapsedRealtime();
                long j = elapsedRealtime;
                com.applovin.impl.mediation.b.g a4 = com.applovin.impl.mediation.b.g.a(hVar, a2, maxError, j, elapsedRealtime2 - j);
                MediationServiceImpl.this.a(a4, hVar, a2);
                aVar.b(a4);
                a2.destroy();
            }

            @Override
            public void onSignalCollected(String str2) {
                com.applovin.impl.sdk.x unused = MediationServiceImpl.this.logger;
                if (com.applovin.impl.sdk.x.FL()) {
                    com.applovin.impl.sdk.x xVar = MediationServiceImpl.this.logger;
                    StringBuilder sb = new StringBuilder("Signal collection successful from: ");
                    sb.append(a2.getName());
                    sb.append(" for Ad Unit ID: ");
                    xVar.f("MediationService", defpackage.a.m(sb, str, " with signal: \"", str2, "\""));
                }
                long elapsedRealtime2 = SystemClock.elapsedRealtime();
                long j = elapsedRealtime;
                com.applovin.impl.mediation.b.g a4 = com.applovin.impl.mediation.b.g.a(hVar, a2, str2, j, elapsedRealtime2 - j);
                MediationServiceImpl.this.amN.a(a4, hVar, str, maxAdFormat);
                aVar.b(a4);
                a2.destroy();
            }
        };
        if (!hVar.zc()) {
            if (com.applovin.impl.sdk.x.FL()) {
                com.applovin.impl.sdk.x xVar = this.logger;
                xVar.f("MediationService", "Collecting signal for adapter: " + a2.getName());
            }
            a2.a(a3, hVar, Db, aVar2);
        } else if (this.sdk.CT().b(hVar)) {
            if (com.applovin.impl.sdk.x.FL()) {
                com.applovin.impl.sdk.x xVar2 = this.logger;
                xVar2.f("MediationService", "Collecting signal for now-initialized adapter: " + a2.getName());
            }
            a2.a(a3, hVar, Db, aVar2);
        } else {
            if (com.applovin.impl.sdk.x.FL()) {
                com.applovin.impl.sdk.x xVar3 = this.logger;
                xVar3.i("MediationService", "Skip collecting signal for not-initialized adapter: " + a2.getName());
            }
            aVar.b(com.applovin.impl.mediation.b.g.a(hVar, new MaxErrorImpl("Adapter not initialized yet")));
        }
    }

    public void destroyAd(MaxAd maxAd) {
        if (maxAd instanceof com.applovin.impl.mediation.b.a) {
            if (com.applovin.impl.sdk.x.FL()) {
                com.applovin.impl.sdk.x xVar = this.logger;
                xVar.g("MediationService", "Destroying " + maxAd);
            }
            com.applovin.impl.mediation.b.a aVar = (com.applovin.impl.mediation.b.a) maxAd;
            g xU = aVar.xU();
            if (xU != null) {
                xU.destroy();
                aVar.yi();
            }
            this.sdk.CR().cw(aVar.xT());
        }
    }

    public JSONObject getAndResetCustomPostBodyData() {
        return this.amO.getAndSet(null);
    }

    public void loadAd(String str, String str2, MaxAdFormat maxAdFormat, d.a aVar, Map<String, Object> map, Map<String, Object> map2, Context context, a.InterfaceC0142a interfaceC0142a) {
        if (TextUtils.isEmpty(str)) {
            throw new IllegalArgumentException("No Ad Unit ID specified");
        }
        if (context == null) {
            throw new IllegalArgumentException("No context specified");
        }
        if (interfaceC0142a == null) {
            throw new IllegalArgumentException("No listener specified");
        }
        if (TextUtils.isEmpty(this.sdk.getMediationProvider())) {
            com.applovin.impl.sdk.x.I("AppLovinSdk", "Mediation provider is null. Please set AppLovin SDK mediation provider via AppLovinSdk.getInstance(context).setMediationProvider()");
        }
        if (!this.sdk.isEnabled()) {
            com.applovin.impl.sdk.x.G("AppLovinSdk", "Attempted to load ad before SDK initialization. Please wait until after the SDK has initialized, e.g. AppLovinSdk.initializeSdk(Context, SdkInitializationListener).");
        }
        List<String> initializationAdUnitIds = this.sdk.getSettings().getInitializationAdUnitIds();
        if (initializationAdUnitIds != null && initializationAdUnitIds.size() > 0 && !initializationAdUnitIds.contains(str) && !this.sdk.Da().isEnabled()) {
            if (com.applovin.impl.sdk.utils.t.b(com.applovin.impl.sdk.n.getApplicationContext(), this.sdk)) {
                String s = myobfuscated.b0.b.s("Ad Unit ID ", str, " has not been initialized. When you use selective init, any ad units that you do not explicitly specify are excluded from serving ads for the current session. For more information visit our docs: https://dash.applovin.com/documentation/mediation/android/getting-started/advanced-settings#selective-init");
                if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.aSD)).booleanValue()) {
                    throw new RuntimeException(s);
                }
                if (com.applovin.impl.sdk.x.FL()) {
                    this.logger.i("MediationService", s);
                }
            }
            String p = com.appsflyer.internal.h.p("uninitialized_ad_unit_id", str);
            this.sdk.CN().a(r.a.INTEGRATION_ERROR, "uninitialized_ad_unit_id", CollectionUtils.hashMap("ad_unit_id", str), p);
        }
        this.sdk.BH();
        if (str.length() != 16 && !str.startsWith("test_mode") && !this.sdk.getSdkKey().startsWith("05TMD")) {
            StringBuilder t = defpackage.d.t("Please double-check the ad unit ", str, " for ");
            t.append(maxAdFormat.getLabel());
            t.append(" : ");
            t.append(Log.getStackTraceString(new Throwable("")));
            com.applovin.impl.sdk.x.I("MediationService", t.toString());
        }
        if (!this.sdk.f(maxAdFormat)) {
            this.sdk.Cc();
            com.applovin.impl.sdk.utils.l.a((MaxAdRequestListener) interfaceC0142a, str, true, true);
            this.sdk.CZ().a(str, str2, maxAdFormat, aVar, map, map2, context, interfaceC0142a);
            return;
        }
        com.applovin.impl.sdk.x.I("MediationService", "Ad load failed due to disabled ad format " + maxAdFormat.getLabel());
        com.applovin.impl.sdk.utils.l.a(interfaceC0142a, str, new MaxErrorImpl(-1, "Disabled ad format " + maxAdFormat.getLabel()));
    }

    public void loadThirdPartyMediatedAd(String str, com.applovin.impl.mediation.b.a aVar, Activity activity, a.InterfaceC0142a interfaceC0142a) {
        if (aVar == null) {
            throw new IllegalArgumentException("No mediated ad specified");
        }
        if (com.applovin.impl.sdk.x.FL()) {
            this.logger.f("MediationService", "Loading " + aVar + "...");
        }
        this.sdk.CC().a(aVar, "WILL_LOAD");
        g c = this.sdk.CS().c(aVar);
        if (c != null) {
            MaxAdapterParametersImpl a2 = MaxAdapterParametersImpl.a(aVar);
            this.sdk.CT().a(aVar, activity);
            com.applovin.impl.mediation.b.a k = aVar.k(c);
            c.a(str, k);
            k.yd();
            c.a(str, a2, k, activity, new a(k, interfaceC0142a));
            return;
        }
        String str2 = "Failed to load " + aVar + ": adapter not loaded";
        com.applovin.impl.sdk.x.I("MediationService", str2);
        a(aVar, new MaxErrorImpl(-5001, str2), interfaceC0142a);
    }

    @Override
    public void onReceive(Intent intent, Map<String, Object> map) {
        if ("com.applovin.render_process_gone".equals(intent.getAction())) {
            Object FB = this.sdk.CA().FB();
            if (FB instanceof com.applovin.impl.mediation.b.a) {
                a((MaxError) MaxAdapterError.WEBVIEW_ERROR, (com.applovin.impl.mediation.b.a) FB, true);
            }
        }
    }

    public void processAdDisplayErrorPostbackForUserError(MaxError maxError, com.applovin.impl.mediation.b.a aVar) {
        a(maxError, aVar, false);
    }

    public void processAdapterInitializationPostback(com.applovin.impl.mediation.b.f fVar, long j, MaxAdapter.InitializationStatus initializationStatus, String str) {
        HashMap hashMap = new HashMap(2);
        hashMap.put("{INIT_STATUS}", String.valueOf(initializationStatus.getCode()));
        hashMap.put("{INIT_TIME_MS}", String.valueOf(j));
        a("minit", hashMap, new MaxErrorImpl(str), fVar);
    }

    public void processCallbackAdImpressionPostback(com.applovin.impl.mediation.b.a aVar, a.InterfaceC0142a interfaceC0142a) {
        if (aVar.xS().endsWith("cimp")) {
            this.sdk.CC().j(aVar);
            com.applovin.impl.sdk.utils.l.a((MaxAdRevenueListener) interfaceC0142a, (MaxAd) aVar);
        }
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.sdk.BU());
        if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.aQg)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mcimp", hashMap, aVar);
    }

    public void processRawAdImpression(com.applovin.impl.mediation.b.a aVar, a.InterfaceC0142a interfaceC0142a) {
        this.sdk.CC().a(aVar, "WILL_DISPLAY");
        if (aVar.xS().endsWith("mimp")) {
            this.sdk.CC().j(aVar);
            com.applovin.impl.sdk.utils.l.a((MaxAdRevenueListener) interfaceC0142a, (MaxAd) aVar);
        }
        if (((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.aQZ)).booleanValue()) {
            this.sdk.Cn().a(com.applovin.impl.sdk.d.e.aUu, com.applovin.impl.sdk.d.f.n(aVar), Long.valueOf(System.currentTimeMillis() - this.sdk.Df()));
        }
        HashMap hashMap = new HashMap(2);
        if (aVar instanceof com.applovin.impl.mediation.b.c) {
            hashMap.put("{TIME_TO_SHOW_MS}", String.valueOf(((com.applovin.impl.mediation.b.c) aVar).ys()));
        }
        String emptyIfNull = StringUtils.emptyIfNull(this.sdk.BU());
        if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.aQg)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mimp", hashMap, aVar);
    }

    public void processViewabilityAdImpressionPostback(com.applovin.impl.mediation.b.e eVar, long j, a.InterfaceC0142a interfaceC0142a) {
        if (eVar.xS().endsWith("vimp")) {
            this.sdk.CC().j(eVar);
            com.applovin.impl.sdk.utils.l.a((MaxAdRevenueListener) interfaceC0142a, (MaxAd) eVar);
        }
        HashMap hashMap = new HashMap(3);
        hashMap.put("{VIEWABILITY_FLAGS}", String.valueOf(j));
        hashMap.put("{USED_VIEWABILITY_TIMER}", String.valueOf(eVar.yN()));
        String emptyIfNull = StringUtils.emptyIfNull(this.sdk.BU());
        if (!((Boolean) this.sdk.a(com.applovin.impl.sdk.c.b.aQg)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mvimp", hashMap, eVar);
    }

    public void processWaterfallInfoPostback(String str, MaxAdFormat maxAdFormat, MaxAdWaterfallInfoImpl maxAdWaterfallInfoImpl, long j, long j2) {
        if (CollectionUtils.isEmpty(maxAdWaterfallInfoImpl.getPostbackUrls())) {
            return;
        }
        HashMap hashMap = new HashMap(8);
        CollectionUtils.putStringIfValid("mcode", maxAdWaterfallInfoImpl.getMCode(), hashMap);
        CollectionUtils.putStringIfValid("ad_unit_id", str, hashMap);
        CollectionUtils.putStringIfValid("ad_format", maxAdFormat.getLabel(), hashMap);
        CollectionUtils.putStringIfValid(AppMeasurementSdk.ConditionalUserProperty.NAME, maxAdWaterfallInfoImpl.getName(), hashMap);
        CollectionUtils.putLongIfValid("request_latency_ms", Long.valueOf(j2), hashMap);
        CollectionUtils.putLongIfValid("request_start_timestamp_ms", Long.valueOf(j), hashMap);
        CollectionUtils.putLongIfValid("wf_latency_ms", Long.valueOf(maxAdWaterfallInfoImpl.getLatencyMillis()), hashMap);
        List<MaxNetworkResponseInfo> networkResponses = maxAdWaterfallInfoImpl.getNetworkResponses();
        ArrayList arrayList = new ArrayList(networkResponses.size());
        for (MaxNetworkResponseInfo maxNetworkResponseInfo : networkResponses) {
            MaxMediatedNetworkInfo mediatedNetwork = maxNetworkResponseInfo.getMediatedNetwork();
            HashMap hashMap2 = new HashMap(5);
            CollectionUtils.putStringIfValid("bcode", ((MaxNetworkResponseInfoImpl) maxNetworkResponseInfo).getBCode(), hashMap2);
            hashMap2.put(AppMeasurementSdk.ConditionalUserProperty.NAME, mediatedNetwork.getName());
            CollectionUtils.putLongIfValid("latency_ms", Long.valueOf(maxNetworkResponseInfo.getLatencyMillis()), hashMap2);
            hashMap2.put("load_state", Integer.valueOf(maxNetworkResponseInfo.getAdLoadState().ordinal()));
            MaxErrorImpl maxErrorImpl = (MaxErrorImpl) maxNetworkResponseInfo.getError();
            if (maxErrorImpl != null) {
                HashMap hashMap3 = new HashMap(4);
                hashMap3.put("error_code", Integer.valueOf(maxErrorImpl.getCode()));
                hashMap3.put("error_message", maxErrorImpl.getMessage());
                hashMap3.put("third_party_sdk_error_code", Integer.valueOf(maxErrorImpl.getMediatedNetworkErrorCode()));
                hashMap3.put("third_party_sdk_error_message", maxErrorImpl.getMediatedNetworkErrorMessage());
                hashMap2.put("error_info", hashMap3);
            }
            arrayList.add(hashMap2);
        }
        hashMap.put("ads_info", arrayList);
        a("mwf_info", maxAdWaterfallInfoImpl.getPostbackUrls(), Collections.EMPTY_MAP, (Map<String, Object>) hashMap, (MaxError) null, (com.applovin.impl.mediation.b.f) null, false);
    }

    public void setCustomPostBodyData(JSONObject jSONObject) {
        this.amO.set(jSONObject);
    }

    public void showFullscreenAd(com.applovin.impl.mediation.b.c cVar, Activity activity, a.InterfaceC0142a interfaceC0142a) {
        if (cVar == null) {
            throw new IllegalArgumentException("No ad specified");
        }
        if (activity == null && MaxAdFormat.APP_OPEN != cVar.getFormat()) {
            throw new IllegalArgumentException("No activity specified");
        }
        this.sdk.CA().aN(true);
        g g = g(cVar);
        long yt = cVar.yt();
        if (com.applovin.impl.sdk.x.FL()) {
            com.applovin.impl.sdk.x xVar = this.logger;
            xVar.g("MediationService", "Showing ad " + cVar.getAdUnitId() + " with delay of " + yt + "ms...");
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new myobfuscated.y8.a(this, cVar, g, activity, interfaceC0142a, 0), yt);
    }

    public void showFullscreenAd(final com.applovin.impl.mediation.b.c cVar, final ViewGroup viewGroup, final Lifecycle lifecycle, final Activity activity, final a.InterfaceC0142a interfaceC0142a) {
        if (cVar == null) {
            throw new IllegalArgumentException("No ad specified");
        }
        if (activity == null) {
            throw new IllegalArgumentException("No activity specified");
        }
        this.sdk.CA().aN(true);
        final g g = g(cVar);
        long yt = cVar.yt();
        if (com.applovin.impl.sdk.x.FL()) {
            com.applovin.impl.sdk.x xVar = this.logger;
            xVar.g("MediationService", "Showing ad " + cVar.getAdUnitId() + " with delay of " + yt + "ms...");
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
            @Override
            public final void run() {
                MediationServiceImpl.this.a(cVar, g, viewGroup, lifecycle, activity, interfaceC0142a);
            }
        }, yt);
    }
}