导航菜单

页面标题

页面副标题

All File Recovery v1.0.2 - MediationServiceImpl.java 源代码

正在查看: All File Recovery v1.0.2 应用的 MediationServiceImpl.java JAVA 源代码文件

本页面展示 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.Nullable;
import com.applovin.impl.AbstractC0473a2;
import com.applovin.impl.AbstractC0536g3;
import com.applovin.impl.AbstractC0575l2;
import com.applovin.impl.AbstractC0640q2;
import com.applovin.impl.AbstractC0730y2;
import com.applovin.impl.AbstractC0742z6;
import com.applovin.impl.AbstractRunnableC0716w4;
import com.applovin.impl.C0474a3;
import com.applovin.impl.C0495b6;
import com.applovin.impl.C0537g4;
import com.applovin.impl.C0544h3;
import com.applovin.impl.C0547h6;
import com.applovin.impl.C0552i3;
import com.applovin.impl.C0577l4;
import com.applovin.impl.C0634p4;
import com.applovin.impl.C0635p5;
import com.applovin.impl.C0642q4;
import com.applovin.impl.C0649r4;
import com.applovin.impl.C0650r5;
import com.applovin.impl.C0690t2;
import com.applovin.impl.C0717w5;
import com.applovin.impl.C0729y1;
import com.applovin.impl.EnumC0540h;
import com.applovin.impl.mediation.MediationServiceImpl;
import com.applovin.impl.mediation.ads.a;
import com.applovin.impl.sdk.AppLovinBroadcastManager;
import com.applovin.impl.sdk.C0668g;
import com.applovin.impl.sdk.C0672k;
import com.applovin.impl.sdk.C0675n;
import com.applovin.impl.sdk.C0676o;
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.facebook.internal.C0752a;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicReference;
import org.json.JSONObject;

public class MediationServiceImpl implements AppLovinBroadcastManager.Receiver {
    private final C0672k a;
    private final C0676o b;
    private final C0634p4 c;
    private final AtomicReference d = new AtomicReference();

    public static class a {
        static final int[] a;

        static {
            int[] iArr = new int[MaxAdapter.InitializationStatus.values().length];
            a = iArr;
            try {
                iArr[MaxAdapter.InitializationStatus.DOES_NOT_APPLY.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[MaxAdapter.InitializationStatus.INITIALIZED_SUCCESS.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[MaxAdapter.InitializationStatus.INITIALIZED_UNKNOWN.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                a[MaxAdapter.InitializationStatus.INITIALIZED_FAILURE.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[MaxAdapter.InitializationStatus.NOT_INITIALIZED.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[MaxAdapter.InitializationStatus.INITIALIZING.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
        }
    }

    public class b implements MaxAdListener, MaxRewardedAdListener, MaxAdViewAdListener, MaxAdRevenueListener, a.InterfaceC0099a {
        private final AbstractC0640q2 a;
        private a.InterfaceC0099a b;

        public b(AbstractC0640q2 abstractC0640q2, a.InterfaceC0099a interfaceC0099a) {
            this.a = abstractC0640q2;
            this.b = interfaceC0099a;
        }

        public void b(MaxAd maxAd, Bundle bundle) {
            this.a.a(bundle);
            AbstractC0575l2.b(this.b, maxAd);
        }

        public void c(MaxAd maxAd, Bundle bundle) {
            this.a.a(bundle);
            C0676o unused = MediationServiceImpl.this.b;
            if (C0676o.a()) {
                MediationServiceImpl.this.b.a("MediationService", "Scheduling impression for ad via callback...");
            }
            MediationServiceImpl.this.processCallbackAdImpressionPostback(this.a, this.b);
            if (!((Boolean) MediationServiceImpl.this.a.a(AbstractC0536g3.O7)).booleanValue() || this.a.u().compareAndSet(false, true)) {
                MediationServiceImpl.this.a.l().a(this.a, C0668g.c.SHOW);
                MediationServiceImpl.this.a.u().b(this.a, "DID_DISPLAY");
                MediationServiceImpl.this.a.p().maybeSendAdEvent(this.a, "DID_DISPLAY");
                if (maxAd.getFormat().isFullscreenAd()) {
                    MediationServiceImpl.this.a.I().a(this.a);
                }
                AbstractC0575l2.c(this.b, maxAd);
            }
        }

        public void d(MaxAd maxAd, Bundle bundle) {
            this.a.a(bundle);
            AbstractC0575l2.d(this.b, maxAd);
        }

        public void e(final MaxAd maxAd, Bundle bundle) {
            this.a.a(bundle);
            MediationServiceImpl.this.a.l().a(this.a, C0668g.c.HIDE);
            MediationServiceImpl.this.a(this.a);
            AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
                @Override
                public final void run() {
                    MediationServiceImpl.b.this.a(maxAd);
                }
            }, maxAd instanceof C0690t2 ? ((C0690t2) maxAd).e0() : 0L);
        }

        public void f(MaxAd maxAd, Bundle bundle) {
            this.a.a(bundle);
            this.a.X();
            MediationServiceImpl.this.a.l().a(this.a, C0668g.c.LOAD);
            MediationServiceImpl.this.b(this.a);
            AbstractC0575l2.f(this.b, maxAd);
        }

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

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

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

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

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

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

        @Override
        public void onAdLoadFailed(String str, MaxError maxError) {
            this.a.X();
            MediationServiceImpl.this.b(this.a, maxError, this.b);
        }

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

        @Override
        public void onAdRequestStarted(String str) {
        }

        @Override
        public void onAdRevenuePaid(MaxAd maxAd) {
        }

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

        public void a(a.InterfaceC0099a interfaceC0099a) {
            this.b = interfaceC0099a;
        }

        public void a(MaxAd maxAd) {
            if (maxAd.getFormat().isFullscreenAd()) {
                MediationServiceImpl.this.a.I().b(maxAd);
            }
            AbstractC0575l2.e(this.b, maxAd);
        }

        public void a(MaxAd maxAd, Bundle bundle) {
            this.a.a(bundle);
            MediationServiceImpl.this.a.l().a(this.a, C0668g.c.CLICK);
            MediationServiceImpl.this.a(this.a, this.b);
            AbstractC0575l2.a((MaxAdListener) this.b, maxAd);
        }

        public void a(MaxAd maxAd, MaxError maxError, Bundle bundle) {
            this.a.a(bundle);
            MediationServiceImpl.this.a(this.a, maxError, this.b);
            if (maxAd.getFormat() == MaxAdFormat.REWARDED && (maxAd instanceof C0690t2)) {
                ((C0690t2) maxAd).c0();
            }
        }

        public void a(MaxAd maxAd, MaxReward maxReward, Bundle bundle) {
            this.a.a(bundle);
            AbstractC0575l2.a(this.b, maxAd, maxReward);
            MediationServiceImpl.this.a.q0().a((AbstractRunnableC0716w4) new C0495b6((C0690t2) maxAd, MediationServiceImpl.this.a), C0650r5.b.OTHER);
        }
    }

    public MediationServiceImpl(C0672k c0672k) {
        this.a = c0672k;
        this.b = c0672k.O();
        this.c = new C0634p4(c0672k);
        AppLovinBroadcastManager.registerReceiver(this, new IntentFilter("com.applovin.render_process_gone"));
    }

    public void collectSignal(final String str, final MaxAdFormat maxAdFormat, final C0649r4 c0649r4, Context context, final C0642q4.a aVar) {
        if (c0649r4 == 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");
        }
        C0642q4 b2 = this.c.b(c0649r4, str, maxAdFormat);
        if (b2 != null) {
            aVar.a(C0642q4.a(b2));
            return;
        }
        final C0595h a2 = this.a.T().a(c0649r4, c0649r4.z());
        if (a2 == null) {
            aVar.a(C0642q4.a(c0649r4, new MaxErrorImpl("Could not load adapter")));
            return;
        }
        final C0537g4 c0537g4 = new C0537g4("SignalCollection:" + c0649r4.c());
        final long elapsedRealtime = SystemClock.elapsedRealtime();
        Executor executor = C0537g4.i;
        c0537g4.a(executor, new C0537g4.b() {
            @Override
            public final void a(boolean z, Object obj, Object obj2) {
                MediationServiceImpl.this.a(elapsedRealtime, a2, str, c0649r4, maxAdFormat, aVar, z, (String) obj, (MaxError) obj2);
            }
        });
        C0717w5.a(c0649r4.m(), c0537g4, new MaxErrorImpl(MaxAdapterError.ERROR_CODE_SIGNAL_COLLECTION_TIMEOUT, "The adapter (" + c0649r4.c() + ") timed out collecting signal"), "MediationService", this.a);
        Activity u0 = context instanceof Activity ? (Activity) context : this.a.u0();
        final MaxAdapterParametersImpl a3 = MaxAdapterParametersImpl.a(c0649r4, str, maxAdFormat);
        if (c0649r4.v()) {
            C0537g4 a6 = this.a.S().a(c0649r4, u0);
            final Activity activity = u0;
            a6.a(executor, new Runnable() {
                @Override
                public final void run() {
                    MediationServiceImpl.this.a(c0537g4, a2, a3, c0649r4, activity);
                }
            });
            a6.a(executor, new C0537g4.a() {
                @Override
                public final void a(Object obj) {
                    MediationServiceImpl.this.a(a2, c0537g4, (String) obj);
                }
            });
            return;
        }
        if (c0649r4.w()) {
            C0537g4 a7 = this.a.S().a(c0649r4, u0);
            if (a7.d() && !c0649r4.y()) {
                if (C0676o.a()) {
                    this.b.b("MediationService", "Skip collecting signal for failed-initialized adapter: " + a2.g());
                }
                c0537g4.a(new MaxErrorImpl("Could not initialize adapter: " + ((String) a7.a())));
                return;
            }
        }
        if (C0676o.a()) {
            this.b.a("MediationService", "Collecting signal for adapter: " + a2.g());
        }
        a2.a(a3, c0649r4, u0, c0537g4);
    }

    public void destroyAd(MaxAd maxAd) {
        if (maxAd instanceof AbstractC0640q2) {
            if (C0676o.a()) {
                this.b.d("MediationService", "Destroying " + maxAd);
            }
            AbstractC0640q2 abstractC0640q2 = (AbstractC0640q2) maxAd;
            C0595h A = abstractC0640q2.A();
            if (A != null) {
                A.a();
                abstractC0640q2.t();
            }
            this.a.j().c(abstractC0640q2.O());
            this.a.l().a(abstractC0640q2, C0668g.c.DESTROY);
        }
    }

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

    public void loadAd(String str, @Nullable String str2, MaxAdFormat maxAdFormat, EnumC0540h enumC0540h, Map<String, Object> map, Map<String, Object> map2, Context context, a.InterfaceC0099a interfaceC0099a) {
        if (TextUtils.isEmpty(str)) {
            throw new IllegalArgumentException("No Ad Unit ID specified");
        }
        if (context == null) {
            throw new IllegalArgumentException("No context specified");
        }
        if (interfaceC0099a == null) {
            throw new IllegalArgumentException("No listener specified");
        }
        if (TextUtils.isEmpty(this.a.V())) {
            C0676o.h("AppLovinSdk", "Mediation provider is null. Please set the mediation provider in the AppLovinSdkInitializationConfiguration.Builder when initializing the AppLovinSDK.");
        }
        if (!this.a.B0()) {
            C0676o.j("AppLovinSdk", "Attempted to load ad before SDK initialization. Please wait until after the SDK has initialized, e.g. AppLovinSdk.initializeSdk(Context, SdkInitializationListener).");
        }
        List<String> adUnitIds = this.a.K() != null ? this.a.K().getAdUnitIds() : null;
        boolean startsWith = str.startsWith("test_mode");
        if (adUnitIds != null && adUnitIds.size() > 0 && !adUnitIds.contains(str) && !startsWith) {
            if (AbstractC0742z6.c(this.a)) {
                String a2 = android.support.v4.media.f.a("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://developers.applovin.com/en/max/android/overview/advanced-settings#selective-init");
                if (((Boolean) this.a.a(C0577l4.W5)).booleanValue()) {
                    throw new RuntimeException(a2);
                }
                if (C0676o.a()) {
                    this.b.b("MediationService", a2);
                }
            }
            this.a.E().a(C0729y1.u0, "uninitialized_ad_unit_id", CollectionUtils.hashMap("ad_unit_id", str), "uninitialized_ad_unit_id".concat(str));
        }
        this.a.c();
        if (str.length() != 16 && !startsWith && !this.a.i0().startsWith("05TMD")) {
            C0676o.h("MediationService", "Ad unit ID provided for " + maxAdFormat.getLabel() + " is invalid (" + str + "). Expected length: 16 characters.\n\nStack trace:\n" + Log.getStackTraceString(new Throwable()));
        }
        if (this.a.a(maxAdFormat)) {
            C0676o.h("MediationService", "Ad load failed due to disabled ad format " + maxAdFormat.getLabel());
            AbstractC0575l2.a(interfaceC0099a, str, new MaxErrorImpl(-1, "Disabled ad format " + maxAdFormat.getLabel()));
            return;
        }
        this.a.V0();
        AbstractC0575l2.a((MaxAdRequestListener) interfaceC0099a, str, true);
        if (this.a.R() != null) {
            this.a.R().a(str, str2, maxAdFormat, enumC0540h, map, map2, context, interfaceC0099a);
        } else {
            this.a.Q().a(str, str2, maxAdFormat, enumC0540h, map, map2, context, interfaceC0099a);
        }
    }

    public void loadThirdPartyMediatedAd(final String str, final AbstractC0640q2 abstractC0640q2, final Activity activity, final a.InterfaceC0099a interfaceC0099a) {
        C0537g4 c0537g4;
        if (abstractC0640q2 == null) {
            throw new IllegalArgumentException("No mediated ad specified");
        }
        if (C0676o.a()) {
            this.b.a("MediationService", "Loading " + abstractC0640q2 + "...");
        }
        this.a.P().a(C0729y1.T, abstractC0640q2);
        this.a.l().a(abstractC0640q2, C0668g.c.LOADING);
        this.a.u().b(abstractC0640q2, "WILL_LOAD");
        this.a.p().maybeSendAdEvent(abstractC0640q2, "WILL_LOAD");
        final C0595h a2 = this.a.T().a(abstractC0640q2);
        if (a2 == null) {
            String str2 = "Failed to load " + abstractC0640q2 + ": adapter not loaded";
            C0676o.h("MediationService", str2);
            b(abstractC0640q2, new MaxErrorImpl(-5001, str2), interfaceC0099a);
            return;
        }
        final MaxAdapterParametersImpl a3 = MaxAdapterParametersImpl.a(abstractC0640q2);
        if (abstractC0640q2.V()) {
            c0537g4 = this.a.S().a(abstractC0640q2, activity);
        } else {
            if (abstractC0640q2.W()) {
                this.a.S().a(abstractC0640q2, activity);
            }
            c0537g4 = null;
        }
        final AbstractC0640q2 a6 = abstractC0640q2.a(a2);
        a2.a(str, a6);
        a6.Y();
        if (c0537g4 == null) {
            a2.a(str, a3, a6, activity, new b(a6, interfaceC0099a));
            return;
        }
        Executor executor = C0537g4.i;
        c0537g4.a(executor, new C0537g4.a() {
            @Override
            public final void a(Object obj) {
                MediationServiceImpl.this.a(abstractC0640q2, interfaceC0099a, (String) obj);
            }
        });
        c0537g4.a(executor, new Runnable() {
            @Override
            public final void run() {
                MediationServiceImpl.this.a(a2, str, a3, a6, activity, interfaceC0099a);
            }
        });
    }

    @Override
    public void onReceive(Intent intent, @Nullable Map<String, Object> map) {
        if ("com.applovin.render_process_gone".equals(intent.getAction())) {
            Object a2 = this.a.I().a();
            if (a2 instanceof AbstractC0640q2) {
                a((MaxError) MaxAdapterError.WEBVIEW_ERROR, (AbstractC0640q2) a2, true);
            }
        }
    }

    public void processAdDisplayErrorPostbackForUserError(MaxError maxError, AbstractC0640q2 abstractC0640q2) {
        a(maxError, abstractC0640q2, false);
    }

    public void processAdapterInitializationPostback(C0474a3 c0474a3, 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), c0474a3);
        Map a2 = AbstractC0473a2.a(c0474a3);
        CollectionUtils.putStringIfValid("adapter_init_status", String.valueOf(initializationStatus.getCode()), a2);
        CollectionUtils.putStringIfValid(C0752a.Y, str, a2);
        CollectionUtils.putStringIfValid("duration_ms", String.valueOf(j), a2);
        switch (a.a[initializationStatus.ordinal()]) {
            case 1:
            case 2:
            case 3:
                this.a.P().d(C0729y1.M, a2);
                break;
            case 4:
                this.a.P().d(C0729y1.N, a2);
                break;
            case 5:
            case 6:
                this.a.O();
                if (C0676o.a()) {
                    this.a.O().k("MediationService", "Adapter init postback called while the adapter is not fully initialized.");
                }
                this.a.E().a(C0729y1.d, "adapterNotInitializedForPostback", a2);
                break;
        }
    }

    public void processCallbackAdImpressionPostback(AbstractC0640q2 abstractC0640q2, a.InterfaceC0099a interfaceC0099a) {
        if (abstractC0640q2.M().endsWith("cimp")) {
            this.a.u().b(abstractC0640q2);
            AbstractC0575l2.a((MaxAdRevenueListener) interfaceC0099a, (MaxAd) abstractC0640q2);
        }
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.a.w0().e());
        if (!((Boolean) this.a.a(C0577l4.f465x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mcimp", hashMap, abstractC0640q2);
        this.a.P().a(C0729y1.Y, abstractC0640q2);
    }

    public void processRawAdImpression(AbstractC0640q2 abstractC0640q2, a.InterfaceC0099a interfaceC0099a) {
        this.a.u().b(abstractC0640q2, "WILL_DISPLAY");
        this.a.p().maybeSendAdEvent(abstractC0640q2, "WILL_DISPLAY");
        if (abstractC0640q2.M().endsWith("mimp")) {
            this.a.u().b(abstractC0640q2);
            AbstractC0575l2.a((MaxAdRevenueListener) interfaceC0099a, (MaxAd) abstractC0640q2);
        }
        if (((Boolean) this.a.a(C0577l4.f439n4)).booleanValue()) {
            this.a.Y().a(C0544h3.d, C0552i3.a(abstractC0640q2), Long.valueOf(System.currentTimeMillis() - this.a.L()));
        }
        HashMap hashMap = new HashMap(2);
        if (abstractC0640q2 instanceof C0690t2) {
            hashMap.put("{TIME_TO_SHOW_MS}", String.valueOf(((C0690t2) abstractC0640q2).i0()));
        }
        String emptyIfNull = StringUtils.emptyIfNull(this.a.w0().e());
        if (!((Boolean) this.a.a(C0577l4.f465x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mimp", hashMap, abstractC0640q2);
        this.a.P().a(C0729y1.X, abstractC0640q2);
    }

    public void processViewabilityAdImpressionPostback(AbstractC0730y2 abstractC0730y2, long j, a.InterfaceC0099a interfaceC0099a) {
        if (abstractC0730y2.M().endsWith("vimp")) {
            this.a.u().b(abstractC0730y2);
            AbstractC0575l2.a((MaxAdRevenueListener) interfaceC0099a, (MaxAd) abstractC0730y2);
        }
        HashMap hashMap = new HashMap(3);
        hashMap.put("{VIEWABILITY_FLAGS}", String.valueOf(j));
        hashMap.put("{USED_VIEWABILITY_TIMER}", String.valueOf(abstractC0730y2.j0()));
        String emptyIfNull = StringUtils.emptyIfNull(this.a.w0().e());
        if (!((Boolean) this.a.a(C0577l4.f465x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mvimp", hashMap, abstractC0730y2);
        this.a.P().a(C0729y1.Z, abstractC0730y2);
    }

    public void processWaterfallInfoPostback(String str, MaxAdFormat maxAdFormat, MaxAdWaterfallInfoImpl maxAdWaterfallInfoImpl, @Nullable MaxError maxError, long j, long j2) {
        HashMap hashMap = new HashMap();
        CollectionUtils.putStringIfValid("ad_format", maxAdFormat.getLabel(), hashMap);
        CollectionUtils.putStringIfValid("ad_unit_id", str, hashMap);
        CollectionUtils.putStringIfValid("duration_ms", String.valueOf(j2), hashMap);
        if (maxError != null) {
            hashMap.putAll(AbstractC0473a2.a(maxError));
        }
        this.a.P().d(C0729y1.W, hashMap);
        if (CollectionUtils.isEmpty(maxAdWaterfallInfoImpl.getPostbackUrls())) {
            return;
        }
        HashMap hashMap2 = new HashMap(8);
        CollectionUtils.putStringIfValid("mcode", maxAdWaterfallInfoImpl.getMCode(), hashMap2);
        CollectionUtils.putStringIfValid("ad_unit_id", str, hashMap2);
        CollectionUtils.putStringIfValid("ad_format", maxAdFormat.getLabel(), hashMap2);
        CollectionUtils.putStringIfValid("name", maxAdWaterfallInfoImpl.getName(), hashMap2);
        CollectionUtils.putLongIfValid("request_latency_ms", Long.valueOf(j2), hashMap2);
        CollectionUtils.putLongIfValid("request_start_timestamp_ms", Long.valueOf(j), hashMap2);
        CollectionUtils.putLongIfValid("wf_latency_ms", Long.valueOf(maxAdWaterfallInfoImpl.getLatencyMillis()), hashMap2);
        List<MaxNetworkResponseInfo> networkResponses = maxAdWaterfallInfoImpl.getNetworkResponses();
        ArrayList arrayList = new ArrayList(networkResponses.size());
        for (MaxNetworkResponseInfo maxNetworkResponseInfo : networkResponses) {
            MaxMediatedNetworkInfo mediatedNetwork = maxNetworkResponseInfo.getMediatedNetwork();
            HashMap hashMap3 = new HashMap(5);
            CollectionUtils.putStringIfValid("bcode", ((MaxNetworkResponseInfoImpl) maxNetworkResponseInfo).getBCode(), hashMap3);
            hashMap3.put("name", mediatedNetwork.getName());
            CollectionUtils.putLongIfValid("latency_ms", Long.valueOf(maxNetworkResponseInfo.getLatencyMillis()), hashMap3);
            hashMap3.put("load_state", Integer.valueOf(maxNetworkResponseInfo.getAdLoadState().ordinal()));
            MaxErrorImpl maxErrorImpl = (MaxErrorImpl) maxNetworkResponseInfo.getError();
            if (maxErrorImpl != null) {
                HashMap hashMap4 = new HashMap(4);
                hashMap4.put("error_code", Integer.valueOf(maxErrorImpl.getCode()));
                hashMap4.put(C0752a.Y, maxErrorImpl.getMessage());
                hashMap4.put("third_party_sdk_error_code", Integer.valueOf(maxErrorImpl.getMediatedNetworkErrorCode()));
                hashMap4.put("third_party_sdk_error_message", maxErrorImpl.getMediatedNetworkErrorMessage());
                hashMap3.put("error_info", hashMap4);
            }
            arrayList.add(hashMap3);
        }
        hashMap2.put("ads_info", arrayList);
        a("mwf_info", maxAdWaterfallInfoImpl.getPostbackUrls(), Collections.EMPTY_MAP, (Map) hashMap2, (MaxError) null, (C0474a3) null, false);
    }

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

    public void showFullscreenAd(final C0690t2 c0690t2, final Activity activity, final a.InterfaceC0099a interfaceC0099a) {
        if (c0690t2 == null) {
            throw new IllegalArgumentException("No ad specified");
        }
        if (activity == null && MaxAdFormat.APP_OPEN != c0690t2.getFormat()) {
            throw new IllegalArgumentException("No activity specified");
        }
        this.a.I().a(true);
        final C0595h b2 = b(c0690t2);
        long k0 = c0690t2.k0();
        if (C0676o.a()) {
            this.b.d("MediationService", "Showing ad " + c0690t2.getAdUnitId() + " with delay of " + k0 + "ms...");
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
            @Override
            public final void run() {
                MediationServiceImpl.this.a(c0690t2, b2, activity, interfaceC0099a);
            }
        }, k0);
    }

    private C0595h b(C0690t2 c0690t2) {
        C0595h A = c0690t2.A();
        if (A != null) {
            return A;
        }
        this.a.I().a(false);
        if (C0676o.a()) {
            this.b.k("MediationService", "Failed to show " + c0690t2 + ": adapter not found");
        }
        C0676o.h("MediationService", "There may be an integration problem with the adapter for Ad Unit ID '" + c0690t2.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");
    }

    public void a(C0690t2 c0690t2, C0595h c0595h, Activity activity, a.InterfaceC0099a interfaceC0099a) {
        a(c0690t2);
        c0595h.b(c0690t2, activity);
        a(c0690t2, interfaceC0099a);
    }

    public void showFullscreenAd(final C0690t2 c0690t2, final ViewGroup viewGroup, final androidx.lifecycle.p pVar, final Activity activity, final a.InterfaceC0099a interfaceC0099a) {
        if (c0690t2 == null) {
            throw new IllegalArgumentException("No ad specified");
        }
        if (activity != null) {
            this.a.I().a(true);
            final C0595h b2 = b(c0690t2);
            long k0 = c0690t2.k0();
            if (C0676o.a()) {
                this.b.d("MediationService", "Showing ad " + c0690t2.getAdUnitId() + " with delay of " + k0 + "ms...");
            }
            AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
                @Override
                public final void run() {
                    MediationServiceImpl.this.a(c0690t2, b2, viewGroup, pVar, activity, interfaceC0099a);
                }
            }, k0);
            return;
        }
        throw new IllegalArgumentException("No activity specified");
    }

    public void a(C0690t2 c0690t2, C0595h c0595h, ViewGroup viewGroup, androidx.lifecycle.p pVar, Activity activity, a.InterfaceC0099a interfaceC0099a) {
        a(c0690t2);
        c0595h.a(c0690t2, viewGroup, pVar, activity);
        a(c0690t2, interfaceC0099a);
    }

    public void b(AbstractC0640q2 abstractC0640q2, MaxError maxError, MaxAdListener maxAdListener) {
        a(maxError, abstractC0640q2);
        destroyAd(abstractC0640q2);
        AbstractC0575l2.a(maxAdListener, abstractC0640q2.getAdUnitId(), maxError);
    }

    private void a(C0690t2 c0690t2) {
        if (c0690t2.getFormat() == MaxAdFormat.REWARDED) {
            this.a.q0().a((AbstractRunnableC0716w4) new C0547h6(c0690t2, this.a), C0650r5.b.OTHER);
        }
    }

    public void b(AbstractC0640q2 abstractC0640q2) {
        this.a.u().b(abstractC0640q2, "DID_LOAD");
        this.a.p().maybeSendAdEvent(abstractC0640q2, "DID_LOAD");
        if (abstractC0640q2.M().endsWith("load")) {
            this.a.u().b(abstractC0640q2);
        }
        HashMap hashMap = new HashMap(3);
        long G = abstractC0640q2.G();
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(G));
        if (abstractC0640q2.getFormat().isFullscreenAd()) {
            C0675n.a b2 = this.a.I().b(abstractC0640q2.getAdUnitId());
            hashMap.put("{SHOW_ATTEMPT_COUNT}", String.valueOf(b2.a()));
            hashMap.put("{SHOW_ATTEMPT_TIMESTAMP_MS}", String.valueOf(b2.b()));
        }
        a("load", hashMap, abstractC0640q2);
        Map a2 = AbstractC0473a2.a(abstractC0640q2);
        a2.put("duration_ms", String.valueOf(G));
        this.a.P().d(C0729y1.U, a2);
    }

    private void a(C0690t2 c0690t2, a.InterfaceC0099a interfaceC0099a) {
        this.a.I().a(false);
        a(c0690t2, (MaxAdListener) interfaceC0099a);
        if (C0676o.a()) {
            this.b.a("MediationService", "Scheduling impression for ad manually...");
        }
        processRawAdImpression(c0690t2, interfaceC0099a);
    }

    public void a(AbstractC0640q2 abstractC0640q2, a.InterfaceC0099a interfaceC0099a, String str) {
        String str2 = "Failed to load " + abstractC0640q2 + ": adapter init failed with error: " + str;
        if (C0676o.a()) {
            this.b.k("MediationService", str2);
        }
        b(abstractC0640q2, new MaxErrorImpl(MaxAdapterError.NOT_INITIALIZED.getErrorCode(), "Adapter initialization failed"), interfaceC0099a);
    }

    public void a(C0595h c0595h, String str, MaxAdapterParametersImpl maxAdapterParametersImpl, AbstractC0640q2 abstractC0640q2, Activity activity, a.InterfaceC0099a interfaceC0099a) {
        c0595h.a(str, maxAdapterParametersImpl, abstractC0640q2, activity, new b(abstractC0640q2, interfaceC0099a));
    }

    public void a(long j, C0595h c0595h, String str, C0649r4 c0649r4, MaxAdFormat maxAdFormat, C0642q4.a aVar, boolean z, String str2, MaxError maxError) {
        C0642q4 a2;
        String str3;
        long elapsedRealtime = SystemClock.elapsedRealtime() - j;
        if (z) {
            if (C0676o.a()) {
                this.b.a("MediationService", "Signal collection successful from: " + c0595h.g() + " for Ad Unit ID: " + str + " with signal: \"" + str2 + "\"");
                str3 = str2;
            } else {
                str3 = str2;
            }
            a2 = C0642q4.a(c0649r4, c0595h, str3, j, elapsedRealtime);
            this.c.a(a2, c0649r4, str, maxAdFormat);
            HashMap hashMap = new HashMap();
            CollectionUtils.putStringIfValid("network_name", c0649r4.c(), hashMap);
            CollectionUtils.putStringIfValid("adapter_class", c0649r4.b(), hashMap);
            CollectionUtils.putStringIfValid("adapter_version", c0595h.b(), hashMap);
            CollectionUtils.putStringIfValid("duration_ms", String.valueOf(elapsedRealtime), hashMap);
            CollectionUtils.putStringIfValid("ad_format", String.valueOf(maxAdFormat.getLabel()), hashMap);
            CollectionUtils.putStringIfValid("ad_unit_id", str, hashMap);
            this.a.P().d(C0729y1.O, hashMap);
        } else {
            if (C0676o.a()) {
                this.b.b("MediationService", "Signal collection failed from: " + c0595h.g() + " for Ad Unit ID: " + str + " with error message: \"" + maxError.getMessage() + "\"");
            }
            a2 = C0642q4.a(c0649r4, c0595h, maxError, j, elapsedRealtime);
            a(a2, c0649r4, c0595h);
        }
        aVar.a(a2);
        c0595h.a();
    }

    public void a(C0537g4 c0537g4, C0595h c0595h, MaxAdapterParametersImpl maxAdapterParametersImpl, C0649r4 c0649r4, Activity activity) {
        if (c0537g4.c()) {
            return;
        }
        if (C0676o.a()) {
            this.b.a("MediationService", "Collecting signal for now-initialized adapter: " + c0595h.g());
        }
        c0595h.a(maxAdapterParametersImpl, c0649r4, activity, c0537g4);
    }

    public void a(C0595h c0595h, C0537g4 c0537g4, String str) {
        if (C0676o.a()) {
            this.b.b("MediationService", "Skip collecting signal for failed-initialized adapter: " + c0595h.g());
        }
        c0537g4.a(new MaxErrorImpl(MaxAdapterError.ERROR_CODE_NOT_INITIALIZED, F.w.a("Could not initialize adapter: ", str)));
    }

    private void a(final C0690t2 c0690t2, final MaxAdListener maxAdListener) {
        final Long l = (Long) this.a.a(AbstractC0536g3.q7);
        if (l.longValue() <= 0) {
            return;
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new Runnable() {
            @Override
            public final void run() {
                MediationServiceImpl.this.a(c0690t2, l, maxAdListener);
            }
        }, l.longValue());
    }

    public void a(C0690t2 c0690t2, Long l, MaxAdListener maxAdListener) {
        if (c0690t2.u().get()) {
            return;
        }
        String str = "Ad (" + c0690t2.k() + ") has not been displayed after " + l + "ms. Failing ad display...";
        C0676o.h("MediationService", str);
        a(c0690t2, new MaxErrorImpl(-1, str), maxAdListener);
        this.a.I().b(c0690t2);
    }

    public void a(AbstractC0640q2 abstractC0640q2, MaxError maxError, MaxAdListener maxAdListener) {
        this.a.l().a(abstractC0640q2, C0668g.c.SHOW_ERROR);
        this.a.u().b(abstractC0640q2, "DID_FAIL_DISPLAY");
        this.a.p().maybeSendAdEvent(abstractC0640q2, "DID_FAIL_DISPLAY");
        a(maxError, abstractC0640q2, true);
        if (abstractC0640q2.u().compareAndSet(false, true)) {
            AbstractC0575l2.a(maxAdListener, abstractC0640q2, maxError);
        }
    }

    private void a(MaxError maxError, AbstractC0640q2 abstractC0640q2) {
        HashMap hashMap = new HashMap(3);
        long G = abstractC0640q2.G();
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(G));
        if (abstractC0640q2.getFormat().isFullscreenAd()) {
            C0675n.a b2 = this.a.I().b(abstractC0640q2.getAdUnitId());
            hashMap.put("{SHOW_ATTEMPT_COUNT}", String.valueOf(b2.a()));
            hashMap.put("{SHOW_ATTEMPT_TIMESTAMP_MS}", String.valueOf(b2.b()));
        }
        a("mlerr", hashMap, maxError, abstractC0640q2);
        Map a2 = AbstractC0473a2.a(abstractC0640q2);
        a2.putAll(AbstractC0473a2.a(maxError));
        a2.put("duration_ms", String.valueOf(G));
        this.a.P().d(C0729y1.V, a2);
    }

    public void a(AbstractC0640q2 abstractC0640q2) {
        this.a.u().b(abstractC0640q2, "DID_HIDE");
        this.a.p().maybeSendAdEvent(abstractC0640q2, "DID_HIDE");
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.a.w0().e());
        if (!((Boolean) this.a.a(C0577l4.f465x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mclose", hashMap, abstractC0640q2);
        this.a.P().a(C0729y1.b0, abstractC0640q2);
    }

    public void a(AbstractC0640q2 abstractC0640q2, a.InterfaceC0099a interfaceC0099a) {
        this.a.u().b(abstractC0640q2, "DID_CLICKED");
        this.a.u().b(abstractC0640q2, "DID_CLICK");
        this.a.p().maybeSendAdEvent(abstractC0640q2, "DID_CLICK");
        if (abstractC0640q2.M().endsWith("click")) {
            this.a.u().b(abstractC0640q2);
            AbstractC0575l2.a((MaxAdRevenueListener) interfaceC0099a, (MaxAd) abstractC0640q2);
        }
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.a.w0().e());
        if (!((Boolean) this.a.a(C0577l4.f465x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mclick", hashMap, abstractC0640q2);
    }

    private void a(MaxError maxError, AbstractC0640q2 abstractC0640q2, boolean z) {
        a("mierr", Collections.EMPTY_MAP, maxError, abstractC0640q2, z);
        if (!z || abstractC0640q2 == null) {
            return;
        }
        this.a.P().a(C0729y1.a0, abstractC0640q2, maxError);
    }

    private void a(C0642q4 c0642q4, C0649r4 c0649r4, C0595h c0595h) {
        long b2 = c0642q4.b();
        HashMap hashMap = new HashMap(3);
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(b2));
        CollectionUtils.putStringIfValid("{ADAPTER_VERSION}", c0595h.b(), hashMap);
        CollectionUtils.putStringIfValid("{SDK_VERSION}", c0595h.i(), hashMap);
        a("serr", hashMap, c0642q4.c(), c0649r4);
        Map a2 = AbstractC0473a2.a(c0642q4.c());
        CollectionUtils.putStringIfValid("network_name", c0649r4.c(), a2);
        CollectionUtils.putStringIfValid("adapter_class", c0649r4.b(), a2);
        CollectionUtils.putStringIfValid("adapter_version", c0595h.b(), a2);
        CollectionUtils.putStringIfValid("duration_ms", String.valueOf(b2), a2);
        this.a.P().d(C0729y1.P, a2);
    }

    private void a(String str, Map map, C0474a3 c0474a3) {
        a(str, map, (MaxError) null, c0474a3);
    }

    private void a(String str, Map map, MaxError maxError, C0474a3 c0474a3) {
        a(str, map, maxError, c0474a3, true);
    }

    private void a(String str, Map map, MaxError maxError, C0474a3 c0474a3, boolean z) {
        String str2;
        Map map2 = CollectionUtils.map(map);
        String str3 = "";
        map2.put("{PLACEMENT}", z ? StringUtils.emptyIfNull(c0474a3.getPlacement()) : "");
        if (!z) {
            str2 = "";
        } else {
            str2 = StringUtils.emptyIfNull(c0474a3.e());
        }
        map2.put("{CUSTOM_DATA}", str2);
        if (c0474a3 instanceof AbstractC0640q2) {
            AbstractC0640q2 abstractC0640q2 = (AbstractC0640q2) c0474a3;
            if (z) {
                str3 = StringUtils.emptyIfNull(abstractC0640q2.getCreativeId());
            }
            map2.put("{CREATIVE_ID}", str3);
        }
        a(str, (List) null, map2, (Map) null, maxError, c0474a3, z);
    }

    private void a(String str, List list, Map map, Map map2, MaxError maxError, C0474a3 c0474a3, boolean z) {
        this.a.q0().a((AbstractRunnableC0716w4) new C0635p5(str, list, map, map2, maxError, c0474a3, this.a, z), C0650r5.b.OTHER);
    }
}