导航菜单

页面标题

页面副标题

FileWipe Pro v3.0.0 - MediationServiceImpl.java 源代码

正在查看: FileWipe Pro v3.0.0 应用的 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 com.applovin.impl.a2;
import com.applovin.impl.a3;
import com.applovin.impl.a7;
import com.applovin.impl.b6;
import com.applovin.impl.g3;
import com.applovin.impl.g4;
import com.applovin.impl.h3;
import com.applovin.impl.h6;
import com.applovin.impl.i3;
import com.applovin.impl.l2;
import com.applovin.impl.l4;
import com.applovin.impl.mediation.ads.a;
import com.applovin.impl.p4;
import com.applovin.impl.p5;
import com.applovin.impl.q2;
import com.applovin.impl.q4;
import com.applovin.impl.r4;
import com.applovin.impl.r5;
import com.applovin.impl.sdk.AppLovinBroadcastManager;
import com.applovin.impl.sdk.g;
import com.applovin.impl.sdk.n;
import com.applovin.impl.sdk.utils.CollectionUtils;
import com.applovin.impl.sdk.utils.StringUtils;
import com.applovin.impl.t2;
import com.applovin.impl.w4;
import com.applovin.impl.w5;
import com.applovin.impl.x8;
import com.applovin.impl.y1;
import com.applovin.impl.y2;
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.internal.measurement.a1;
import com.mbridge.msdk.foundation.entity.CampaignEx;
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 com.applovin.impl.sdk.k f3178a;

    private final com.applovin.impl.sdk.o f3179b;

    private final p4 f3180c;

    private final AtomicReference f3181d = new AtomicReference();

    public static class a {

        static final int[] f3182a;

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

    public class b implements MaxAdListener, MaxRewardedAdListener, MaxAdViewAdListener, MaxAdRevenueListener, a.InterfaceC0008a {

        private final q2 f3183a;

        private a.InterfaceC0008a f3184b;

        public b(q2 q2Var, a.InterfaceC0008a interfaceC0008a) {
            this.f3183a = q2Var;
            this.f3184b = interfaceC0008a;
        }

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

        public void c(MaxAd maxAd, Bundle bundle) {
            this.f3183a.a(bundle);
            com.applovin.impl.sdk.o unused = MediationServiceImpl.this.f3179b;
            if (com.applovin.impl.sdk.o.a()) {
                MediationServiceImpl.this.f3179b.a("MediationService", "Scheduling impression for ad via callback...");
            }
            MediationServiceImpl.this.processCallbackAdImpressionPostback(this.f3183a, this.f3184b);
            if (!((Boolean) MediationServiceImpl.this.f3178a.a(g3.P7)).booleanValue() || this.f3183a.u().compareAndSet(false, true)) {
                MediationServiceImpl.this.f3178a.l().a(this.f3183a, g.c.SHOW);
                MediationServiceImpl.this.f3178a.u().b(this.f3183a, "DID_DISPLAY");
                MediationServiceImpl.this.f3178a.p().maybeSendAdEvent(this.f3183a, "DID_DISPLAY");
                if (maxAd.getFormat().isFullscreenAd()) {
                    MediationServiceImpl.this.f3178a.I().a(this.f3183a);
                }
                l2.c(this.f3184b, maxAd);
            }
        }

        public void d(MaxAd maxAd, Bundle bundle) {
            this.f3183a.a(bundle);
            l2.d(this.f3184b, maxAd);
        }

        public void e(MaxAd maxAd, Bundle bundle) {
            this.f3183a.a(bundle);
            MediationServiceImpl.this.f3178a.l().a(this.f3183a, g.c.HIDE);
            MediationServiceImpl.this.a(this.f3183a);
            AppLovinSdkUtils.runOnUiThreadDelayed(new r(1, this, maxAd), maxAd instanceof t2 ? ((t2) maxAd).e0() : 0L);
        }

        public void f(MaxAd maxAd, Bundle bundle) {
            this.f3183a.a(bundle);
            this.f3183a.X();
            MediationServiceImpl.this.f3178a.l().a(this.f3183a, g.c.LOAD);
            MediationServiceImpl.this.b(this.f3183a);
            l2.f(this.f3184b, 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.f3183a.X();
            MediationServiceImpl.this.b(this.f3183a, maxError, this.f3184b);
        }

        @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.InterfaceC0008a interfaceC0008a) {
            this.f3184b = interfaceC0008a;
        }

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

        public void a(MaxAd maxAd, Bundle bundle) {
            this.f3183a.a(bundle);
            MediationServiceImpl.this.f3178a.l().a(this.f3183a, g.c.CLICK);
            MediationServiceImpl.this.a(this.f3183a, this.f3184b);
            l2.a((MaxAdListener) this.f3184b, maxAd);
        }

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

        public void a(MaxAd maxAd, MaxReward maxReward, Bundle bundle) {
            this.f3183a.a(bundle);
            l2.a(this.f3184b, maxAd, maxReward);
            MediationServiceImpl.this.f3178a.q0().a((w4) new b6((t2) maxAd, MediationServiceImpl.this.f3178a), r5.b.OTHER);
        }
    }

    public MediationServiceImpl(com.applovin.impl.sdk.k kVar) {
        this.f3178a = kVar;
        this.f3179b = kVar.O();
        this.f3180c = new p4(kVar);
        AppLovinBroadcastManager.registerReceiver(this, new IntentFilter("com.applovin.render_process_gone"));
    }

    public void collectSignal(final String str, final MaxAdFormat maxAdFormat, final r4 r4Var, Context context, final q4.a aVar) {
        if (r4Var == 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");
        }
        q4 b10 = this.f3180c.b(r4Var, str, maxAdFormat);
        if (b10 != null) {
            aVar.a(q4.a(b10));
            return;
        }
        final h a10 = this.f3178a.T().a(r4Var, r4Var.z());
        if (a10 == null) {
            aVar.a(q4.a(r4Var, new MaxErrorImpl("Could not load adapter")));
            return;
        }
        g4 g4Var = new g4("SignalCollection:" + r4Var.c());
        final long elapsedRealtime = SystemClock.elapsedRealtime();
        Executor executor = g4.f2556i;
        g4Var.a(executor, new g4.b() {
            @Override
            public final void a(boolean z3, Object obj, Object obj2) {
                MediationServiceImpl mediationServiceImpl = MediationServiceImpl.this;
                h hVar = a10;
                r4 r4Var2 = r4Var;
                q4.a aVar2 = aVar;
                mediationServiceImpl.a(elapsedRealtime, hVar, str, r4Var2, maxAdFormat, aVar2, z3, (String) obj, (MaxError) obj2);
            }
        });
        w5.a(r4Var.m(), g4Var, new MaxErrorImpl(MaxAdapterError.ERROR_CODE_SIGNAL_COLLECTION_TIMEOUT, "The adapter (" + r4Var.c() + ") timed out collecting signal"), "MediationService", this.f3178a);
        Activity u02 = context instanceof Activity ? (Activity) context : this.f3178a.u0();
        MaxAdapterParametersImpl a11 = MaxAdapterParametersImpl.a(r4Var, str, maxAdFormat);
        if (r4Var.v()) {
            g4 a12 = this.f3178a.S().a(r4Var, u02);
            a12.a(executor, new j(this, g4Var, a10, a11, r4Var, u02, 0));
            a12.a(executor, new k(this, a10, g4Var, 0));
            return;
        }
        if (r4Var.w()) {
            g4 a13 = this.f3178a.S().a(r4Var, u02);
            if (a13.d() && !r4Var.y()) {
                if (com.applovin.impl.sdk.o.a()) {
                    this.f3179b.b("MediationService", "Skip collecting signal for failed-initialized adapter: " + a10.g());
                }
                g4Var.a(new MaxErrorImpl("Could not initialize adapter: " + ((String) a13.a())));
                return;
            }
        }
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.a("MediationService", "Collecting signal for adapter: " + a10.g());
        }
        a10.a(a11, r4Var, u02, g4Var);
    }

    public void destroyAd(MaxAd maxAd) {
        if (maxAd instanceof q2) {
            if (com.applovin.impl.sdk.o.a()) {
                this.f3179b.d("MediationService", "Destroying " + maxAd);
            }
            q2 q2Var = (q2) maxAd;
            h A = q2Var.A();
            if (A != null) {
                A.a();
                q2Var.t();
            }
            this.f3178a.j().c(q2Var.O());
            this.f3178a.l().a(q2Var, g.c.DESTROY);
        }
    }

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

    public void loadAd(String str, String str2, MaxAdFormat maxAdFormat, com.applovin.impl.h hVar, Map<String, Object> map, Map<String, Object> map2, Context context, a.InterfaceC0008a interfaceC0008a) {
        if (TextUtils.isEmpty(str)) {
            throw new IllegalArgumentException("No Ad Unit ID specified");
        }
        if (context == null) {
            throw new IllegalArgumentException("No context specified");
        }
        if (interfaceC0008a == null) {
            throw new IllegalArgumentException("No listener specified");
        }
        if (TextUtils.isEmpty(this.f3178a.V())) {
            com.applovin.impl.sdk.o.h("AppLovinSdk", "Mediation provider is null. Please set the mediation provider in the AppLovinSdkInitializationConfiguration.Builder when initializing the AppLovinSDK.");
        }
        if (!this.f3178a.B0()) {
            com.applovin.impl.sdk.o.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.f3178a.K() != null ? this.f3178a.K().getAdUnitIds() : null;
        boolean startsWith = str.startsWith("test_mode");
        if (adUnitIds != null && adUnitIds.size() > 0 && !adUnitIds.contains(str) && !startsWith) {
            if (a7.c(this.f3178a)) {
                String g5 = j0.a.g("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.f3178a.a(l4.X5)).booleanValue()) {
                    throw new RuntimeException(g5);
                }
                if (com.applovin.impl.sdk.o.a()) {
                    this.f3179b.b("MediationService", g5);
                }
            }
            this.f3178a.E().a(y1.f4720w0, "uninitialized_ad_unit_id", CollectionUtils.hashMap("ad_unit_id", str), "uninitialized_ad_unit_id".concat(str));
        }
        this.f3178a.c();
        if (str.length() != 16 && !startsWith && !this.f3178a.i0().startsWith("05TMD")) {
            com.applovin.impl.sdk.o.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.f3178a.a(maxAdFormat)) {
            com.applovin.impl.sdk.o.h("MediationService", "Ad load failed due to disabled ad format " + maxAdFormat.getLabel());
            l2.a(interfaceC0008a, str, new MaxErrorImpl(-1, "Disabled ad format " + maxAdFormat.getLabel()));
            return;
        }
        this.f3178a.V0();
        l2.a((MaxAdRequestListener) interfaceC0008a, str, true);
        if (this.f3178a.R() != null) {
            this.f3178a.R().a(str, str2, maxAdFormat, hVar, map, map2, context, interfaceC0008a);
        } else {
            this.f3178a.Q().a(str, str2, maxAdFormat, hVar, map, map2, context, interfaceC0008a);
        }
    }

    public void loadThirdPartyMediatedAd(String str, q2 q2Var, Activity activity, a.InterfaceC0008a interfaceC0008a) {
        g4 g4Var;
        if (q2Var == null) {
            throw new IllegalArgumentException("No mediated ad specified");
        }
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.a("MediationService", "Loading " + q2Var + "...");
        }
        this.f3178a.P().a(y1.V, q2Var);
        this.f3178a.l().a(q2Var, g.c.LOADING);
        this.f3178a.u().b(q2Var, "WILL_LOAD");
        this.f3178a.p().maybeSendAdEvent(q2Var, "WILL_LOAD");
        h a10 = this.f3178a.T().a(q2Var);
        if (a10 == null) {
            String str2 = "Failed to load " + q2Var + ": adapter not loaded";
            com.applovin.impl.sdk.o.h("MediationService", str2);
            b(q2Var, new MaxErrorImpl(-5001, str2), interfaceC0008a);
            return;
        }
        MaxAdapterParametersImpl a11 = MaxAdapterParametersImpl.a(q2Var);
        if (q2Var.V()) {
            g4Var = this.f3178a.S().a(q2Var, activity);
        } else {
            if (q2Var.W()) {
                this.f3178a.S().a(q2Var, activity);
            }
            g4Var = null;
        }
        q2 a12 = q2Var.a(a10);
        a10.a(str, a12);
        a12.Y();
        if (g4Var == null) {
            a10.a(str, a11, a12, activity, new b(a12, interfaceC0008a));
            return;
        }
        Executor executor = g4.f2556i;
        g4Var.a(executor, new k(this, q2Var, interfaceC0008a, 1));
        g4Var.a(executor, new l(this, a10, str, a11, a12, activity, interfaceC0008a));
    }

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

    public void processAdDisplayErrorPostbackForUserError(MaxError maxError, q2 q2Var) {
        a(maxError, q2Var, false);
    }

    public void processAdapterInitializationPostback(a3 a3Var, long j5, 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(j5));
        a("minit", hashMap, new MaxErrorImpl(str), a3Var);
        Map a10 = a2.a(a3Var);
        CollectionUtils.putStringIfValid("adapter_init_status", String.valueOf(initializationStatus.getCode()), a10);
        CollectionUtils.putStringIfValid("error_message", str, a10);
        CollectionUtils.putStringIfValid("duration_ms", String.valueOf(j5), a10);
        switch (a.f3182a[initializationStatus.ordinal()]) {
            case 1:
            case 2:
            case 3:
                this.f3178a.P().d(y1.O, a10);
                break;
            case 4:
                this.f3178a.P().d(y1.P, a10);
                break;
            case 5:
            case 6:
                this.f3178a.O();
                if (com.applovin.impl.sdk.o.a()) {
                    this.f3178a.O().k("MediationService", "Adapter init postback called while the adapter is not fully initialized.");
                }
                this.f3178a.E().a(y1.f4685d, "adapterNotInitializedForPostback", a10);
                break;
        }
    }

    public void processCallbackAdImpressionPostback(q2 q2Var, a.InterfaceC0008a interfaceC0008a) {
        if (q2Var.M().endsWith("cimp")) {
            this.f3178a.u().b(q2Var);
            l2.a((MaxAdRevenueListener) interfaceC0008a, (MaxAd) q2Var);
        }
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.f3178a.w0().e());
        if (!((Boolean) this.f3178a.a(l4.f3025x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mcimp", hashMap, q2Var);
        this.f3178a.P().a(y1.f4681a0, q2Var);
    }

    public void processRawAdImpression(q2 q2Var, a.InterfaceC0008a interfaceC0008a) {
        this.f3178a.u().b(q2Var, "WILL_DISPLAY");
        this.f3178a.p().maybeSendAdEvent(q2Var, "WILL_DISPLAY");
        if (q2Var.M().endsWith("mimp")) {
            this.f3178a.u().b(q2Var);
            l2.a((MaxAdRevenueListener) interfaceC0008a, (MaxAd) q2Var);
        }
        if (((Boolean) this.f3178a.a(l4.f2954n4)).booleanValue()) {
            this.f3178a.Y().a(h3.f2635d, i3.a(q2Var), Long.valueOf(System.currentTimeMillis() - this.f3178a.L()));
        }
        HashMap hashMap = new HashMap(2);
        if (q2Var instanceof t2) {
            hashMap.put("{TIME_TO_SHOW_MS}", String.valueOf(((t2) q2Var).i0()));
        }
        String emptyIfNull = StringUtils.emptyIfNull(this.f3178a.w0().e());
        if (!((Boolean) this.f3178a.a(l4.f3025x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mimp", hashMap, q2Var);
        this.f3178a.P().a(y1.Z, q2Var);
    }

    public void processViewabilityAdImpressionPostback(y2 y2Var, long j5, a.InterfaceC0008a interfaceC0008a) {
        if (y2Var.M().endsWith("vimp")) {
            this.f3178a.u().b(y2Var);
            l2.a((MaxAdRevenueListener) interfaceC0008a, (MaxAd) y2Var);
        }
        HashMap hashMap = new HashMap(3);
        hashMap.put("{VIEWABILITY_FLAGS}", String.valueOf(j5));
        hashMap.put("{USED_VIEWABILITY_TIMER}", String.valueOf(y2Var.j0()));
        String emptyIfNull = StringUtils.emptyIfNull(this.f3178a.w0().e());
        if (!((Boolean) this.f3178a.a(l4.f3025x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mvimp", hashMap, y2Var);
        this.f3178a.P().a(y1.f4682b0, y2Var);
    }

    public void processWaterfallInfoPostback(String str, MaxAdFormat maxAdFormat, MaxAdWaterfallInfoImpl maxAdWaterfallInfoImpl, MaxError maxError, long j5, long j6) {
        HashMap hashMap = new HashMap();
        CollectionUtils.putStringIfValid("ad_format", maxAdFormat.getLabel(), hashMap);
        CollectionUtils.putStringIfValid("ad_unit_id", str, hashMap);
        CollectionUtils.putStringIfValid("duration_ms", String.valueOf(j6), hashMap);
        if (maxError != null) {
            hashMap.putAll(a2.a(maxError));
        }
        this.f3178a.P().d(y1.Y, 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(j6), hashMap2);
        CollectionUtils.putLongIfValid("request_start_timestamp_ms", Long.valueOf(j5), 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("error_message", 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, (a3) null, false);
    }

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

    public void showFullscreenAd(t2 t2Var, Activity activity, a.InterfaceC0008a interfaceC0008a) {
        if (t2Var == null) {
            throw new IllegalArgumentException("No ad specified");
        }
        if (activity == null && MaxAdFormat.APP_OPEN != t2Var.getFormat()) {
            throw new IllegalArgumentException("No activity specified");
        }
        this.f3178a.I().a(true);
        h b10 = b(t2Var);
        long k0 = t2Var.k0();
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.d("MediationService", "Showing ad " + t2Var.getAdUnitId() + " with delay of " + k0 + "ms...");
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new x8(this, t2Var, b10, activity, interfaceC0008a), k0);
    }

    private h b(t2 t2Var) {
        h A = t2Var.A();
        if (A != null) {
            return A;
        }
        this.f3178a.I().a(false);
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.k("MediationService", "Failed to show " + t2Var + ": adapter not found");
        }
        com.applovin.impl.sdk.o.h("MediationService", "There may be an integration problem with the adapter for Ad Unit ID '" + t2Var.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(t2 t2Var, h hVar, Activity activity, a.InterfaceC0008a interfaceC0008a) {
        a(t2Var);
        hVar.b(t2Var, activity);
        a(t2Var, interfaceC0008a);
    }

    public void showFullscreenAd(t2 t2Var, ViewGroup viewGroup, androidx.lifecycle.p pVar, Activity activity, a.InterfaceC0008a interfaceC0008a) {
        if (t2Var == null) {
            throw new IllegalArgumentException("No ad specified");
        }
        if (activity != null) {
            this.f3178a.I().a(true);
            h b10 = b(t2Var);
            long k0 = t2Var.k0();
            if (com.applovin.impl.sdk.o.a()) {
                this.f3179b.d("MediationService", "Showing ad " + t2Var.getAdUnitId() + " with delay of " + k0 + "ms...");
            }
            AppLovinSdkUtils.runOnUiThreadDelayed(new l(this, t2Var, b10, viewGroup, pVar, activity, interfaceC0008a), k0);
            return;
        }
        throw new IllegalArgumentException("No activity specified");
    }

    public void a(t2 t2Var, h hVar, ViewGroup viewGroup, androidx.lifecycle.p pVar, Activity activity, a.InterfaceC0008a interfaceC0008a) {
        a(t2Var);
        hVar.a(t2Var, viewGroup, pVar, activity);
        a(t2Var, interfaceC0008a);
    }

    public void b(q2 q2Var, MaxError maxError, MaxAdListener maxAdListener) {
        a(maxError, q2Var);
        destroyAd(q2Var);
        l2.a(maxAdListener, q2Var.getAdUnitId(), maxError);
    }

    private void a(t2 t2Var) {
        if (t2Var.getFormat() == MaxAdFormat.REWARDED) {
            this.f3178a.q0().a((w4) new h6(t2Var, this.f3178a), r5.b.OTHER);
        }
    }

    public void b(q2 q2Var) {
        this.f3178a.u().b(q2Var, "DID_LOAD");
        this.f3178a.p().maybeSendAdEvent(q2Var, "DID_LOAD");
        if (q2Var.M().endsWith("load")) {
            this.f3178a.u().b(q2Var);
        }
        HashMap hashMap = new HashMap(3);
        long G = q2Var.G();
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(G));
        if (q2Var.getFormat().isFullscreenAd()) {
            n.a b10 = this.f3178a.I().b(q2Var.getAdUnitId());
            hashMap.put("{SHOW_ATTEMPT_COUNT}", String.valueOf(b10.a()));
            hashMap.put("{SHOW_ATTEMPT_TIMESTAMP_MS}", String.valueOf(b10.b()));
        }
        a("load", hashMap, q2Var);
        Map a10 = a2.a(q2Var);
        a10.put("duration_ms", String.valueOf(G));
        this.f3178a.P().d(y1.W, a10);
    }

    private void a(t2 t2Var, a.InterfaceC0008a interfaceC0008a) {
        this.f3178a.I().a(false);
        a(t2Var, (MaxAdListener) interfaceC0008a);
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.a("MediationService", "Scheduling impression for ad manually...");
        }
        processRawAdImpression(t2Var, interfaceC0008a);
    }

    public void a(q2 q2Var, a.InterfaceC0008a interfaceC0008a, String str) {
        String str2 = "Failed to load " + q2Var + ": adapter init failed with error: " + str;
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.k("MediationService", str2);
        }
        b(q2Var, new MaxErrorImpl(MaxAdapterError.NOT_INITIALIZED.getErrorCode(), "Adapter initialization failed"), interfaceC0008a);
    }

    public void a(h hVar, String str, MaxAdapterParametersImpl maxAdapterParametersImpl, q2 q2Var, Activity activity, a.InterfaceC0008a interfaceC0008a) {
        hVar.a(str, maxAdapterParametersImpl, q2Var, activity, new b(q2Var, interfaceC0008a));
    }

    public void a(long j5, h hVar, String str, r4 r4Var, MaxAdFormat maxAdFormat, q4.a aVar, boolean z3, String str2, MaxError maxError) {
        q4 a10;
        String str3;
        long elapsedRealtime = SystemClock.elapsedRealtime() - j5;
        if (z3) {
            if (com.applovin.impl.sdk.o.a()) {
                this.f3179b.a("MediationService", "Signal collection successful from: " + hVar.g() + " for Ad Unit ID: " + str + " with signal: \"" + str2 + "\"");
                str3 = str2;
            } else {
                str3 = str2;
            }
            a10 = q4.a(r4Var, hVar, str3, j5, elapsedRealtime);
            this.f3180c.a(a10, r4Var, str, maxAdFormat);
            HashMap hashMap = new HashMap();
            CollectionUtils.putStringIfValid("network_name", r4Var.c(), hashMap);
            CollectionUtils.putStringIfValid("adapter_class", r4Var.b(), hashMap);
            CollectionUtils.putStringIfValid("adapter_version", hVar.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.f3178a.P().d(y1.Q, hashMap);
        } else {
            if (com.applovin.impl.sdk.o.a()) {
                this.f3179b.b("MediationService", "Signal collection failed from: " + hVar.g() + " for Ad Unit ID: " + str + " with error message: \"" + maxError.getMessage() + "\"");
            }
            a10 = q4.a(r4Var, hVar, maxError, j5, elapsedRealtime);
            a(a10, r4Var, hVar);
        }
        aVar.a(a10);
        hVar.a();
    }

    public void a(g4 g4Var, h hVar, MaxAdapterParametersImpl maxAdapterParametersImpl, r4 r4Var, Activity activity) {
        if (g4Var.c()) {
            return;
        }
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.a("MediationService", "Collecting signal for now-initialized adapter: " + hVar.g());
        }
        hVar.a(maxAdapterParametersImpl, r4Var, activity, g4Var);
    }

    public void a(h hVar, g4 g4Var, String str) {
        if (com.applovin.impl.sdk.o.a()) {
            this.f3179b.b("MediationService", "Skip collecting signal for failed-initialized adapter: " + hVar.g());
        }
        g4Var.a(new MaxErrorImpl(MaxAdapterError.ERROR_CODE_NOT_INITIALIZED, a1.k("Could not initialize adapter: ", str)));
    }

    private void a(t2 t2Var, MaxAdListener maxAdListener) {
        Long l = (Long) this.f3178a.a(g3.f2546r7);
        if (l.longValue() <= 0) {
            return;
        }
        AppLovinSdkUtils.runOnUiThreadDelayed(new v(this, t2Var, l, maxAdListener, 2), l.longValue());
    }

    public void a(t2 t2Var, Long l, MaxAdListener maxAdListener) {
        if (t2Var.u().get()) {
            return;
        }
        String str = "Ad (" + t2Var.k() + ") has not been displayed after " + l + "ms. Failing ad display...";
        com.applovin.impl.sdk.o.h("MediationService", str);
        a(t2Var, new MaxErrorImpl(-1, str), maxAdListener);
        this.f3178a.I().b(t2Var);
    }

    public void a(q2 q2Var, MaxError maxError, MaxAdListener maxAdListener) {
        this.f3178a.l().a(q2Var, g.c.SHOW_ERROR);
        this.f3178a.u().b(q2Var, "DID_FAIL_DISPLAY");
        this.f3178a.p().maybeSendAdEvent(q2Var, "DID_FAIL_DISPLAY");
        a(maxError, q2Var, true);
        if (q2Var.u().compareAndSet(false, true)) {
            l2.a(maxAdListener, q2Var, maxError);
        }
    }

    private void a(MaxError maxError, q2 q2Var) {
        HashMap hashMap = new HashMap(3);
        long G = q2Var.G();
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(G));
        if (q2Var.getFormat().isFullscreenAd()) {
            n.a b10 = this.f3178a.I().b(q2Var.getAdUnitId());
            hashMap.put("{SHOW_ATTEMPT_COUNT}", String.valueOf(b10.a()));
            hashMap.put("{SHOW_ATTEMPT_TIMESTAMP_MS}", String.valueOf(b10.b()));
        }
        a("mlerr", hashMap, maxError, q2Var);
        Map a10 = a2.a(q2Var);
        a10.putAll(a2.a(maxError));
        a10.put("duration_ms", String.valueOf(G));
        this.f3178a.P().d(y1.X, a10);
    }

    public void a(q2 q2Var) {
        this.f3178a.u().b(q2Var, "DID_HIDE");
        this.f3178a.p().maybeSendAdEvent(q2Var, "DID_HIDE");
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.f3178a.w0().e());
        if (!((Boolean) this.f3178a.a(l4.f3025x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mclose", hashMap, q2Var);
        this.f3178a.P().a(y1.f4686d0, q2Var);
    }

    public void a(q2 q2Var, a.InterfaceC0008a interfaceC0008a) {
        this.f3178a.u().b(q2Var, "DID_CLICKED");
        this.f3178a.u().b(q2Var, "DID_CLICK");
        this.f3178a.p().maybeSendAdEvent(q2Var, "DID_CLICK");
        if (q2Var.M().endsWith(CampaignEx.JSON_NATIVE_VIDEO_CLICK)) {
            this.f3178a.u().b(q2Var);
            l2.a((MaxAdRevenueListener) interfaceC0008a, (MaxAd) q2Var);
        }
        HashMap hashMap = new HashMap(1);
        String emptyIfNull = StringUtils.emptyIfNull(this.f3178a.w0().e());
        if (!((Boolean) this.f3178a.a(l4.f3025x3)).booleanValue()) {
            emptyIfNull = "";
        }
        hashMap.put("{CUID}", emptyIfNull);
        a("mclick", hashMap, q2Var);
    }

    private void a(MaxError maxError, q2 q2Var, boolean z3) {
        a("mierr", Collections.EMPTY_MAP, maxError, q2Var, z3);
        if (!z3 || q2Var == null) {
            return;
        }
        this.f3178a.P().a(y1.f4684c0, q2Var, maxError);
    }

    private void a(q4 q4Var, r4 r4Var, h hVar) {
        long b10 = q4Var.b();
        HashMap hashMap = new HashMap(3);
        hashMap.put("{LOAD_TIME_MS}", String.valueOf(b10));
        CollectionUtils.putStringIfValid("{ADAPTER_VERSION}", hVar.b(), hashMap);
        CollectionUtils.putStringIfValid("{SDK_VERSION}", hVar.i(), hashMap);
        a("serr", hashMap, q4Var.c(), r4Var);
        Map a10 = a2.a(q4Var.c());
        CollectionUtils.putStringIfValid("network_name", r4Var.c(), a10);
        CollectionUtils.putStringIfValid("adapter_class", r4Var.b(), a10);
        CollectionUtils.putStringIfValid("adapter_version", hVar.b(), a10);
        CollectionUtils.putStringIfValid("duration_ms", String.valueOf(b10), a10);
        this.f3178a.P().d(y1.R, a10);
    }

    private void a(String str, Map map, a3 a3Var) {
        a(str, map, (MaxError) null, a3Var);
    }

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

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

    private void a(String str, List list, Map map, Map map2, MaxError maxError, a3 a3Var, boolean z3) {
        this.f3178a.q0().a((w4) new p5(str, list, map, map2, maxError, a3Var, this.f3178a, z3), r5.b.OTHER);
    }
}