Driving Zone: Germany v1.22.4版本的 MD5 值为:2b6e2d8e8733a3104dcc306c5770286c

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


package com.ironsource.mediationsdk;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.appodeal.ads.modules.common.internal.Constants;
import com.ironsource.environment.ContextProvider;
import com.ironsource.environment.DeviceConfigurationsDataHolder;
import com.ironsource.environment.a;
import com.ironsource.environment.token.TokenProvider;
import com.ironsource.isadplayer.ISAdPlayer;
import com.ironsource.mediationsdk.IronSource;
import com.ironsource.mediationsdk.Q;
import com.ironsource.mediationsdk.adunit.adapter.utility.AdInfo;
import com.ironsource.mediationsdk.adunit.data.DataKeys;
import com.ironsource.mediationsdk.config.ConfigFile;
import com.ironsource.mediationsdk.events.PixelEventsManager;
import com.ironsource.mediationsdk.impressionData.ExternalImpressionDataHandler;
import com.ironsource.mediationsdk.logger.IronLog;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.ironsource.mediationsdk.logger.IronSourceLogger;
import com.ironsource.mediationsdk.logger.IronSourceLoggerManager;
import com.ironsource.mediationsdk.metadata.MetaData;
import com.ironsource.mediationsdk.metadata.MetaDataUtils;
import com.ironsource.mediationsdk.model.InterstitialPlacement;
import com.ironsource.mediationsdk.model.NetworkSettings;
import com.ironsource.mediationsdk.model.Placement;
import com.ironsource.mediationsdk.sdk.ISDemandOnlyInterstitialListener;
import com.ironsource.mediationsdk.sdk.ISDemandOnlyRewardedVideoListener;
import com.ironsource.mediationsdk.sdk.InitializationListener;
import com.ironsource.mediationsdk.sdk.LevelPlayInterstitialListener;
import com.ironsource.mediationsdk.sdk.LevelPlayRewardedVideoListener;
import com.ironsource.mediationsdk.sdk.LevelPlayRewardedVideoManualListener;
import com.ironsource.mediationsdk.sdk.RewardedVideoManualListener;
import com.ironsource.mediationsdk.server.HttpFunctions;
import com.ironsource.mediationsdk.server.ServerURL;
import com.ironsource.mediationsdk.utils.ErrorBuilder;
import com.ironsource.mediationsdk.utils.IronSourceAES;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import com.ironsource.mediationsdk.utils.IronSourceUtils;
import com.ironsource.mediationsdk.utils.PixelSettings;
import com.ironsource.mediationsdk.utils.k;
import com.ironsource.mediationsdk.utils.l;
import io.sentry.TraceContext;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;

public final class L implements com.ironsource.mediationsdk.utils.i {
    private static boolean aq;
    W A;
    T B;
    com.ironsource.mediationsdk.adunit.c.g C;
    com.ironsource.mediationsdk.adunit.c.h D;
    boolean E;
    boolean F;
    boolean G;
    boolean H;
    boolean I;
    boolean J;
    boolean K;
    int L;
    C1566w M;
    com.ironsource.mediationsdk.utils.k N;
    ExternalImpressionDataHandler O;
    private final String P;
    private final String Q;
    private AbstractAdapter R;
    private AtomicBoolean S;
    private final Object T;
    private AtomicBoolean U;
    private boolean V;
    private List<IronSource.AD_UNIT> W;
    private Set<IronSource.AD_UNIT> X;
    private Set<IronSource.AD_UNIT> Y;
    private boolean Z;

    final String f4697a;
    private final String aa;
    private boolean ab;
    private boolean ac;
    private ConcurrentHashMap<String, ISDemandOnlyBannerLayout> ad;
    private Boolean ae;
    private IronSourceBannerLayout af;
    private String ag;
    private InitializationListener ah;
    private AtomicBoolean ai;
    private boolean aj;
    private CopyOnWriteArraySet<String> ak;
    private CopyOnWriteArraySet<String> al;
    private CopyOnWriteArraySet<String> am;
    private C1568y an;
    private com.ironsource.sdk.a.e ao;
    private TokenRepository ap;
    af b;
    I c;
    S d;
    C1560p e;
    IronSourceLoggerManager f;
    com.ironsource.mediationsdk.sdk.i g;
    com.ironsource.mediationsdk.logger.b h;
    com.ironsource.mediationsdk.utils.l i;
    public String j;
    public String k;
    String l;
    public String m;
    public Map<String, String> n;
    public String o;
    public String p;
    Context q;
    Boolean r;
    IronSourceSegment s;
    int t;
    boolean u;
    boolean v;
    boolean w;
    boolean x;
    Boolean y;
    D z;

    public static class AnonymousClass1 {

        static final int[] f4698a;
        static final int[] b;

        static {
            int[] iArr = new int[k.a.a().length];
            b = iArr;
            try {
                int i = k.a.f4930a;
                iArr[0] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                int[] iArr2 = b;
                int i2 = k.a.b;
                iArr2[1] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                int[] iArr3 = b;
                int i3 = k.a.c;
                iArr3[2] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                int[] iArr4 = b;
                int i4 = k.a.d;
                iArr4[3] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            int[] iArr5 = new int[IronSource.AD_UNIT.values().length];
            f4698a = iArr5;
            try {
                iArr5[IronSource.AD_UNIT.REWARDED_VIDEO.ordinal()] = 1;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f4698a[IronSource.AD_UNIT.INTERSTITIAL.ordinal()] = 2;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                f4698a[IronSource.AD_UNIT.OFFERWALL.ordinal()] = 3;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                f4698a[IronSource.AD_UNIT.BANNER.ordinal()] = 4;
            } catch (NoSuchFieldError unused8) {
            }
        }
    }

    public interface a {
        void a(String str);
    }

    public static class b {

        static volatile L f4699a = new L(0);
    }

    private L() {
        this.f4697a = getClass().getName();
        this.P = "!SDK-VERSION-STRING!:com.ironsource:mediationsdk:\u200b7.2.4.1";
        this.Q = "Activity=";
        this.T = new Object();
        this.i = null;
        this.j = null;
        this.k = null;
        this.l = null;
        this.m = null;
        this.n = null;
        this.o = null;
        this.V = false;
        this.p = null;
        this.r = null;
        this.Z = true;
        this.aa = IronSourceConstants.KEY_SESSION_DEPTH;
        this.y = null;
        this.f = IronSourceLoggerManager.getLogger(0);
        com.ironsource.mediationsdk.logger.b bVar = new com.ironsource.mediationsdk.logger.b(null, 1);
        this.h = bVar;
        this.f.addLogger(bVar);
        this.g = new com.ironsource.mediationsdk.sdk.i();
        af afVar = new af();
        this.b = afVar;
        afVar.m = this.g;
        I i = new I();
        this.c = i;
        i.m = this.g;
        S s = new S();
        this.d = s;
        s.b = this.g;
        this.S = new AtomicBoolean();
        this.X = new HashSet();
        this.Y = new HashSet();
        this.v = false;
        this.u = false;
        this.ab = false;
        this.U = new AtomicBoolean(true);
        this.ai = new AtomicBoolean(false);
        this.t = 0;
        this.w = false;
        this.x = false;
        this.ac = false;
        this.p = UUID.randomUUID().toString();
        this.ae = Boolean.FALSE;
        this.J = false;
        this.ag = null;
        this.z = null;
        this.A = null;
        this.ah = null;
        this.B = null;
        this.E = false;
        this.F = false;
        this.H = false;
        this.K = false;
        this.ak = new CopyOnWriteArraySet<>();
        this.al = new CopyOnWriteArraySet<>();
        this.am = new CopyOnWriteArraySet<>();
        this.ad = new ConcurrentHashMap<>();
        this.M = null;
        this.an = null;
        this.N = null;
        this.e = null;
        this.L = 1;
        this.O = new ExternalImpressionDataHandler();
        this.ao = new com.ironsource.sdk.a.e();
        this.ap = new TokenRepository();
    }

    L(byte b2) {
        this();
    }

    private void A() {
        NetworkSettings a2;
        if (this.ab) {
            B();
            return;
        }
        synchronized (this.ae) {
            this.K = this.i.c.d.g.f4921a;
            IronLog.INTERNAL.verbose("mIsBnProgrammatic = " + this.K);
            IronLog.INTERNAL.verbose("mIsBnLoadBeforeInitCompleted = " + this.ae);
            b(IronSourceConstants.TROUBLESHOOTING_BN_FORK, IronSourceUtils.getMediationAdditionalData(false, this.K, 1));
            ArrayList<NetworkSettings> arrayList = new ArrayList<>();
            for (int i = 0; i < this.i.f4931a.e.size(); i++) {
                String str = this.i.f4931a.e.get(i);
                if (!TextUtils.isEmpty(str) && (a2 = this.i.b.a(str)) != null) {
                    arrayList.add(a2);
                }
            }
            if (arrayList.size() <= 0) {
                JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, this.K, 1);
                a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
                b(IronSourceConstants.TROUBLESHOOTING_BN_INIT_FAILED, mediationAdditionalData);
                a(IronSource.AD_UNIT.BANNER, false);
            } else if (this.K) {
                a(arrayList);
            } else {
                this.e = new C1560p(arrayList, this.j, IronSourceUtils.getUserIdForNetworks(), this.i.c.d.b, this.i.c.d.e, this.i.c.d.f);
                C();
            }
        }
    }

    private void B() {
        this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "Banner started in demand only mode", 0);
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.i.f4931a.e.size(); i++) {
            String str = this.i.f4931a.e.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.i.b.a(str));
            }
        }
        if (arrayList.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, false, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_BN_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.BANNER, false);
            return;
        }
        synchronized (this.am) {
            this.N = new com.ironsource.mediationsdk.utils.k(arrayList, this.i.c.d, this.j, this.k);
        }
        Iterator<String> it = this.am.iterator();
        while (it.hasNext()) {
            String next = it.next();
            this.N.a(this.ad.get(next), next);
        }
        this.ad.clear();
        this.am.clear();
    }

    private void C() {
        if (this.ae.booleanValue()) {
            this.ae = Boolean.FALSE;
            a(this.af, this.ag);
            this.af = null;
            this.ag = null;
        }
    }

    private boolean D() {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        return (lVar == null || lVar.f4931a == null || this.i.f4931a.f4861a == null || this.i.f4931a.f4861a.size() <= 0) ? false : true;
    }

    private boolean E() {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        return (lVar == null || lVar.f4931a == null || this.i.f4931a.d == null || this.i.f4931a.d.size() <= 0) ? false : true;
    }

    private boolean F() {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        return (lVar == null || lVar.c == null || this.i.c.d == null) ? false : true;
    }

    private boolean G() {
        if (F()) {
            com.ironsource.mediationsdk.utils.l lVar = this.i;
            if ((lVar == null || lVar.f4931a == null || this.i.f4931a.e == null || this.i.f4931a.e.size() <= 0) ? false : true) {
                return true;
            }
        }
        return false;
    }

    private static boolean H() {
        return ContextProvider.getInstance().getCurrentActiveActivity() != null;
    }

    private void I() {
        if (this.ah == null || !this.ai.compareAndSet(false, true)) {
            return;
        }
        IronLog.CALLBACK.verbose("onInitializationCompleted()");
        com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(IronSourceConstants.TROUBLESHOOTING_INIT_COMPLETED, IronSourceUtils.getMediationAdditionalData(false)));
        this.ah.onInitializationComplete();
    }

    private int a(com.ironsource.mediationsdk.model.p pVar) {
        return !this.aj && !this.F && pVar.l.o ? 2 : 1;
    }

    public static L a() {
        return b.f4699a;
    }

    private IronSourceError a(Q.a aVar) {
        if (!this.ac) {
            return new IronSourceError(510, "ironSource SDK was not initialized");
        }
        if (!this.ab) {
            return new IronSourceError(510, "ironSource SDK was not initialized using Demand Only mode");
        }
        if (aVar == Q.a.INIT_FAILED) {
            return new IronSourceError(510, "ironSource initialization failed");
        }
        if (aVar == Q.a.INIT_IN_PROGRESS && Q.a().c()) {
            return new IronSourceError(510, "ironSource initialization in progress");
        }
        return null;
    }

    private com.ironsource.mediationsdk.utils.l a(Context context, String str) {
        if (IronSourceUtils.isInitResponseCached(context)) {
            String cachedValueByKeyOfCachedInitResponse = IronSourceUtils.getCachedValueByKeyOfCachedInitResponse(context, Constants.APP_KEY);
            String cachedValueByKeyOfCachedInitResponse2 = IronSourceUtils.getCachedValueByKeyOfCachedInitResponse(context, DataKeys.USER_ID);
            String cachedValueByKeyOfCachedInitResponse3 = IronSourceUtils.getCachedValueByKeyOfCachedInitResponse(context, "response");
            String str2 = this.j;
            if (str2 != null && cachedValueByKeyOfCachedInitResponse.equals(str2) && cachedValueByKeyOfCachedInitResponse2.equals(str)) {
                com.ironsource.mediationsdk.utils.l lVar = new com.ironsource.mediationsdk.utils.l(context, cachedValueByKeyOfCachedInitResponse, cachedValueByKeyOfCachedInitResponse2, cachedValueByKeyOfCachedInitResponse3);
                lVar.e = l.a.b;
                return lVar;
            }
        }
        return null;
    }

    public static String a(Context context) {
        String[] C = com.ironsource.environment.h.C(context);
        return (C == null || C.length != 2) ? "" : C[0];
    }

    private static String a(String str, int i) {
        if (i == 0) {
            return null;
        }
        int i2 = AnonymousClass1.b[i - 1];
        if (i2 != 1 && i2 != 2 && i2 != 3) {
            return null;
        }
        return "placement " + str + " is capped";
    }

    public static void a(int i, JSONObject jSONObject) {
        com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(i, jSONObject));
    }

    private void a(IronSource.AD_UNIT ad_unit) {
        String str = ad_unit + " ad unit has already been initialized";
        this.f.log(IronSourceLogger.IronSourceTag.API, str, 3);
        IronSourceUtils.sendAutomationLog(str);
    }

    private void a(IronSource.AD_UNIT ad_unit, boolean z) {
        int i = AnonymousClass1.f4698a[ad_unit.ordinal()];
        if (i == 1) {
            if (this.u) {
                Iterator<String> it = this.al.iterator();
                while (it.hasNext()) {
                    ad.a().a(it.next(), ErrorBuilder.buildInitFailedError("initISDemandOnly() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
                }
                this.al.clear();
                return;
            }
            if (this.F) {
                if (this.G) {
                    this.G = false;
                    C1564u.a().a(IronSource.AD_UNIT.REWARDED_VIDEO, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
                    return;
                }
                return;
            }
            if (z || d() || this.Y.contains(ad_unit)) {
                ae.a().a(false, (AdInfo) null);
                return;
            }
            return;
        }
        if (i == 2) {
            if (!this.v) {
                if (this.J) {
                    this.J = false;
                    C1564u.a().a(IronSource.AD_UNIT.INTERSTITIAL, ErrorBuilder.buildInitFailedError("init() had failed", "Interstitial"));
                    return;
                }
                return;
            }
            Iterator<String> it2 = this.ak.iterator();
            while (it2.hasNext()) {
                E.a().a(it2.next(), ErrorBuilder.buildInitFailedError("initISDemandOnly() had failed", "Interstitial"));
            }
            this.ak.clear();
            return;
        }
        if (i == 3) {
            if (z || k() || this.Y.contains(ad_unit)) {
                this.g.onOfferwallAvailable(false);
                return;
            }
            return;
        }
        if (i != 4) {
            return;
        }
        if (this.ab) {
            Iterator<String> it3 = this.am.iterator();
            while (it3.hasNext()) {
                C1557m.a().a(it3.next(), ErrorBuilder.buildInitFailedError("initISDemandOnly() had failed", "Banner"));
            }
            this.am.clear();
            return;
        }
        synchronized (this.ae) {
            if (this.ae.booleanValue()) {
                this.ae = Boolean.FALSE;
                C1559o.a().a(this.af, new IronSourceError(602, "Init had failed"), false);
                this.af = null;
                this.ag = null;
            }
        }
    }

    public static void a(ISDemandOnlyInterstitialListener iSDemandOnlyInterstitialListener) {
        E.a().f4661a = iSDemandOnlyInterstitialListener;
    }

    public static void a(ISDemandOnlyRewardedVideoListener iSDemandOnlyRewardedVideoListener) {
        ad.a().f4753a = iSDemandOnlyRewardedVideoListener;
    }

    public static void a(LevelPlayInterstitialListener levelPlayInterstitialListener) {
        IronLog ironLog = IronLog.API;
        if (levelPlayInterstitialListener == null) {
            ironLog.info("ISListener is null");
        } else {
            ironLog.info();
        }
        F.a().a(levelPlayInterstitialListener);
    }

    public static void a(LevelPlayRewardedVideoListener levelPlayRewardedVideoListener) {
        IronLog ironLog = IronLog.API;
        if (levelPlayRewardedVideoListener == null) {
            ironLog.info("RVListener is null");
        } else {
            ironLog.info();
        }
        ae.a().b = levelPlayRewardedVideoListener;
    }

    public static void a(String str, com.ironsource.d.b bVar) {
        if (str != null) {
            try {
                if (str.length() > 64) {
                    bVar.a(ErrorBuilder.buildInvalidKeyValueError(TraceContext.TraceContextUser.JsonKeys.SEGMENT, IronSourceConstants.SUPERSONIC_CONFIG_NAME, "segment value should not exceed 64 characters."));
                }
            } catch (Exception unused) {
                bVar.a(ErrorBuilder.buildInvalidKeyValueError(TraceContext.TraceContextUser.JsonKeys.SEGMENT, IronSourceConstants.SUPERSONIC_CONFIG_NAME, "segment value should not exceed 64 characters."));
            }
        }
    }

    public static void a(String str, JSONObject jSONObject) {
        String str2 = "networkKey = " + str;
        if (jSONObject != null) {
            str2 = str2 + " networkData = " + jSONObject;
        }
        IronLog.API.verbose(str2);
        C1553d.a().a(str, jSONObject);
    }

    private void a(ArrayList<NetworkSettings> arrayList) {
        this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "Banner started in programmatic mode", 0);
        this.B = new T(arrayList, new com.ironsource.mediationsdk.utilities.b(this.j, IronSourceUtils.getUserIdForNetworks(), this.i.c.d), com.ironsource.d.a.a().b(), this.s);
        C();
    }

    public static void a(JSONObject jSONObject, Object[][] objArr) {
        for (int i = 0; i <= 0; i++) {
            try {
                Object[] objArr2 = objArr[0];
                jSONObject.put(objArr2[0].toString(), objArr2[1]);
            } catch (Exception e) {
                IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.INTERNAL, "IronSourceObject addToDictionary: " + Log.getStackTraceString(e), 3);
                return;
            }
        }
    }

    public static void a(boolean z) {
        IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.API, "setAdaptersDebug : " + z, 1);
        C1553d.a().b(z);
    }

    private synchronized void a(boolean z, IronSource.AD_UNIT... ad_unitArr) {
        String str;
        String str2;
        int i = 0;
        for (IronSource.AD_UNIT ad_unit : ad_unitArr) {
            if (ad_unit.equals(IronSource.AD_UNIT.INTERSTITIAL)) {
                this.x = true;
            } else if (ad_unit.equals(IronSource.AD_UNIT.BANNER)) {
                this.ac = true;
            } else if (ad_unit.equals(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                this.w = true;
            }
        }
        if (Q.a().b() == Q.a.INIT_FAILED) {
            try {
                if (this.g != null) {
                    int length = ad_unitArr.length;
                    while (i < length) {
                        IronSource.AD_UNIT ad_unit2 = ad_unitArr[i];
                        if (!this.X.contains(ad_unit2)) {
                            a(ad_unit2, true);
                        }
                        i++;
                    }
                }
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
        }
        if (!this.V) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(z);
            int length2 = ad_unitArr.length;
            boolean z2 = false;
            while (i < length2) {
                IronSource.AD_UNIT ad_unit3 = ad_unitArr[i];
                if (this.X.contains(ad_unit3)) {
                    this.f.log(IronSourceLogger.IronSourceTag.API, ad_unit3 + " ad unit has started initializing.", 3);
                } else {
                    this.X.add(ad_unit3);
                    this.Y.add(ad_unit3);
                    try {
                        mediationAdditionalData.put(ad_unit3.toString(), true);
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                    z2 = true;
                }
                i++;
            }
            if (z2) {
                try {
                    StringBuilder sb = new StringBuilder();
                    String str3 = ",androidx=" + IronSourceUtils.isAndroidXAvailable();
                    String str4 = ",Activity=" + H();
                    if (a.AnonymousClass1.d()) {
                        sb.append(IronSourceConstants.IS_APP_LANGUAGE_KOTLIN);
                        str2 = a.AnonymousClass1.c();
                    } else {
                        str2 = IronSourceConstants.IS_APP_LANGUAGE_JAVA;
                    }
                    sb.append(str2);
                    sb.append(str3);
                    if (n()) {
                        sb.append(str4);
                    }
                    mediationAdditionalData.put(IronSourceConstants.EVENTS_EXT1, sb.toString());
                    int i2 = this.t + 1;
                    this.t = i2;
                    mediationAdditionalData.put(IronSourceConstants.KEY_SESSION_DEPTH, i2);
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
                com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(14, mediationAdditionalData));
            }
            return;
        }
        Q.a().b(z);
        if (this.W == null) {
            return;
        }
        JSONObject mediationAdditionalData2 = IronSourceUtils.getMediationAdditionalData(z);
        boolean z3 = false;
        for (IronSource.AD_UNIT ad_unit4 : ad_unitArr) {
            if (this.X.contains(ad_unit4)) {
                a(ad_unit4);
            } else {
                this.X.add(ad_unit4);
                this.Y.add(ad_unit4);
                try {
                    mediationAdditionalData2.put(ad_unit4.toString(), true);
                } catch (Exception e4) {
                    e4.printStackTrace();
                }
                if (this.W == null || !this.W.contains(ad_unit4)) {
                    a(ad_unit4, false);
                } else {
                    b(ad_unit4);
                }
                z3 = true;
            }
        }
        if (z3) {
            try {
                StringBuilder sb2 = new StringBuilder();
                String str5 = ",androidx=" + IronSourceUtils.isAndroidXAvailable();
                String str6 = ",Activity=" + H();
                if (a.AnonymousClass1.d()) {
                    sb2.append(IronSourceConstants.IS_APP_LANGUAGE_KOTLIN);
                    str = a.AnonymousClass1.c();
                } else {
                    str = IronSourceConstants.IS_APP_LANGUAGE_JAVA;
                }
                sb2.append(str);
                sb2.append(str5);
                if (n()) {
                    sb2.append(str6);
                }
                mediationAdditionalData2.put(IronSourceConstants.EVENTS_EXT1, sb2.toString());
                int i3 = this.t + 1;
                this.t = i3;
                mediationAdditionalData2.put(IronSourceConstants.KEY_SESSION_DEPTH, i3);
            } catch (Exception e5) {
                e5.printStackTrace();
            }
            com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(14, mediationAdditionalData2));
        }
        return;
    }

    private boolean a(ISDemandOnlyBannerLayout iSDemandOnlyBannerLayout, String str) {
        synchronized (this.am) {
            if (this.N != null) {
                return false;
            }
            if (!this.am.contains(str)) {
                this.am.add(str);
            }
            this.ad.put(str, iSDemandOnlyBannerLayout);
            return true;
        }
    }

    private static boolean a(AbstractC1551b abstractC1551b) {
        return abstractC1551b.k > 0 && abstractC1551b.l > 0;
    }

    private static boolean a(String str, int i, int i2) {
        return str != null && str.length() >= i && str.length() <= i2;
    }

    private static IronSourceError b(Activity activity, ISDemandOnlyBannerLayout iSDemandOnlyBannerLayout, String str) {
        if (activity == null && ContextProvider.getInstance().getCurrentActiveActivity() == null) {
            return new IronSourceError(IronSourceError.ERROR_DO_BN_LOAD_MISSING_ACTIVITY, "Banner was initialized and loaded without Activity");
        }
        if (iSDemandOnlyBannerLayout == null || iSDemandOnlyBannerLayout.isDestroyed()) {
            return new IronSourceError(510, iSDemandOnlyBannerLayout == null ? "Missing banner layout" : "Banner layout is destroyed");
        }
        if (TextUtils.isEmpty(str)) {
            return new IronSourceError(510, "Missing instance Id");
        }
        return null;
    }

    private com.ironsource.mediationsdk.utils.l b(Context context, String str, a aVar) {
        com.ironsource.mediationsdk.utils.l lVar = null;
        if (!IronSourceUtils.isNetworkConnected(context)) {
            return null;
        }
        try {
            String a2 = a(context);
            if (TextUtils.isEmpty(a2)) {
                a2 = com.ironsource.environment.h.x(context);
                IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.INTERNAL, "using custom identifier", 1);
            }
            String stringFromURL = HttpFunctions.getStringFromURL(ServerURL.getCPVProvidersURL(context, this.j, str, a2, this.o, this.F, this.s != null ? this.s.a() : null, n()), aVar);
            if (stringFromURL == null) {
                IronLog.INTERNAL.warning("serverResponseString is null");
                return null;
            }
            if (IronSourceUtils.getSerr() == 1) {
                IronLog.INTERNAL.verbose("encrypt");
                String optString = new JSONObject(stringFromURL).optString("response", null);
                if (TextUtils.isEmpty(optString)) {
                    IronLog.INTERNAL.warning("encryptedResponse is empty - return null");
                    return null;
                }
                stringFromURL = IronSourceAES.decode(com.ironsource.mediationsdk.utils.g.a().b(), optString);
                if (TextUtils.isEmpty(stringFromURL)) {
                    IronLog.INTERNAL.warning("encoded response invalid - return null");
                    if (!aq) {
                        aq = true;
                        JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false);
                        try {
                            mediationAdditionalData.put("status", "false");
                            mediationAdditionalData.put(IronSourceConstants.EVENTS_ERROR_CODE, 1);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(114, mediationAdditionalData));
                    }
                    return null;
                }
            }
            com.ironsource.mediationsdk.utils.l lVar2 = new com.ironsource.mediationsdk.utils.l(context, this.j, str, stringFromURL);
            try {
                lVar2.e = l.a.c;
                if (lVar2.b()) {
                    return lVar2;
                }
                IronLog.INTERNAL.warning("response invalid - return null");
                return null;
            } catch (Exception e2) {
                e = e2;
                lVar = lVar2;
                IronLog.INTERNAL.warning("exception = " + e);
                e.printStackTrace();
                return lVar;
            }
        } catch (Exception e3) {
            e = e3;
            IronLog.INTERNAL.warning("exception = " + e);
            e.printStackTrace();
            return lVar;
        }
    }

    private static void b(int i, JSONObject jSONObject) {
        com.ironsource.mediationsdk.events.d.d().b(new com.ironsource.mediationsdk.events.c(i, jSONObject));
    }

    private void b(IronSource.AD_UNIT ad_unit) {
        int i = AnonymousClass1.f4698a[ad_unit.ordinal()];
        if (i == 1) {
            r();
            return;
        }
        if (i == 2) {
            z();
        } else if (i == 3) {
            this.d.a(this.j, this.k);
        } else {
            if (i != 4) {
                return;
            }
            A();
        }
    }

    private boolean b(ISDemandOnlyBannerLayout iSDemandOnlyBannerLayout, String str) {
        if (Q.a().b() != Q.a.INIT_IN_PROGRESS) {
            return false;
        }
        synchronized (this.am) {
            if (!this.am.contains(str)) {
                this.am.add(str);
            }
            this.ad.put(str, iSDemandOnlyBannerLayout);
        }
        return true;
    }

    private void o() {
        this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "Rewarded Video started in programmatic mode", 0);
        List<NetworkSettings> t = t();
        if (t.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, this.L);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            a(IronSourceConstants.TROUBLESHOOTING_RV_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        this.z = this.i.c.f4854a.l.o ? new M(t, this.i.c.f4854a, this.j, IronSourceUtils.getUserIdForNetworks(), com.ironsource.d.a.a().b(), this.s) : new Z(t, this.i.c.f4854a, this.j, IronSourceUtils.getUserIdForNetworks(), com.ironsource.d.a.a().b(), this.s);
        Boolean bool = this.r;
        if (bool != null) {
            this.z.a(this.q, bool.booleanValue());
            if (this.r.booleanValue()) {
                this.b.a(this.q, false);
            }
        }
    }

    private Placement p(String str) {
        com.ironsource.mediationsdk.model.p pVar = this.i.c.f4854a;
        if (pVar != null) {
            Iterator<Placement> it = pVar.f4863a.iterator();
            while (it.hasNext()) {
                Placement next = it.next();
                if (next.getPlacementName().equals(str)) {
                    return next;
                }
            }
        }
        return null;
    }

    private void p() {
        this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "Rewarded Video started in demand only mode", 0);
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.i.f4931a.f4861a.size(); i++) {
            String str = this.i.f4931a.f4861a.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.i.b.a(str));
            }
        }
        if (arrayList.size() <= 0) {
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        synchronized (this.al) {
            this.an = new C1568y(arrayList, this.i.c.f4854a, this.j, this.k);
        }
        if (ContextProvider.getInstance().getCurrentActiveActivity() == null) {
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        Iterator<String> it = this.al.iterator();
        while (it.hasNext()) {
            this.an.a(it.next(), (String) null, false);
        }
        this.al.clear();
    }

    private void q() {
        NetworkSettings a2;
        NetworkSettings a3;
        NetworkSettings a4;
        com.ironsource.mediationsdk.model.p pVar = this.i.c.f4854a;
        int i = pVar.e;
        for (int i2 = 0; i2 < this.i.f4931a.f4861a.size(); i2++) {
            String str = this.i.f4931a.f4861a.get(i2);
            if (!TextUtils.isEmpty(str) && (a4 = this.i.b.a(str)) != null) {
                ag agVar = new ag(a4, i);
                if (a(agVar)) {
                    agVar.s = this.b;
                    agVar.n = i2 + 1;
                    this.b.a((AbstractC1551b) agVar);
                }
            }
        }
        if (this.b.c.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, false, this.L);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            a(IronSourceConstants.TROUBLESHOOTING_RV_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        this.b.n = pVar.b.f4850a;
        this.b.b = pVar.c;
        this.b.o = pVar.h;
        String c = this.i.c();
        if (!TextUtils.isEmpty(c) && (a3 = this.i.b.a(c)) != null) {
            ag agVar2 = new ag(a3, i);
            if (a(agVar2)) {
                agVar2.s = this.b;
                af afVar = this.b;
                afVar.h.log(IronSourceLogger.IronSourceTag.INTERNAL, agVar2.d + " is set as backfill", 0);
                afVar.d = agVar2;
            }
        }
        String d = this.i.d();
        if (!TextUtils.isEmpty(d) && (a2 = this.i.b.a(d)) != null) {
            ag agVar3 = new ag(a2, i);
            if (a(agVar3)) {
                agVar3.s = this.b;
                af afVar2 = this.b;
                afVar2.h.log(IronSourceLogger.IronSourceTag.INTERNAL, agVar3.d + " is set as premium", 0);
                afVar2.e = agVar3;
            }
        }
        af afVar3 = this.b;
        afVar3.p = new B(pVar.i, afVar3);
        this.b.a(this.j, IronSourceUtils.getUserIdForNetworks());
    }

    private void q(String str) {
        Placement placement;
        D d;
        try {
            placement = p(str);
            if (placement == null) {
                try {
                    placement = b();
                } catch (Exception e) {
                    e = e;
                    this.f.logException(IronSourceLogger.IronSourceTag.API, "showProgrammaticRewardedVideo()", e);
                    if (this.D == null) {
                    }
                    d = this.z;
                    if (d == null) {
                    }
                }
            }
            if (placement == null) {
                this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "showProgrammaticRewardedVideo error: empty default placement in response", 3);
                ae.a().a(new IronSourceError(1021, "showProgrammaticRewardedVideo error: empty default placement in response"), (AdInfo) null);
                return;
            }
        } catch (Exception e2) {
            e = e2;
            placement = null;
        }
        if (this.D == null && (this.F || this.aj)) {
            this.D.a(placement);
            return;
        }
        d = this.z;
        if (d == null) {
            d.a(placement);
            return;
        }
        this.f.log(IronSourceLogger.IronSourceTag.API, "showProgrammaticRewardedVideo - show called before init completed, managers not initiated yet", 3);
        ae.a().a(new IronSourceError(1023, "showProgrammaticRewardedVideo - show called before init completed, managers not initiated yet"), (AdInfo) null);
    }

    private Placement r(String str) {
        Placement p = p(str);
        if (p == null) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "Placement is not valid, please make sure you are using the right placements, using the default placement.", 3);
            p = b();
            if (p == null) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Default placement was not found, please make sure you are using the right placements.", 3);
                return null;
            }
        }
        String a2 = a(p.getPlacementName(), com.ironsource.mediationsdk.utils.k.b(ContextProvider.getInstance().getApplicationContext(), p));
        if (TextUtils.isEmpty(a2)) {
            return p;
        }
        this.f.log(IronSourceLogger.IronSourceTag.API, a2, 1);
        ae.a().a(ErrorBuilder.buildCappedPerPlacementError(a2), (AdInfo) null);
        return null;
    }

    private void r() {
        if (this.u) {
            p();
            return;
        }
        com.ironsource.mediationsdk.model.p pVar = this.i.c.f4854a;
        this.E = pVar.l.f4921a || this.F;
        this.aj = pVar.l.b;
        int a2 = a(pVar);
        this.L = a2;
        a(IronSourceConstants.TROUBLESHOOTING_RV_FORK, IronSourceUtils.getMediationAdditionalData(false, this.E, a2));
        if (this.F || this.aj) {
            s();
        } else if (this.E) {
            o();
        } else {
            q();
        }
    }

    private InterstitialPlacement s(String str) {
        com.ironsource.mediationsdk.model.i iVar = this.i.c.b;
        if (iVar != null) {
            Iterator<InterstitialPlacement> it = iVar.f4855a.iterator();
            while (it.hasNext()) {
                InterstitialPlacement next = it.next();
                if (next.getPlacementName().equals(str)) {
                    return next;
                }
            }
        }
        return null;
    }

    private void s() {
        IronLog.INTERNAL.verbose();
        List<NetworkSettings> t = t();
        if (t.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, this.L);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            a(IronSourceConstants.TROUBLESHOOTING_RV_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        com.ironsource.mediationsdk.adunit.c.h hVar = new com.ironsource.mediationsdk.adunit.c.h(t, this.i.c.f4854a, IronSourceUtils.getUserIdForNetworks(), this.F, com.ironsource.d.a.a().b(), this.s);
        this.D = hVar;
        Boolean bool = this.r;
        if (bool != null) {
            hVar.b(bool.booleanValue());
        }
        if (this.G && this.F) {
            this.G = false;
            this.D.d();
        }
    }

    private List<NetworkSettings> t() {
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.i.f4931a.f4861a.size(); i++) {
            String str = this.i.f4931a.f4861a.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.i.b.a(str));
            }
        }
        return arrayList;
    }

    private void t(String str) {
        Exception e;
        InterstitialPlacement interstitialPlacement;
        try {
            interstitialPlacement = s(str);
            if (interstitialPlacement == null) {
                try {
                    interstitialPlacement = g();
                } catch (Exception e2) {
                    e = e2;
                    this.f.logException(IronSourceLogger.IronSourceTag.API, "showProgrammaticInterstitial()", e);
                    if (this.I) {
                    }
                }
            }
            if (interstitialPlacement == null) {
                this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "showProgrammaticInterstitial error: empty default placement in response", 3);
                F.a().a(new IronSourceError(1020, "showProgrammaticInterstitial error: empty default placement in response"), (AdInfo) null);
                return;
            }
        } catch (Exception e3) {
            e = e3;
            interstitialPlacement = null;
        }
        if (this.I) {
            this.A.a(interstitialPlacement.getPlacementName());
        } else {
            this.C.a(new Placement(interstitialPlacement));
        }
    }

    private InterstitialPlacement u(String str) {
        InterstitialPlacement s = s(str);
        if (s == null) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "Placement is not valid, please make sure you are using the right placements, using the default placement.", 3);
            s = g();
            if (s == null) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Default placement was not found, please make sure you are using the right placements.", 3);
                return null;
            }
        }
        String a2 = a(s.getPlacementName(), w(s.getPlacementName()));
        if (TextUtils.isEmpty(a2)) {
            return s;
        }
        this.f.log(IronSourceLogger.IronSourceTag.API, a2, 1);
        this.g.e = s;
        F.a().a(ErrorBuilder.buildCappedPerPlacementError(a2), (AdInfo) null);
        return null;
    }

    private List<NetworkSettings> u() {
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.i.f4931a.d.size(); i++) {
            String str = this.i.f4931a.d.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.i.b.a(str));
            }
        }
        return arrayList;
    }

    private void v() {
        IronLog.INTERNAL.verbose();
        List<NetworkSettings> u = u();
        if (u.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_IS_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.INTERSTITIAL, false);
            return;
        }
        com.ironsource.mediationsdk.adunit.c.g gVar = new com.ironsource.mediationsdk.adunit.c.g(u, this.i.c.b, IronSourceUtils.getUserIdForNetworks(), com.ironsource.d.a.a().b(), this.s);
        this.C = gVar;
        Boolean bool = this.r;
        if (bool != null) {
            gVar.b(bool.booleanValue());
        }
        if (this.J) {
            this.J = false;
            this.C.d();
        }
    }

    private static boolean v(String str) {
        if (str == null) {
            return false;
        }
        return str.matches("^[a-zA-Z0-9]*$");
    }

    private int w(String str) {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        if (lVar == null || lVar.c == null || this.i.c.b == null) {
            return k.a.d;
        }
        InterstitialPlacement interstitialPlacement = null;
        try {
            interstitialPlacement = s(str);
            if (interstitialPlacement == null && (interstitialPlacement = g()) == null) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Default placement was not found", 3);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return interstitialPlacement == null ? k.a.d : com.ironsource.mediationsdk.utils.k.b(ContextProvider.getInstance().getApplicationContext(), interstitialPlacement);
    }

    private void w() {
        this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "Adunit: Interstitial is now initiated - programmatic mode", 0);
        List<NetworkSettings> u = u();
        if (u.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_IS_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.INTERSTITIAL, false);
            return;
        }
        W w = new W(u, this.i.c.b, this.j, IronSourceUtils.getUserIdForNetworks(), this.i.c.b.f, com.ironsource.d.a.a().b(), this.s);
        this.A = w;
        Boolean bool = this.r;
        if (bool != null) {
            w.a(bool.booleanValue());
            if (this.r.booleanValue()) {
                this.c.a(this.q, false);
            }
        }
        if (this.J) {
            this.J = false;
            this.A.e();
        }
    }

    private com.ironsource.mediationsdk.model.g x(String str) {
        com.ironsource.mediationsdk.model.g a2;
        com.ironsource.mediationsdk.model.f fVar = this.i.c.d;
        if (fVar == null) {
            return null;
        }
        return (TextUtils.isEmpty(str) || (a2 = fVar.a(str)) == null) ? fVar.a() : a2;
    }

    private void x() {
        NetworkSettings a2;
        com.ironsource.mediationsdk.model.i iVar = this.i.c.b;
        int i = iVar.e;
        this.c.n.a(IronSource.AD_UNIT.INTERSTITIAL, iVar.f);
        for (int i2 = 0; i2 < this.i.f4931a.d.size(); i2++) {
            String str = this.i.f4931a.d.get(i2);
            if (!TextUtils.isEmpty(str) && (a2 = this.i.b.a(str)) != null) {
                J j = new J(a2, i);
                if (a(j)) {
                    j.s = this.c;
                    j.n = i2 + 1;
                    this.c.a((AbstractC1551b) j);
                }
            }
        }
        if (this.c.c.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, false, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_IS_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.INTERSTITIAL, false);
            return;
        }
        this.c.b = iVar.c;
        this.c.a(this.j, IronSourceUtils.getUserIdForNetworks());
        if (this.J) {
            this.J = false;
            this.c.c();
        }
    }

    private void y() {
        this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "Interstitial started in demand only mode", 0);
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.i.f4931a.d.size(); i++) {
            String str = this.i.f4931a.d.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.i.b.a(str));
            }
        }
        if (arrayList.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, false, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{IronSourceConstants.EVENTS_ERROR_CODE, 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_IS_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.INTERSTITIAL, false);
            return;
        }
        synchronized (this.ak) {
            this.M = new C1566w(arrayList, this.i.c.b, this.j, this.k);
        }
        Iterator<String> it = this.ak.iterator();
        while (it.hasNext()) {
            this.M.a(it.next(), (String) null, false);
        }
        this.ak.clear();
    }

    private void z() {
        if (this.v) {
            y();
            return;
        }
        com.ironsource.mediationsdk.model.i iVar = this.i.c.b;
        this.H = iVar.i.f4921a;
        this.I = iVar.i.b;
        b(IronSourceConstants.TROUBLESHOOTING_IS_FORK, IronSourceUtils.getMediationAdditionalData(false, this.H, 1));
        if (!this.H) {
            x();
        } else if (this.I) {
            v();
        } else {
            w();
        }
    }

    public final com.ironsource.mediationsdk.utils.l a(Context context, String str, a aVar) {
        com.ironsource.mediationsdk.events.h d;
        boolean z;
        com.ironsource.mediationsdk.events.d d2;
        boolean z2;
        synchronized (this.T) {
            if (this.i != null) {
                return new com.ironsource.mediationsdk.utils.l(this.i);
            }
            com.ironsource.mediationsdk.utils.l b2 = b(context, str, aVar);
            if (b2 == null || !b2.b()) {
                IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.INTERNAL, "Null or invalid response. Trying to get cached response", 0);
                b2 = a(context, str);
                if (b2 != null) {
                    IronSourceError buildUsingCachedConfigurationError = ErrorBuilder.buildUsingCachedConfigurationError(this.j, str);
                    this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, buildUsingCachedConfigurationError.toString() + ": " + b2.toString(), 1);
                    com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(IronSourceConstants.USING_CACHE_FOR_INIT_EVENT, IronSourceUtils.getMediationAdditionalData(false)));
                }
            }
            if (b2 != null) {
                this.i = b2;
                IronSourceUtils.saveLastResponse(context, b2.toString());
                com.ironsource.mediationsdk.utils.l lVar = this.i;
                this.h.setDebugLevel(lVar.c.e.a().f4852a);
                this.f.setLoggerDebugLevel("console", lVar.c.e.a().b);
                boolean z3 = d() ? lVar.c.f4854a.b.b : false;
                boolean z4 = i() ? lVar.c.b.b.b : false;
                boolean z5 = F() ? lVar.c.d.f4853a.b : false;
                boolean z6 = k() ? lVar.c.c.c.b : false;
                PixelSettings h = lVar.c.e.h();
                boolean f4927a = h.getF4927a();
                if (z3) {
                    com.ironsource.mediationsdk.model.c cVar = lVar.c.f4854a.b;
                    com.ironsource.mediationsdk.events.h.d().b(cVar.e, context);
                    com.ironsource.mediationsdk.events.h.d().a(cVar.d, context);
                    com.ironsource.mediationsdk.events.h.d().b(cVar.g);
                    com.ironsource.mediationsdk.events.h.d().c(cVar.h);
                    com.ironsource.mediationsdk.events.h.d().a(cVar.f);
                    com.ironsource.mediationsdk.events.h.d().a(cVar.i, context);
                    com.ironsource.mediationsdk.events.h.d().b(cVar.j, context);
                    com.ironsource.mediationsdk.events.h.d().c(cVar.k, context);
                    com.ironsource.mediationsdk.events.h.d().d(cVar.l, context);
                    com.ironsource.mediationsdk.events.h.d().a(lVar.c.e.b());
                    d = com.ironsource.mediationsdk.events.h.d();
                    z = cVar.c;
                } else if (z6) {
                    com.ironsource.mediationsdk.model.c cVar2 = lVar.c.c.c;
                    com.ironsource.mediationsdk.events.h.d().b(cVar2.e, context);
                    com.ironsource.mediationsdk.events.h.d().a(cVar2.d, context);
                    com.ironsource.mediationsdk.events.h.d().b(cVar2.g);
                    com.ironsource.mediationsdk.events.h.d().c(cVar2.h);
                    com.ironsource.mediationsdk.events.h.d().a(cVar2.f);
                    com.ironsource.mediationsdk.events.h.d().a(cVar2.i, context);
                    com.ironsource.mediationsdk.events.h.d().b(cVar2.j, context);
                    com.ironsource.mediationsdk.events.h.d().c(cVar2.k, context);
                    com.ironsource.mediationsdk.events.h.d().d(cVar2.l, context);
                    com.ironsource.mediationsdk.events.h.d().a(lVar.c.e.b());
                    d = com.ironsource.mediationsdk.events.h.d();
                    z = cVar2.c;
                } else {
                    com.ironsource.mediationsdk.events.h.d().f = false;
                    if (!z4) {
                        com.ironsource.mediationsdk.model.c cVar3 = lVar.c.b.b;
                        com.ironsource.mediationsdk.events.d.d().b(cVar3.e, context);
                        com.ironsource.mediationsdk.events.d.d().a(cVar3.d, context);
                        com.ironsource.mediationsdk.events.d.d().b(cVar3.g);
                        com.ironsource.mediationsdk.events.d.d().c(cVar3.h);
                        com.ironsource.mediationsdk.events.d.d().a(cVar3.f);
                        com.ironsource.mediationsdk.events.d.d().a(cVar3.i, context);
                        com.ironsource.mediationsdk.events.d.d().b(cVar3.j, context);
                        com.ironsource.mediationsdk.events.d.d().c(cVar3.k, context);
                        com.ironsource.mediationsdk.events.d.d().d(cVar3.l, context);
                        com.ironsource.mediationsdk.events.d.d().a(lVar.c.e.b());
                        d2 = com.ironsource.mediationsdk.events.d.d();
                        z2 = cVar3.c;
                    } else if (z5) {
                        com.ironsource.mediationsdk.model.c cVar4 = lVar.c.d.f4853a;
                        com.ironsource.mediationsdk.events.d.d().b(cVar4.e, context);
                        com.ironsource.mediationsdk.events.d.d().a(cVar4.d, context);
                        com.ironsource.mediationsdk.events.d.d().b(cVar4.g);
                        com.ironsource.mediationsdk.events.d.d().c(cVar4.h);
                        com.ironsource.mediationsdk.events.d.d().a(cVar4.f);
                        com.ironsource.mediationsdk.events.d.d().a(cVar4.i, context);
                        com.ironsource.mediationsdk.events.d.d().b(cVar4.j, context);
                        com.ironsource.mediationsdk.events.d.d().c(cVar4.k, context);
                        com.ironsource.mediationsdk.events.d.d().d(cVar4.l, context);
                        com.ironsource.mediationsdk.events.d.d().a(lVar.c.e.b());
                        d2 = com.ironsource.mediationsdk.events.d.d();
                        z2 = cVar4.c;
                    } else {
                        com.ironsource.mediationsdk.events.d.d().f = false;
                        PixelEventsManager.w.f = f4927a;
                        if (f4927a) {
                            PixelEventsManager.w.a(h.getB(), context);
                            PixelEventsManager.w.a(h.getD(), context);
                            PixelEventsManager.w.b(h.getE(), context);
                            PixelEventsManager.w.c = h.getC();
                        }
                        com.ironsource.mediationsdk.events.d.d().f4739a = true;
                        com.ironsource.mediationsdk.events.h.d().f4739a = true;
                        PixelEventsManager.w.f4739a = true;
                    }
                    d2.c = z2;
                    PixelEventsManager.w.f = f4927a;
                    if (f4927a) {
                    }
                    com.ironsource.mediationsdk.events.d.d().f4739a = true;
                    com.ironsource.mediationsdk.events.h.d().f4739a = true;
                    PixelEventsManager.w.f4739a = true;
                }
                d.c = z;
                if (!z4) {
                }
                d2.c = z2;
                PixelEventsManager.w.f = f4927a;
                if (f4927a) {
                }
                com.ironsource.mediationsdk.events.d.d().f4739a = true;
                com.ironsource.mediationsdk.events.h.d().f4739a = true;
                PixelEventsManager.w.f4739a = true;
            }
            return b2;
        }
    }

    public final synchronized void a(Activity activity, ISDemandOnlyBannerLayout iSDemandOnlyBannerLayout, String str) {
        IronSourceError b2 = b(activity, iSDemandOnlyBannerLayout, str);
        if (b2 != null) {
            this.f.log(IronSourceLogger.IronSourceTag.API, b2.getErrorMessage(), 3);
            if (iSDemandOnlyBannerLayout != null) {
                iSDemandOnlyBannerLayout.sendBannerAdLoadFailed(str, b2);
            }
            return;
        }
        IronSourceError a2 = a(Q.a().b());
        if (a2 != null) {
            this.f.log(IronSourceLogger.IronSourceTag.API, a2.getErrorMessage(), 3);
            iSDemandOnlyBannerLayout.sendBannerAdLoadFailed(str, a2);
            return;
        }
        ContextProvider.getInstance().updateActivity(activity);
        if (b(iSDemandOnlyBannerLayout, str)) {
            return;
        }
        if (a(iSDemandOnlyBannerLayout, str)) {
            return;
        }
        if (G()) {
            this.N.a(iSDemandOnlyBannerLayout, str);
        } else {
            this.f.log(IronSourceLogger.IronSourceTag.API, "No banner configurations found", 3);
            iSDemandOnlyBannerLayout.sendBannerAdLoadFailed(str, ErrorBuilder.buildInitFailedError("the server response does not contain banner data", "Banner"));
        }
    }

    public final synchronized void a(Activity activity, ISDemandOnlyBannerLayout iSDemandOnlyBannerLayout, String str, String str2) {
        IronSourceError b2 = b(activity, iSDemandOnlyBannerLayout, str);
        if (b2 == null && str2 == null) {
            b2 = new IronSourceError(510, "Missing adm");
        }
        if (b2 != null) {
            this.f.log(IronSourceLogger.IronSourceTag.API, b2.getErrorMessage(), 3);
            if (iSDemandOnlyBannerLayout != null) {
                iSDemandOnlyBannerLayout.sendBannerAdLoadFailed(str, b2);
            }
            return;
        }
        IronSourceError a2 = a(Q.a().b());
        if (a2 != null) {
            this.f.log(IronSourceLogger.IronSourceTag.API, a2.getErrorMessage(), 3);
            iSDemandOnlyBannerLayout.sendBannerAdLoadFailed(str, a2);
            return;
        }
        ContextProvider.getInstance().updateActivity(activity);
        if (b(iSDemandOnlyBannerLayout, str)) {
            return;
        }
        if (a(iSDemandOnlyBannerLayout, str)) {
            return;
        }
        if (G()) {
            this.N.a(iSDemandOnlyBannerLayout, str, str2);
        } else {
            this.f.log(IronSourceLogger.IronSourceTag.API, "No banner configurations found", 3);
            iSDemandOnlyBannerLayout.sendBannerAdLoadFailed(str, ErrorBuilder.buildInitFailedError("the server response does not contain banner data", "Banner"));
        }
    }

    public final synchronized void a(Activity activity, String str, String str2) {
        if (str2 != null) {
            b(activity, str, str2);
        } else {
            this.f.log(IronSourceLogger.IronSourceTag.API, "adm cannot be null", 3);
            ad.a().a(str, new IronSourceError(510, "adm cannot be null"));
        }
    }

    public final synchronized void a(Context context, String str, InitializationListener initializationListener, IronSource.AD_UNIT... ad_unitArr) {
        ArrayList arrayList = new ArrayList();
        if (ad_unitArr != null && ad_unitArr.length != 0) {
            for (IronSource.AD_UNIT ad_unit : ad_unitArr) {
                if (ad_unit.equals(IronSource.AD_UNIT.OFFERWALL)) {
                    this.f.log(IronSourceLogger.IronSourceTag.API, ad_unit + " ad unit cannot be initialized in demand only mode", 3);
                } else {
                    if (ad_unit.equals(IronSource.AD_UNIT.INTERSTITIAL)) {
                        if (this.x) {
                            a(ad_unit);
                        } else {
                            this.v = true;
                            if (!arrayList.contains(ad_unit)) {
                                arrayList.add(ad_unit);
                            }
                        }
                    }
                    if (ad_unit.equals(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                        if (this.w) {
                            a(ad_unit);
                        } else {
                            this.u = true;
                            if (!arrayList.contains(ad_unit)) {
                                arrayList.add(ad_unit);
                            }
                        }
                    }
                    if (ad_unit.equals(IronSource.AD_UNIT.BANNER)) {
                        if (this.ac) {
                            a(ad_unit);
                        } else {
                            this.ab = true;
                            if (!arrayList.contains(ad_unit)) {
                                arrayList.add(ad_unit);
                            }
                        }
                    }
                }
            }
            if (context != null) {
                if (context instanceof Activity) {
                    ContextProvider.getInstance().updateActivity((Activity) context);
                }
                ContextProvider.getInstance().updateAppContext(context.getApplicationContext());
            }
            if (arrayList.size() > 0) {
                a(context, str, true, null, (IronSource.AD_UNIT[]) arrayList.toArray(new IronSource.AD_UNIT[arrayList.size()]));
            }
        }
        if (this.w) {
            a(IronSource.AD_UNIT.REWARDED_VIDEO);
        } else {
            this.u = true;
            arrayList.add(IronSource.AD_UNIT.REWARDED_VIDEO);
        }
        if (this.x) {
            a(IronSource.AD_UNIT.INTERSTITIAL);
        } else {
            this.v = true;
            arrayList.add(IronSource.AD_UNIT.INTERSTITIAL);
        }
        if (this.ac) {
            a(IronSource.AD_UNIT.BANNER);
        } else {
            this.ab = true;
            arrayList.add(IronSource.AD_UNIT.BANNER);
        }
        if (context != null) {
        }
        if (arrayList.size() > 0) {
        }
    }

    public final synchronized void a(Context context, String str, boolean z, InitializationListener initializationListener, IronSource.AD_UNIT... ad_unitArr) {
        com.ironsource.d.b bVar;
        IronSourceError ironSourceError;
        Context applicationContext;
        boolean isInitResponseCached;
        com.ironsource.mediationsdk.utils.l a2;
        ConcurrentHashMap<String, List<String>> d;
        String str2;
        IronLog.INTERNAL.verbose();
        if (initializationListener != null) {
            this.ah = initializationListener;
        }
        if (this.U == null || !this.U.compareAndSet(true, false)) {
            if (ad_unitArr != null) {
                a(z, ad_unitArr);
                if (Q.a().b() == Q.a.INITIATED && !z) {
                    I();
                    return;
                }
            } else {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Multiple calls to init without ad units are not allowed", 3);
            }
            return;
        }
        if (ad_unitArr != null && ad_unitArr.length != 0) {
            for (IronSource.AD_UNIT ad_unit : ad_unitArr) {
                this.X.add(ad_unit);
                this.Y.add(ad_unit);
                if (ad_unit.equals(IronSource.AD_UNIT.INTERSTITIAL)) {
                    this.x = true;
                }
                if (ad_unit.equals(IronSource.AD_UNIT.BANNER)) {
                    this.ac = true;
                }
                if (ad_unit.equals(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                    this.w = true;
                }
            }
            IronLog.API.info("init(appKey:" + str + ")");
            if (context instanceof Activity) {
                ContextProvider.getInstance().updateActivity((Activity) context);
            }
            ContextProvider.getInstance().updateAppContext(context.getApplicationContext());
            com.ironsource.environment.h.q();
            this.ao.b(IronSourceUtils.getSDKVersion());
            this.ao.a(ISAdPlayer.a());
            this.ao.b(IronSourceUtils.isGooglePlayInstalled(context));
            bVar = new com.ironsource.d.b();
            if (str != null) {
                ironSourceError = new IronSourceError(506, "Init Fail - appKey is missing");
            } else {
                if (a(str, 5, 10)) {
                    if (!v(str)) {
                        ironSourceError = ErrorBuilder.buildInvalidCredentialsError(Constants.APP_KEY, str, "should contain only english characters and numbers");
                    }
                    if (bVar.a()) {
                        this.j = str;
                    }
                    applicationContext = ContextProvider.getInstance().getApplicationContext();
                    isInitResponseCached = IronSourceUtils.isInitResponseCached(applicationContext);
                    long firstSessionTimestamp = IronSourceUtils.getFirstSessionTimestamp(applicationContext);
                    if (!isInitResponseCached && firstSessionTimestamp == -1) {
                        long currentTimeMillis = System.currentTimeMillis();
                        IronLog.INTERNAL.verbose("get first session timestamp = " + currentTimeMillis);
                        IronSourceUtils.saveFirstSessionTimestamp(applicationContext, currentTimeMillis);
                    }
                    a2 = a(ContextProvider.getInstance().getApplicationContext(), this.k);
                    if (a2 != null) {
                        DeviceConfigurationsDataHolder deviceConfigurationsDataHolder = DeviceConfigurationsDataHolder.f4636a;
                        DeviceConfigurationsDataHolder.a(a2.c.e.f().getC());
                        DeviceConfigurationsDataHolder deviceConfigurationsDataHolder2 = DeviceConfigurationsDataHolder.f4636a;
                        DeviceConfigurationsDataHolder.c(a2.c.e.f().getD());
                    }
                    d = com.ironsource.d.a.a().d();
                    if (d.containsKey("is_deviceid_optout")) {
                        String str3 = d.get("is_deviceid_optout").get(0);
                        if (!TextUtils.isEmpty(str3)) {
                            boolean z2 = !MetaDataUtils.getMetaDataBooleanValue(str3);
                            DeviceConfigurationsDataHolder deviceConfigurationsDataHolder3 = DeviceConfigurationsDataHolder.f4636a;
                            DeviceConfigurationsDataHolder.b(z2);
                        }
                    }
                    if (this.S != null && this.S.compareAndSet(false, true)) {
                        com.ironsource.mediationsdk.events.i.a().a(new com.ironsource.mediationsdk.utils.h(context));
                        com.ironsource.mediationsdk.events.d.d().a(context, this.s);
                        com.ironsource.mediationsdk.events.h.d().a(context, this.s);
                        PixelEventsManager.w.a(context, this.s);
                    }
                    if (this.j == null) {
                        Q.a().a(Q.a.INIT_FAILED);
                        if (this.X.contains(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                            ae.a().a(false, (AdInfo) null);
                        }
                        if (this.X.contains(IronSource.AD_UNIT.OFFERWALL)) {
                            this.g.a(false, bVar.b());
                        }
                        IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.API, bVar.b().toString(), 1);
                        return;
                    }
                    this.ao.a(context);
                    this.ao.a(this.j);
                    this.ao.c(this.p);
                    this.ao.d(ConfigFile.getConfigFile().getPluginType());
                    if (this.Z) {
                        StringBuilder sb = new StringBuilder();
                        JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(z);
                        try {
                            String str4 = ",androidx=" + IronSourceUtils.isAndroidXAvailable();
                            String str5 = ",Activity=" + H();
                            if (a.AnonymousClass1.d()) {
                                sb.append(IronSourceConstants.IS_APP_LANGUAGE_KOTLIN);
                                str2 = a.AnonymousClass1.c();
                            } else {
                                str2 = IronSourceConstants.IS_APP_LANGUAGE_JAVA;
                            }
                            sb.append(str2);
                            sb.append(str4);
                            if (n()) {
                                sb.append(str5);
                            }
                            mediationAdditionalData.put(IronSourceConstants.EVENTS_EXT1, sb.toString());
                            if (ad_unitArr != null) {
                                for (IronSource.AD_UNIT ad_unit2 : ad_unitArr) {
                                    mediationAdditionalData.put(ad_unit2.toString(), true);
                                }
                            }
                            int i = this.t + 1;
                            this.t = i;
                            mediationAdditionalData.put(IronSourceConstants.KEY_SESSION_DEPTH, i);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(14, mediationAdditionalData));
                        this.Z = false;
                    }
                    if (this.X.contains(IronSource.AD_UNIT.INTERSTITIAL)) {
                        Q.a().a(this.c);
                    }
                    Q.a().a(this);
                    Q.a().a(this.O);
                    Q.a().a(context, str, this.k);
                    return;
                }
                ironSourceError = ErrorBuilder.buildInvalidCredentialsError(Constants.APP_KEY, str, "length should be between 5-10 characters");
            }
            bVar.a(ironSourceError);
            if (bVar.a()) {
            }
            applicationContext = ContextProvider.getInstance().getApplicationContext();
            isInitResponseCached = IronSourceUtils.isInitResponseCached(applicationContext);
            long firstSessionTimestamp2 = IronSourceUtils.getFirstSessionTimestamp(applicationContext);
            if (!isInitResponseCached) {
                long currentTimeMillis2 = System.currentTimeMillis();
                IronLog.INTERNAL.verbose("get first session timestamp = " + currentTimeMillis2);
                IronSourceUtils.saveFirstSessionTimestamp(applicationContext, currentTimeMillis2);
            }
            a2 = a(ContextProvider.getInstance().getApplicationContext(), this.k);
            if (a2 != null) {
            }
            d = com.ironsource.d.a.a().d();
            if (d.containsKey("is_deviceid_optout")) {
            }
            if (this.S != null) {
                com.ironsource.mediationsdk.events.i.a().a(new com.ironsource.mediationsdk.utils.h(context));
                com.ironsource.mediationsdk.events.d.d().a(context, this.s);
                com.ironsource.mediationsdk.events.h.d().a(context, this.s);
                PixelEventsManager.w.a(context, this.s);
            }
            if (this.j == null) {
            }
        }
        for (IronSource.AD_UNIT ad_unit3 : IronSource.AD_UNIT.values()) {
            this.X.add(ad_unit3);
        }
        this.w = true;
        this.x = true;
        this.ac = true;
        IronLog.API.info("init(appKey:" + str + ")");
        if (context instanceof Activity) {
        }
        ContextProvider.getInstance().updateAppContext(context.getApplicationContext());
        com.ironsource.environment.h.q();
        this.ao.b(IronSourceUtils.getSDKVersion());
        this.ao.a(ISAdPlayer.a());
        this.ao.b(IronSourceUtils.isGooglePlayInstalled(context));
        bVar = new com.ironsource.d.b();
        if (str != null) {
        }
        bVar.a(ironSourceError);
        if (bVar.a()) {
        }
        applicationContext = ContextProvider.getInstance().getApplicationContext();
        isInitResponseCached = IronSourceUtils.isInitResponseCached(applicationContext);
        long firstSessionTimestamp22 = IronSourceUtils.getFirstSessionTimestamp(applicationContext);
        if (!isInitResponseCached) {
        }
        a2 = a(ContextProvider.getInstance().getApplicationContext(), this.k);
        if (a2 != null) {
        }
        d = com.ironsource.d.a.a().d();
        if (d.containsKey("is_deviceid_optout")) {
        }
        if (this.S != null) {
        }
        if (this.j == null) {
        }
    }

    public final synchronized void a(AbstractAdapter abstractAdapter) {
        this.R = abstractAdapter;
    }

    public final void a(IronSourceBannerLayout ironSourceBannerLayout, String str) {
        IronLog.INTERNAL.verbose("placementName = " + str);
        if (this.ab) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "Banner was initialized in demand only mode. Use loadISDemandOnlyBanner instead", 3);
            C1559o.a().a(ironSourceBannerLayout, ErrorBuilder.buildInitFailedError("Banner was initialized in demand only mode. Use loadISDemandOnlyBanner instead", "Banner"), false);
            return;
        }
        if (ironSourceBannerLayout == null || ironSourceBannerLayout.isDestroyed()) {
            StringBuilder sb = new StringBuilder("loadBanner can't be called - ");
            sb.append(ironSourceBannerLayout == null ? "banner layout is null " : "banner layout is destroyed");
            String sb2 = sb.toString();
            this.f.log(IronSourceLogger.IronSourceTag.API, sb2, 3);
            C1559o.a().a(ironSourceBannerLayout, ErrorBuilder.buildLoadFailedError(sb2), false);
            return;
        }
        if (!this.ac) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "init() must be called before loadBanner()", 3);
            C1559o.a().a(ironSourceBannerLayout, ErrorBuilder.buildLoadFailedError("init() must be called before loadBanner()"), false);
            return;
        }
        if (ironSourceBannerLayout.getSize().getDescription().equals("CUSTOM") && (ironSourceBannerLayout.getSize().getWidth() <= 0 || ironSourceBannerLayout.getSize().getHeight() <= 0)) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "loadBanner: Unsupported banner size. Height and width must be bigger than 0", 3);
            C1559o.a().a(ironSourceBannerLayout, ErrorBuilder.unsupportedBannerSize(""), false);
            return;
        }
        Q.a b2 = Q.a().b();
        if (b2 == Q.a.INIT_FAILED) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
            C1559o.a().a(ironSourceBannerLayout, new IronSourceError(600, "Init() had failed"), false);
            return;
        }
        if (b2 == Q.a.INIT_IN_PROGRESS) {
            if (Q.a().c()) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
                C1559o.a().a(ironSourceBannerLayout, new IronSourceError(601, "Init had failed"), false);
                return;
            } else {
                this.af = ironSourceBannerLayout;
                this.ae = Boolean.TRUE;
                this.ag = str;
                return;
            }
        }
        if (!G()) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "No banner configurations found", 3);
            C1559o.a().a(ironSourceBannerLayout, new IronSourceError(615, "the server response does not contain banner data"), false);
            return;
        }
        synchronized (this.ae) {
            if (this.e == null && this.B == null) {
                this.af = ironSourceBannerLayout;
                this.ae = Boolean.TRUE;
                this.ag = str;
            } else if (this.K) {
                this.B.a(ironSourceBannerLayout, x(str));
            } else {
                this.e.a(ironSourceBannerLayout, x(str));
            }
        }
    }

    public final synchronized void a(LevelPlayRewardedVideoManualListener levelPlayRewardedVideoManualListener) {
        IronLog ironLog;
        String str;
        if (levelPlayRewardedVideoManualListener == null) {
            IronLog.API.info("RVListener is null");
        } else {
            IronLog.API.info();
        }
        if (!this.w) {
            if (levelPlayRewardedVideoManualListener == null) {
                this.F = false;
                ironLog = IronLog.API;
                str = "Disabling rewarded video manual mode";
            } else {
                this.F = true;
                ironLog = IronLog.API;
                str = "Enabling rewarded video manual mode";
            }
            ironLog.info(str);
        }
        ae.a().b = levelPlayRewardedVideoManualListener;
    }

    public final synchronized void a(RewardedVideoManualListener rewardedVideoManualListener) {
        IronLog ironLog;
        String str;
        if (rewardedVideoManualListener == null) {
            IronLog.API.info("RVListener is null");
        } else {
            IronLog.API.info();
        }
        if (!this.w) {
            if (rewardedVideoManualListener == null) {
                this.F = false;
                ironLog = IronLog.API;
                str = "Disabling rewarded video manual mode";
            } else {
                this.F = true;
                ironLog = IronLog.API;
                str = "Enabling rewarded video manual mode";
            }
            ironLog.info(str);
        }
        this.g.f4889a = rewardedVideoManualListener;
        ae.a().f4781a = rewardedVideoManualListener;
    }

    @Override
    public final void a(String str) {
        try {
            this.f.log(IronSourceLogger.IronSourceTag.API, "onInitFailed(reason:" + str + ")", 1);
            IronSourceUtils.sendAutomationLog("Mediation init failed");
            if (this.g != null) {
                Iterator<IronSource.AD_UNIT> it = this.X.iterator();
                while (it.hasNext()) {
                    a(it.next(), true);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void a(String str, List<String> list) {
        IronLog.API.verbose("key = " + str + ", values = " + list.toString());
        String checkMetaDataKeyValidity = MetaDataUtils.checkMetaDataKeyValidity(str);
        String checkMetaDataValueValidity = MetaDataUtils.checkMetaDataValueValidity(list);
        if (checkMetaDataKeyValidity.length() > 0) {
            IronLog.API.verbose(checkMetaDataKeyValidity);
            return;
        }
        if (checkMetaDataValueValidity.length() > 0) {
            IronLog.API.verbose(checkMetaDataValueValidity);
            return;
        }
        MetaData formatMetaData = MetaDataUtils.formatMetaData(str, list);
        String metaDataKey = formatMetaData.getMetaDataKey();
        List<String> metaDataValue = formatMetaData.getMetaDataValue();
        if (!MetaDataUtils.isMediationOnlyKey(metaDataKey)) {
            C1553d.a().a(metaDataKey, metaDataValue);
        } else if (Q.a().b() == Q.a.INITIATED && MetaDataUtils.isMediationKeysBeforeInit(metaDataKey)) {
            IronLog.API.error("setMetaData with key = " + metaDataKey + " must to be called before init");
        } else {
            com.ironsource.d.a.a().a(metaDataKey, metaDataValue);
        }
        try {
            ConcurrentHashMap<String, List<String>> concurrentHashMap = C1553d.a().c;
            concurrentHashMap.putAll(com.ironsource.d.a.a().d());
            JSONObject jSONObject = new JSONObject();
            for (Map.Entry<String, List<String>> entry : concurrentHashMap.entrySet()) {
                jSONObject.put(entry.getKey(), entry.getValue());
            }
            this.ao.a(jSONObject);
        } catch (JSONException e) {
            IronLog.INTERNAL.error("got the following error " + e.getMessage());
            e.printStackTrace();
        }
        com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(Q.a().b() == Q.a.INITIATED ? 51 : 50, IronSourceUtils.getJsonForMetaData(str, list, metaDataValue)));
    }

    public final void a(String str, boolean z) {
        IronLog.API.verbose("userId = " + str + ", isFromPublisher = " + z);
        this.k = str;
        if (z) {
            com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(52, IronSourceUtils.getJsonForUserId(false)));
        }
    }

    @Override
    public final void a(List<IronSource.AD_UNIT> list, boolean z, com.ironsource.mediationsdk.model.h hVar) {
        IronLog.INTERNAL.verbose();
        try {
            this.W = list;
            this.V = true;
            this.f.log(IronSourceLogger.IronSourceTag.API, "onInitSuccess()", 1);
            IronSourceUtils.sendAutomationLog("init success");
            if (z) {
                JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false);
                try {
                    mediationAdditionalData.put("revived", true);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(114, mediationAdditionalData));
            }
            Activity currentActiveActivity = ContextProvider.getInstance().getCurrentActiveActivity();
            if (currentActiveActivity != null) {
                String screenSizeParams = AdapterUtils.getScreenSizeParams(currentActiveActivity);
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put(IronSourceConstants.EVENTS_EXT1, screenSizeParams);
                } catch (JSONException e2) {
                    e2.printStackTrace();
                }
                com.ironsource.mediationsdk.events.d.d().b(new com.ironsource.mediationsdk.events.c(IronSourceConstants.TROUBLESHOOTING_SCREEN_SIZE, jSONObject));
            }
            com.ironsource.mediationsdk.events.d.d().c();
            com.ironsource.mediationsdk.events.h.d().c();
            C1553d a2 = C1553d.a();
            String str = this.j;
            String str2 = this.k;
            a2.f4814a = str;
            a2.b = str2;
            for (IronSource.AD_UNIT ad_unit : IronSource.AD_UNIT.values()) {
                if (this.X.contains(ad_unit)) {
                    if (list.contains(ad_unit)) {
                        b(ad_unit);
                    } else {
                        a(ad_unit, false);
                    }
                }
            }
            I();
        } catch (Exception e3) {
            e3.printStackTrace();
        }
    }

    public final synchronized AbstractAdapter b(String str) {
        try {
            if (this.R != null && this.R.getProviderName().equals(str)) {
                return this.R;
            }
        } catch (Exception e) {
            this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, "getOfferwallAdapter exception: " + e, 1);
        }
        return null;
    }

    public Placement b() {
        com.ironsource.mediationsdk.model.p pVar = this.i.c.f4854a;
        if (pVar != null) {
            return pVar.a();
        }
        return null;
    }

    public final String b(Context context) {
        String str;
        com.ironsource.mediationsdk.utils.p pVar;
        a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_CALLED, (JSONObject) null);
        if (context == null) {
            IronLog.API.error("bidding data cannot be retrieved, context required");
            return null;
        }
        Q.a b2 = Q.a().b();
        if (b2 == Q.a.NOT_INIT) {
            IronLog.API.error("bidding data cannot be retrieved, SDK not initialized");
            a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_RETURNED_NULL, (JSONObject) null);
            return null;
        }
        if (b2 == Q.a.INIT_FAILED) {
            IronLog.API.error("bidding data cannot be retrieved, SDK failed to initialize");
            a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_RETURNED_NULL, (JSONObject) null);
            return null;
        }
        try {
            com.ironsource.mediationsdk.utils.l a2 = this.i != null ? this.i : InitServerResponse.a(context);
            if (b2 == Q.a.NOT_INIT) {
                this.ao.a(context);
                this.ao.b(IronSourceUtils.getSDKVersion());
                this.ao.c(this.p);
                this.ao.d(ConfigFile.getConfigFile().getPluginType());
                this.ao.a(ISAdPlayer.a());
                this.ao.b(IronSourceUtils.isGooglePlayInstalled(context));
            }
            if (b2 != Q.a.INITIATED) {
                Q.a().a(a2);
                if (a2 != null) {
                    Q.a().a(context, a2);
                }
            }
            if (a2 == null || !a2.b()) {
                pVar = new com.ironsource.mediationsdk.utils.p();
            } else {
                pVar = a2.c.e.c();
                if (!pVar.d) {
                    pVar.b = a2.b.a(IronSourceConstants.IRONSOURCE_CONFIG_NAME);
                }
            }
            JSONObject a3 = TokenRepository.a(context, pVar);
            C1555f.a().a(a3, true);
            str = pVar.e ? IronSourceAES.compressAndEncrypt(a3.toString()) : IronSourceAES.encrypt(a3.toString());
        } catch (Throwable th) {
            a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_ENRICH_TOKEN_ERROR, (JSONObject) null);
            IronLog.API.error("got error during token creation: " + th.getMessage());
            str = null;
        }
        if (str == null) {
            a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_RETURNED_NULL, (JSONObject) null);
        }
        return str;
    }

    public final synchronized void b(Activity activity, String str, String str2) {
        this.f.log(IronSourceLogger.IronSourceTag.API, "loadISDemandOnlyRewardedVideo() instanceId=" + str, 1);
        try {
        } catch (Throwable th) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, "loadISDemandOnlyRewardedVideo", th);
            ad.a().a(str, new IronSourceError(510, th.getMessage()));
        }
        if (!this.w) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "initISDemandOnly() must be called before loadISDemandOnlyRewardedVideo()", 3);
            ad.a().a(str, new IronSourceError(508, "initISDemandOnly() must be called before loadISDemandOnlyRewardedVideo()"));
            return;
        }
        if (!this.u) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was initialized in mediation mode", 3);
            ad.a().a(str, new IronSourceError(508, "Rewarded video was initialized in mediation mode"));
            return;
        }
        boolean z = false;
        if (activity != null) {
            ContextProvider.getInstance().updateActivity(activity);
        } else if (ContextProvider.getInstance().getCurrentActiveActivity() == null) {
            if (str2 != null) {
                z = true;
            }
            a(IronSourceConstants.TROUBLESHOOTING_DO_CALLED_RV_LOAD_WITH_NO_ACTIVITY, IronSourceUtils.getMediationAdditionalData(true, z, 1));
            this.f.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was initialized and loaded without Activity", 3);
            ad.a().a(str, new IronSourceError(IronSourceError.ERROR_DO_RV_LOAD_MISSING_ACTIVITY, "Rewarded video was initialized and loaded without Activity"));
            return;
        }
        Q.a b2 = Q.a().b();
        if (b2 == Q.a.INIT_FAILED) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
            ad.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
            return;
        }
        if (b2 == Q.a.INIT_IN_PROGRESS) {
            if (Q.a().c()) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
                ad.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
                return;
            }
            synchronized (this.al) {
                this.al.add(str);
            }
            if (str2 != null) {
                a(IronSourceConstants.TROUBLESHOOTING_DO_IAB_RV_LOAD_FAILED_INIT_IN_PROGRESS, IronSourceUtils.getMediationAdditionalData(true, true, this.L));
            }
            return;
        }
        if (!e()) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "No rewarded video configurations found", 3);
            ad.a().a(str, ErrorBuilder.buildInitFailedError("the server response does not contain rewarded video data", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
            return;
        }
        synchronized (this.al) {
            if (this.an == null) {
                this.al.add(str);
                if (str2 != null) {
                    a(IronSourceConstants.TROUBLESHOOTING_DO_IAB_RV_LOAD_FAILED_INIT_IN_PROGRESS, IronSourceUtils.getMediationAdditionalData(true, true, this.L));
                }
            } else if (str2 == null) {
                this.an.a(str, (String) null, false);
            } else {
                this.an.a(str, str2, true);
            }
        }
    }

    public final void b(boolean z) {
        this.y = Boolean.valueOf(z);
        IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.API, "setConsent : " + z, 1);
        C1553d.a().a(z);
        if (this.R != null) {
            this.f.log(IronSourceLogger.IronSourceTag.ADAPTER_API, "Offerwall | setConsent(consent:" + z + ")", 1);
            this.R.setConsent(z);
        }
        int i = z ? 40 : 41;
        this.ao.a(z);
        com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(i, IronSourceUtils.getMediationAdditionalData(false)));
    }

    public final synchronized void c(Activity activity, String str, String str2) {
        if (str2 != null) {
            d(activity, str, str2);
        } else {
            this.f.log(IronSourceLogger.IronSourceTag.API, "adm cannot be null", 3);
            E.a().a(str, new IronSourceError(510, "adm cannot be null"));
        }
    }

    public final boolean c() {
        boolean z;
        boolean z2;
        try {
            if (this.u) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Rewarded Video was initialized in demand only mode. Use isISDemandOnlyRewardedVideoAvailable instead", 3);
                return false;
            }
            try {
                if (!this.F && !this.aj) {
                    if (!this.E) {
                        z2 = this.b.c();
                        JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false);
                        if (this.E) {
                        }
                        com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(z2 ? IronSourceConstants.RV_API_HAS_AVAILABILITY_TRUE : IronSourceConstants.RV_API_HAS_AVAILABILITY_FALSE, mediationAdditionalData));
                        this.f.log(IronSourceLogger.IronSourceTag.API, "isRewardedVideoAvailable():" + z2, 1);
                        return z2;
                    }
                    if (this.z != null) {
                    }
                    z2 = false;
                    JSONObject mediationAdditionalData2 = IronSourceUtils.getMediationAdditionalData(false);
                    if (this.E) {
                        a(mediationAdditionalData2, new Object[][]{new Object[]{IronSourceConstants.EVENTS_PROGRAMMATIC, Integer.valueOf(this.L)}});
                    }
                    com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(z2 ? IronSourceConstants.RV_API_HAS_AVAILABILITY_TRUE : IronSourceConstants.RV_API_HAS_AVAILABILITY_FALSE, mediationAdditionalData2));
                    this.f.log(IronSourceLogger.IronSourceTag.API, "isRewardedVideoAvailable():" + z2, 1);
                    return z2;
                }
                JSONObject mediationAdditionalData22 = IronSourceUtils.getMediationAdditionalData(false);
                if (this.E) {
                }
                com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(z2 ? IronSourceConstants.RV_API_HAS_AVAILABILITY_TRUE : IronSourceConstants.RV_API_HAS_AVAILABILITY_FALSE, mediationAdditionalData22));
                this.f.log(IronSourceLogger.IronSourceTag.API, "isRewardedVideoAvailable():" + z2, 1);
                return z2;
            } catch (Throwable th) {
                z = z2;
                th = th;
                this.f.log(IronSourceLogger.IronSourceTag.API, "isRewardedVideoAvailable():" + z, 1);
                this.f.logException(IronSourceLogger.IronSourceTag.API, "isRewardedVideoAvailable()", th);
                return false;
            }
            if (this.D != null) {
            }
            z2 = false;
        } catch (Throwable th2) {
            th = th2;
            z = false;
        }
    }

    public final boolean c(String str) {
        try {
            this.f.log(IronSourceLogger.IronSourceTag.API, this.f4697a + ":setDynamicUserId(dynamicUserId:" + str + ")", 1);
            com.ironsource.d.b bVar = new com.ironsource.d.b();
            if (!a(str, 1, 128)) {
                bVar.a(ErrorBuilder.buildInvalidKeyValueError(IronSourceConstants.EVENTS_DYNAMIC_USER_ID, IronSourceConstants.SUPERSONIC_CONFIG_NAME, "dynamicUserId is invalid, should be between 1-128 chars in length."));
            }
            if (!bVar.a()) {
                IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.API, bVar.b().toString(), 2);
                return false;
            }
            this.m = str;
            com.ironsource.mediationsdk.events.h.d().b(new com.ironsource.mediationsdk.events.c(52, IronSourceUtils.getJsonForUserId(true)));
            return true;
        } catch (Exception e) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, this.f4697a + ":setDynamicUserId(dynamicUserId:" + str + ")", e);
            return false;
        }
    }

    public final synchronized void d(Activity activity, String str, String str2) {
        this.f.log(IronSourceLogger.IronSourceTag.API, "loadISDemandOnlyInterstitial() instanceId=" + str, 1);
        try {
        } catch (Throwable th) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, "loadDemandOnlyInterstitial", th);
            E.a().a(str, new IronSourceError(510, th.getMessage()));
        }
        if (!this.x) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "initISDemandOnly() must be called before loadISDemandOnlyInterstitial()", 3);
            E.a().a(str, new IronSourceError(510, "initISDemandOnly() must be called before loadISDemandOnlyInterstitial()"));
            return;
        }
        if (!this.v) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized in mediation mode. Use loadInterstitial instead", 3);
            E.a().a(str, new IronSourceError(510, "Interstitial was initialized in mediation mode. Use loadInterstitial instead"));
            return;
        }
        boolean z = false;
        if (activity != null) {
            ContextProvider.getInstance().updateActivity(activity);
        } else if (ContextProvider.getInstance().getCurrentActiveActivity() == null) {
            if (str2 != null) {
                z = true;
            }
            b(IronSourceConstants.TROUBLESHOOTING_DO_CALLED_IS_LOAD_WITH_NO_ACTIVITY, IronSourceUtils.getMediationAdditionalData(true, z, 1));
            this.f.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized and loaded without Activity", 3);
            E.a().a(str, new IronSourceError(IronSourceError.ERROR_DO_IS_LOAD_MISSING_ACTIVITY, "Interstitial was initialized and loaded without Activity"));
            return;
        }
        Q.a b2 = Q.a().b();
        if (b2 == Q.a.INIT_FAILED) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
            E.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", "Interstitial"));
            return;
        }
        if (b2 == Q.a.INIT_IN_PROGRESS) {
            if (Q.a().c()) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
                E.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", "Interstitial"));
                return;
            }
            synchronized (this.ak) {
                this.ak.add(str);
            }
            if (str2 != null) {
                b(IronSourceConstants.TROUBLESHOOTING_DO_IAB_IS_LOAD_FAILED_INIT_IN_PROGRESS, IronSourceUtils.getMediationAdditionalData(true, true, 1));
            }
            return;
        }
        if (!j()) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "No interstitial configurations found", 3);
            E.a().a(str, ErrorBuilder.buildInitFailedError("the server response does not contain interstitial data", "Interstitial"));
            return;
        }
        synchronized (this.ak) {
            if (this.M == null) {
                this.ak.add(str);
                if (str2 != null) {
                    b(IronSourceConstants.TROUBLESHOOTING_DO_IAB_IS_LOAD_FAILED_INIT_IN_PROGRESS, IronSourceUtils.getMediationAdditionalData(true, true, 1));
                }
            } else if (str2 == null) {
                this.M.a(str, (String) null, false);
            } else {
                this.M.a(str, str2, true);
            }
        }
    }

    public final void d(String str) {
        try {
            this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, this.f4697a + ":setMediationType(mediationType:" + str + ")", 1);
            if (a(str, 1, 64) && v(str)) {
                this.o = str;
            } else {
                this.f.log(IronSourceLogger.IronSourceTag.INTERNAL, " mediationType value is invalid - should be alphanumeric and 1-64 chars in length", 1);
            }
        } catch (Exception e) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, this.f4697a + ":setMediationType(mediationType:" + str + ")", e);
        }
    }

    public boolean d() {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        return (lVar == null || lVar.c == null || this.i.c.f4854a == null) ? false : true;
    }

    public final void e(String str) {
        String str2 = "showRewardedVideo(" + str + ")";
        this.f.log(IronSourceLogger.IronSourceTag.API, str2, 1);
        try {
            if (this.u) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Rewarded Video was initialized in demand only mode. Use showISDemandOnlyRewardedVideo instead", 3);
                ae.a().a(ErrorBuilder.buildInitFailedError("Rewarded Video was initialized in demand only mode. Use showISDemandOnlyRewardedVideo instead", IronSourceConstants.REWARDED_VIDEO_AD_UNIT), (AdInfo) null);
                return;
            }
            if (!d()) {
                ae.a().a(ErrorBuilder.buildInitFailedError("showRewardedVideo can't be called before the Rewarded Video ad unit initialization completed successfully", IronSourceConstants.REWARDED_VIDEO_AD_UNIT), (AdInfo) null);
                return;
            }
            if (this.E) {
                q(str);
                return;
            }
            Placement r = r(str);
            if (r != null) {
                this.b.a(r);
                this.b.a(r.getPlacementName());
            }
        } catch (Exception e) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, str2, e);
            ae.a().a(new IronSourceError(510, e.getMessage()), (AdInfo) null);
        }
    }

    public boolean e() {
        return d() && D();
    }

    @Override
    public final void f() {
        synchronized (this.ae) {
            if (this.ae.booleanValue()) {
                this.ae = Boolean.FALSE;
                C1559o.a().a(this.af, new IronSourceError(603, "init had failed"), false);
                this.af = null;
                this.ag = null;
            }
        }
        if (this.J) {
            this.J = false;
            C1564u.a().a(IronSource.AD_UNIT.INTERSTITIAL, ErrorBuilder.buildInitFailedError("init() had failed", "Interstitial"));
        }
        if (this.G) {
            this.G = false;
            C1564u.a().a(IronSource.AD_UNIT.REWARDED_VIDEO, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
        }
        synchronized (this.ak) {
            Iterator<String> it = this.ak.iterator();
            while (it.hasNext()) {
                E.a().a(it.next(), ErrorBuilder.buildInitFailedError("init() had failed", "Interstitial"));
            }
            this.ak.clear();
        }
        synchronized (this.al) {
            Iterator<String> it2 = this.al.iterator();
            while (it2.hasNext()) {
                ad.a().a(it2.next(), ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
            }
            this.al.clear();
        }
        synchronized (this.am) {
            Iterator<String> it3 = this.am.iterator();
            while (it3.hasNext()) {
                C1557m.a().a(it3.next(), ErrorBuilder.buildInitFailedError("init() had failed", "Banner"));
            }
            this.am.clear();
            this.ad.clear();
        }
    }

    public final synchronized void f(String str) {
        this.f.log(IronSourceLogger.IronSourceTag.API, "showISDemandOnlyRewardedVideo() instanceId=" + str, 1);
        try {
        } catch (Exception e) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, "showISDemandOnlyRewardedVideo", e);
            ad.a().b(str, new IronSourceError(510, e.getMessage()));
        }
        if (!this.u) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was initialized in mediation mode. Use showRewardedVideo instead", 3);
            ad.a().b(str, new IronSourceError(508, "Rewarded video was initialized in mediation mode. Use showRewardedVideo instead"));
            return;
        }
        if (this.an == null) {
            this.f.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was not initiated", 3);
            ad.a().b(str, new IronSourceError(508, "Rewarded video was not initiated"));
            return;
        }
        C1568y c1568y = this.an;
        if (c1568y.f4944a.containsKey(str)) {
            C1569z c1569z = c1568y.f4944a.get(str);
            c1568y.a(IronSourceConstants.RV_INSTANCE_SHOW, c1569z);
            c1569z.a();
        } else {
            C1568y.a(1500, str);
            ad.a().b(str, ErrorBuilder.buildNonExistentInstanceError(IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
        }
    }

    public InterstitialPlacement g() {
        com.ironsource.mediationsdk.model.i iVar = this.i.c.b;
        if (iVar != null) {
            return iVar.a();
        }
        return null;
    }

    public final synchronized boolean g(String str) {
        boolean z;
        if (this.an != null) {
            C1568y c1568y = this.an;
            if (c1568y.f4944a.containsKey(str)) {
                C1569z c1569z = c1568y.f4944a.get(str);
                if (c1569z.b()) {
                    C1568y.a(IronSourceConstants.RV_INSTANCE_READY_TRUE, c1569z, (Object[][]) null);
                    z = true;
                    if (z) {
                        return true;
                    }
                } else {
                    C1568y.a(IronSourceConstants.RV_INSTANCE_READY_FALSE, c1569z, (Object[][]) null);
                }
            } else {
                C1568y.a(1500, str);
            }
            z = false;
            if (z) {
            }
        }
        return false;
    }

    public final void h(String str) {
        String str2 = "showInterstitial(" + str + ")";
        this.f.log(IronSourceLogger.IronSourceTag.API, str2, 1);
        try {
            if (this.v) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized in demand only mode. Use showISDemandOnlyInterstitial instead", 3);
                F.a().a(new IronSourceError(510, "Interstitial was initialized in demand only mode. Use showISDemandOnlyInterstitial instead"), (AdInfo) null);
                return;
            }
            if (!i()) {
                F.a().a(ErrorBuilder.buildInitFailedError("showInterstitial can't be called before the Interstitial ad unit initialization completed successfully", "Interstitial"), (AdInfo) null);
                return;
            }
            if (this.H) {
                t(str);
                return;
            }
            InterstitialPlacement u = u(str);
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false);
            try {
                if (u != null) {
                    str = u.getPlacementName();
                }
                mediationAdditionalData.put("placement", str);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            com.ironsource.mediationsdk.events.d.d().b(new com.ironsource.mediationsdk.events.c(2100, mediationAdditionalData));
            if (u != null) {
                this.c.a(u);
                I i = this.c;
                u.getPlacementName();
                i.d();
            }
        } catch (Exception e2) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, str2, e2);
            F.a().a(new IronSourceError(510, e2.getMessage()), (AdInfo) null);
        }
    }

    public final boolean h() {
        boolean z;
        boolean z2;
        try {
            if (this.v) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized in demand only mode. Use isISDemandOnlyInterstitialReady instead", 3);
                return false;
            }
            if (!this.H) {
                if (this.c != null) {
                }
            } else if (this.I) {
                if (this.C != null) {
                }
            } else {
                z2 = this.A != null && this.A.f();
            }
            try {
                com.ironsource.mediationsdk.events.d.d().b(new com.ironsource.mediationsdk.events.c(z2 ? IronSourceConstants.IS_CHECK_READY_TRUE : IronSourceConstants.IS_CHECK_READY_FALSE, IronSourceUtils.getMediationAdditionalData(false, this.H, 1)));
                this.f.log(IronSourceLogger.IronSourceTag.API, "isInterstitialReady():" + z2, 1);
                return z2;
            } catch (Throwable th) {
                z = z2;
                th = th;
                this.f.log(IronSourceLogger.IronSourceTag.API, "isInterstitialReady():" + z, 1);
                this.f.logException(IronSourceLogger.IronSourceTag.API, "isInterstitialReady()", th);
                return false;
            }
        } catch (Throwable th2) {
            th = th2;
            z = false;
        }
    }

    public boolean i() {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        return (lVar == null || lVar.c == null || this.i.c.b == null) ? false : true;
    }

    public final synchronized boolean i(String str) {
        boolean z;
        if (this.M != null) {
            C1566w c1566w = this.M;
            if (c1566w.f4941a.containsKey(str)) {
                C1567x c1567x = c1566w.f4941a.get(str);
                if (c1567x.b()) {
                    C1566w.a(IronSourceConstants.IS_INSTANCE_READY_TRUE, c1567x, (Object[][]) null);
                    z = true;
                    if (z) {
                        return true;
                    }
                } else {
                    C1566w.a(IronSourceConstants.IS_INSTANCE_READY_FALSE, c1567x, (Object[][]) null);
                }
            } else {
                C1566w.a(2500, str);
            }
            z = false;
            if (z) {
            }
        }
        return false;
    }

    public final void j(String str) {
        String str2 = "showOfferwall(" + str + ")";
        this.f.log(IronSourceLogger.IronSourceTag.API, str2, 1);
        try {
            if (!k()) {
                this.g.onOfferwallShowFailed(ErrorBuilder.buildInitFailedError("showOfferwall can't be called before the Offerwall ad unit initialization completed successfully", IronSourceConstants.OFFERWALL_AD_UNIT));
                return;
            }
            com.ironsource.mediationsdk.model.k a2 = this.i.c.c.a(str);
            if (a2 == null) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Placement is not valid, please make sure you are using the right placements, using the default placement.", 3);
                a2 = this.i.c.c.a();
                if (a2 == null) {
                    this.f.log(IronSourceLogger.IronSourceTag.API, "Default placement was not found, please make sure you are using the right placements.", 3);
                    return;
                }
            }
            this.d.a(a2.b);
        } catch (Exception e) {
            this.f.logException(IronSourceLogger.IronSourceTag.API, str2, e);
            this.g.onOfferwallShowFailed(ErrorBuilder.buildInitFailedError("showOfferwall can't be called before the Offerwall ad unit initialization completed successfully", IronSourceConstants.OFFERWALL_AD_UNIT));
        }
    }

    public boolean j() {
        return i() && E();
    }

    public final InterstitialPlacement k(String str) {
        try {
            InterstitialPlacement s = s(str);
            if (s == null) {
                try {
                    this.f.log(IronSourceLogger.IronSourceTag.API, "Placement is not valid, please make sure you are using the right placements, using the default placement.", 2);
                    s = g();
                } catch (Exception unused) {
                    return s;
                }
            }
            this.f.log(IronSourceLogger.IronSourceTag.API, "getPlacementInfo(placement: " + str + "):" + s, 1);
            return s;
        } catch (Exception unused2) {
            return null;
        }
    }

    public boolean k() {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        return (lVar == null || lVar.c == null || this.i.c.c == null) ? false : true;
    }

    public final Placement l(String str) {
        try {
            Placement p = p(str);
            if (p == null) {
                try {
                    this.f.log(IronSourceLogger.IronSourceTag.API, "Placement is not valid, please make sure you are using the right placements, using the default placement.", 2);
                    p = b();
                } catch (Exception unused) {
                    return p;
                }
            }
            this.f.log(IronSourceLogger.IronSourceTag.API, "getPlacementInfo(placement: " + str + "):" + p, 1);
            return p;
        } catch (Exception unused2) {
            return null;
        }
    }

    public final boolean l() {
        try {
            if (this.d != null) {
                return this.d.a();
            }
            return false;
        } catch (Exception unused) {
            return false;
        }
    }

    public final String m() {
        String str;
        String str2;
        JSONObject a2;
        a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_CALLED, (JSONObject) null);
        IronLog.API.info();
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        if (lVar == null) {
            IronLog.API.error("bidding data cannot be retrieved, SDK not initialized");
        } else {
            NetworkSettings a3 = lVar.b.a(IronSourceConstants.IRONSOURCE_CONFIG_NAME);
            if (a3 != null) {
                JSONObject jSONObject = new JSONObject();
                AbstractAdapter a4 = C1553d.a().a(a3, a3.getApplicationSettings(), true, false);
                if (a4 != null) {
                    try {
                        jSONObject = a4.getPlayerBiddingData();
                    } catch (Exception e) {
                        e = e;
                        str = null;
                        a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_ENRICH_TOKEN_ERROR, (JSONObject) null);
                        IronLog.API.error("got error during creating the token: " + e.getMessage());
                        str2 = str;
                        if (str2 == null) {
                        }
                        return str2;
                    }
                }
                com.ironsource.mediationsdk.utils.p c = this.i.c.e.c();
                if (c.d) {
                    a2 = new TokenProvider().a();
                    C1555f.a().a(a2, true);
                } else {
                    a2 = C1555f.a().a(jSONObject, c.c, c.f4937a);
                }
                IronLog.INTERNAL.verbose("bidding data: " + a2);
                if (a2 != null) {
                    IronLog.INTERNAL.verbose("raw biddingData length: " + a2.toString().length());
                    str2 = c.e ? IronSourceAES.compressAndEncrypt(a2.toString()) : IronSourceAES.encrypt(a2.toString());
                    if (str2 != null) {
                        try {
                            IronLog.INTERNAL.verbose("biddingData length: " + str2.length());
                        } catch (Exception e2) {
                            str = str2;
                            e = e2;
                            a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_ENRICH_TOKEN_ERROR, (JSONObject) null);
                            IronLog.API.error("got error during creating the token: " + e.getMessage());
                            str2 = str;
                            if (str2 == null) {
                            }
                            return str2;
                        }
                    }
                    if (str2 == null) {
                        a(IronSourceConstants.TROUBLESHOOTING_DO_GET_BIDDING_DATA_RETURNED_NULL, (JSONObject) null);
                    }
                    return str2;
                }
            }
        }
        str2 = null;
        if (str2 == null) {
        }
        return str2;
    }

    public final boolean m(String str) {
        if (this.v) {
            return false;
        }
        boolean z = w(str) != k.a.d;
        if (z) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(this.v, this.H, 1);
            try {
                mediationAdditionalData.put("placement", str);
                if (this.H) {
                    mediationAdditionalData.put(IronSourceConstants.EVENTS_PROGRAMMATIC, 1);
                }
            } catch (Exception unused) {
            }
            com.ironsource.mediationsdk.events.d.d().b(new com.ironsource.mediationsdk.events.c(IronSourceConstants.IS_CHECK_CAPPED_TRUE, mediationAdditionalData));
        }
        return z;
    }

    public final boolean n() {
        return this.u || this.v || this.ab;
    }

    public final boolean n(String str) {
        if (!F()) {
            return false;
        }
        com.ironsource.mediationsdk.model.g gVar = null;
        try {
            gVar = this.i.c.d.a(str);
            if (gVar == null && (gVar = this.i.c.d.a()) == null) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Banner default placement was not found", 3);
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (gVar == null) {
            return false;
        }
        return com.ironsource.mediationsdk.utils.k.b(ContextProvider.getInstance().getApplicationContext(), gVar.getPlacementName());
    }

    public int o(String str) {
        com.ironsource.mediationsdk.utils.l lVar = this.i;
        if (lVar == null || lVar.c == null || this.i.c.f4854a == null) {
            return k.a.d;
        }
        Placement placement = null;
        try {
            placement = p(str);
            if (placement == null && (placement = b()) == null) {
                this.f.log(IronSourceLogger.IronSourceTag.API, "Default placement was not found", 3);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return placement == null ? k.a.d : com.ironsource.mediationsdk.utils.k.b(ContextProvider.getInstance().getApplicationContext(), placement);
    }
}