Idle Tower v2.48版本的 MD5 值为:56f20496f6a85726b376356ed2ecee23

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


package com.ironsource.mediationsdk;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.ironsource.environment.ContextProvider;
import com.ironsource.environment.DeviceConfigurationsDataHolder;
import com.ironsource.environment.a;
import com.ironsource.isadplayer.ISAdPlayer;
import com.ironsource.mediationsdk.D;
import com.ironsource.mediationsdk.IronSource;
import com.ironsource.mediationsdk.adunit.adapter.utility.AdInfo;
import com.ironsource.mediationsdk.adunit.data.DataKeys;
import com.ironsource.mediationsdk.adunit.manager.NativeAdManager;
import com.ironsource.mediationsdk.config.ConfigFile;
import com.ironsource.mediationsdk.demandOnly.ISDemandOnlyBannerLayout;
import com.ironsource.mediationsdk.demandOnly.ISDemandOnlyInterstitialListener;
import com.ironsource.mediationsdk.demandOnly.ISDemandOnlyRewardedVideoListener;
import com.ironsource.mediationsdk.events.ISErrorListener;
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.BannerPlacement;
import com.ironsource.mediationsdk.model.EmptyBannerPlacement;
import com.ironsource.mediationsdk.model.InterstitialPlacement;
import com.ironsource.mediationsdk.model.NetworkSettings;
import com.ironsource.mediationsdk.model.OfferwallPlacement;
import com.ironsource.mediationsdk.model.Placement;
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.utilities.IronSourcePreconditions;
import com.ironsource.mediationsdk.utils.ApplicationGeneralSettings;
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.j;
import com.ironsource.mediationsdk.utils.k;
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.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;

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

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

    public static class AnonymousClass2 {

        static final int[] f5567a;
        public static final int[] b;
        static final int[] c;

        static {
            int[] iArr = new int[j.a.a().length];
            c = iArr;
            try {
                int i = j.a.f5555a;
                iArr[0] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                int[] iArr2 = c;
                int i2 = j.a.b;
                iArr2[1] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                int[] iArr3 = c;
                int i3 = j.a.c;
                iArr3[2] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                int[] iArr4 = c;
                int i4 = j.a.d;
                iArr4[3] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            int[] iArr5 = new int[D.a.values().length];
            b = iArr5;
            try {
                iArr5[D.a.INIT_FAILED.ordinal()] = 1;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                b[D.a.INIT_IN_PROGRESS.ordinal()] = 2;
            } catch (NoSuchFieldError unused6) {
            }
            int[] iArr6 = new int[IronSource.AD_UNIT.values().length];
            f5567a = iArr6;
            try {
                iArr6[IronSource.AD_UNIT.REWARDED_VIDEO.ordinal()] = 1;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                f5567a[IronSource.AD_UNIT.INTERSTITIAL.ordinal()] = 2;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                f5567a[IronSource.AD_UNIT.OFFERWALL.ordinal()] = 3;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                f5567a[IronSource.AD_UNIT.BANNER.ordinal()] = 4;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                f5567a[IronSource.AD_UNIT.NATIVE_AD.ordinal()] = 5;
            } catch (NoSuchFieldError unused11) {
            }
        }
    }

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

    public static class b {

        static volatile y f5568a = new y(0);
    }

    private y() {
        this.f5565a = getClass().getName();
        this.O = "!SDK-VERSION-STRING!:com.ironsource:mediationsdk:\u200b7.3.1.1";
        this.R = new Object();
        this.f = null;
        this.g = null;
        this.h = "";
        this.S = null;
        this.i = null;
        this.j = null;
        this.k = null;
        this.l = false;
        this.o = null;
        this.X = true;
        this.Y = IronSourceConstants.KEY_SESSION_DEPTH;
        this.w = null;
        this.N = false;
        this.c = IronSourceLoggerManager.getLogger(0);
        com.ironsource.mediationsdk.logger.b bVar = new com.ironsource.mediationsdk.logger.b(null, 1);
        this.e = bVar;
        this.c.addLogger(bVar);
        this.d = new com.ironsource.mediationsdk.sdk.f();
        G g = new G();
        this.b = g;
        g.b = this.d;
        this.Q = new AtomicBoolean();
        this.V = new HashSet();
        this.W = new HashSet();
        this.s = false;
        this.r = false;
        this.Z = false;
        this.T = new AtomicBoolean(true);
        this.ag = new AtomicBoolean(false);
        this.q = 0;
        this.t = false;
        this.u = false;
        this.aa = false;
        this.v = false;
        this.m = IronSourceUtils.getSessionId();
        this.ac = Boolean.FALSE;
        this.G = false;
        this.ae = null;
        this.x = null;
        this.y = null;
        this.af = null;
        this.z = null;
        this.D = false;
        this.ai = new CopyOnWriteArraySet<>();
        this.aj = new CopyOnWriteArraySet<>();
        this.ak = new CopyOnWriteArraySet<>();
        this.ab = new ConcurrentHashMap<>();
        this.J = null;
        this.al = null;
        this.K = null;
        this.I = 1;
        this.L = new ExternalImpressionDataHandler();
        this.M = new com.ironsource.mediationsdk.a.a();
        this.am = new TokenRepository();
        this.ao = new ISErrorListener() {
            @Override
            public final void onError(Throwable th) {
                IronLog.INTERNAL.error(th.getMessage());
            }
        };
    }

    y(byte b2) {
        this();
    }

    private boolean A() {
        com.ironsource.mediationsdk.utils.k kVar = this.f;
        return (kVar == null || kVar.f5556a == null || this.f.f5556a.f5469a == null || this.f.f5556a.f5469a.size() <= 0) ? false : true;
    }

    private InterstitialPlacement B() {
        com.ironsource.mediationsdk.model.h hVar = this.f.c.b;
        if (hVar != null) {
            return hVar.a();
        }
        return null;
    }

    private boolean C() {
        com.ironsource.mediationsdk.utils.k kVar = this.f;
        return (kVar == null || kVar.c == null || this.f.c.b == null) ? false : true;
    }

    private boolean D() {
        com.ironsource.mediationsdk.utils.k kVar = this.f;
        return (kVar == null || kVar.f5556a == null || this.f.f5556a.b == null || this.f.f5556a.b.size() <= 0) ? false : true;
    }

    private boolean E() {
        com.ironsource.mediationsdk.utils.k kVar = this.f;
        return (kVar == null || kVar.c == null || this.f.c.d == null) ? false : true;
    }

    private boolean F() {
        if (E()) {
            com.ironsource.mediationsdk.utils.k kVar = this.f;
            if ((kVar == null || kVar.f5556a == null || this.f.f5556a.c == null || this.f.f5556a.c.size() <= 0) ? false : true) {
                return true;
            }
        }
        return false;
    }

    private void G() {
        if (this.af == null || !this.ag.compareAndSet(false, true)) {
            return;
        }
        IronLog.CALLBACK.verbose("onInitializationCompleted()");
        com.ironsource.mediationsdk.events.i.d().b(new com.ironsource.environment.c.a(IronSourceConstants.TROUBLESHOOTING_INIT_COMPLETED, IronSourceUtils.getMediationAdditionalData(false)));
        this.af.onInitializationComplete();
    }

    private int a(com.ironsource.mediationsdk.model.q qVar) {
        return !this.ah && !this.D && qVar.k.n ? 2 : 1;
    }

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

    private static com.ironsource.mediationsdk.utils.k a(Context context, String str) {
        if (IronSourceUtils.isInitResponseCached(context)) {
            String cachedValueByKeyOfCachedInitResponse = IronSourceUtils.getCachedValueByKeyOfCachedInitResponse(context, "appKey");
            String cachedValueByKeyOfCachedInitResponse2 = IronSourceUtils.getCachedValueByKeyOfCachedInitResponse(context, DataKeys.USER_ID);
            String cachedValueByKeyOfCachedInitResponse3 = IronSourceUtils.getCachedValueByKeyOfCachedInitResponse(context, "response");
            if (cachedValueByKeyOfCachedInitResponse.equals(str)) {
                com.ironsource.mediationsdk.utils.k kVar = new com.ironsource.mediationsdk.utils.k(context, cachedValueByKeyOfCachedInitResponse, cachedValueByKeyOfCachedInitResponse2, cachedValueByKeyOfCachedInitResponse3);
                kVar.e = k.a.b;
                return kVar;
            }
        }
        return null;
    }

    public static y a() {
        return b.f5568a;
    }

    public static String a(Context context) {
        String C = com.ironsource.environment.h.C(context);
        return !TextUtils.isEmpty(C) ? C : "";
    }

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

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

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

    private void a(IronSource.AD_UNIT ad_unit, boolean z) {
        int i = AnonymousClass2.f5567a[ad_unit.ordinal()];
        if (i == 1) {
            if (this.r) {
                Iterator<String> it = this.aj.iterator();
                while (it.hasNext()) {
                    com.ironsource.mediationsdk.demandOnly.i.a().a(it.next(), ErrorBuilder.buildInitFailedError("initISDemandOnly() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
                }
                this.aj.clear();
                return;
            }
            if (this.D) {
                if (this.E) {
                    this.E = false;
                    C1392p.a().a(IronSource.AD_UNIT.REWARDED_VIDEO, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
                    return;
                }
                return;
            }
            if (z || z() || this.W.contains(ad_unit)) {
                R.a().a(false, (AdInfo) null);
                return;
            }
            return;
        }
        if (i == 2) {
            if (!this.s) {
                if (this.G) {
                    this.G = false;
                    C1392p.a().a(IronSource.AD_UNIT.INTERSTITIAL, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.INTERSTITIAL_AD_UNIT));
                    return;
                }
                return;
            }
            Iterator<String> it2 = this.ai.iterator();
            while (it2.hasNext()) {
                com.ironsource.mediationsdk.demandOnly.h.a().a(it2.next(), ErrorBuilder.buildInitFailedError("initISDemandOnly() had failed", IronSourceConstants.INTERSTITIAL_AD_UNIT));
            }
            this.ai.clear();
            return;
        }
        if (i == 3) {
            if (z || h() || this.W.contains(ad_unit)) {
                this.d.onOfferwallAvailable(false);
                return;
            }
            return;
        }
        if (i != 4) {
            return;
        }
        if (!this.Z) {
            if (this.ac.booleanValue()) {
                this.ac = Boolean.FALSE;
                C1392p.a().a(IronSource.AD_UNIT.BANNER, new IronSourceError(602, "init() had failed"));
                this.ad = null;
                this.ae = null;
                return;
            }
            return;
        }
        Iterator<String> it3 = this.ak.iterator();
        while (it3.hasNext()) {
            String next = it3.next();
            ISDemandOnlyBannerLayout iSDemandOnlyBannerLayout = this.ab.get(next);
            if (iSDemandOnlyBannerLayout != null) {
                iSDemandOnlyBannerLayout.getListener().a(next, ErrorBuilder.buildInitFailedError("initISDemandOnly() had failed", IronSourceConstants.BANNER_AD_UNIT));
            }
        }
        this.ak.clear();
    }

    public static void a(ISDemandOnlyInterstitialListener iSDemandOnlyInterstitialListener) {
        com.ironsource.mediationsdk.demandOnly.h.a().f5387a = iSDemandOnlyInterstitialListener;
    }

    public static void a(ISDemandOnlyRewardedVideoListener iSDemandOnlyRewardedVideoListener) {
        com.ironsource.mediationsdk.demandOnly.i.a().f5394a = iSDemandOnlyRewardedVideoListener;
    }

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

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

    private static void a(com.ironsource.sdk.controller.x xVar, Context context, com.ironsource.mediationsdk.utils.k kVar) {
        com.ironsource.mediationsdk.events.i.d().b(xVar.e(), context);
        com.ironsource.mediationsdk.events.i.d().a(xVar.d(), context);
        com.ironsource.mediationsdk.events.i.d().b(xVar.g());
        com.ironsource.mediationsdk.events.i.d().c(xVar.h());
        com.ironsource.mediationsdk.events.i.d().a(xVar.f());
        com.ironsource.mediationsdk.events.i.d().a(xVar.i(), context);
        com.ironsource.mediationsdk.events.i.d().b(xVar.j(), context);
        com.ironsource.mediationsdk.events.i.d().c(xVar.k(), context);
        com.ironsource.mediationsdk.events.i.d().d(xVar.l(), context);
        com.ironsource.mediationsdk.events.i.d().a(kVar.c.f.b());
        com.ironsource.mediationsdk.events.i.d().c = xVar.b();
        com.ironsource.mediationsdk.events.i.d().d = xVar.c();
    }

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

    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);
        C1384c.a().b(z);
    }

    private static void a(boolean z, boolean z2, int i, JSONObject jSONObject) {
        StringBuilder sb;
        String str;
        String str2;
        try {
            sb = new StringBuilder();
            if (a.AnonymousClass1.d()) {
                sb.append(IronSourceConstants.IS_APP_LANGUAGE_KOTLIN);
                str = a.AnonymousClass1.c();
            } else {
                str = IronSourceConstants.IS_APP_LANGUAGE_JAVA;
            }
            sb.append(str);
            sb.append(String.format(",androidx=%s", Boolean.valueOf(IronSourceUtils.isAndroidXAvailable())));
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!z2) {
            if (!z) {
                sb.append(",");
                str2 = IronSourceConstants.EVENTS_INIT_CONTEXT_FLOW;
            }
            sb.append(String.format(",cachedUserAgent=%s", Boolean.valueOf(com.ironsource.environment.h.f5216a)));
            jSONObject.put(IronSourceConstants.EVENTS_EXT1, sb.toString());
            jSONObject.put(IronSourceConstants.KEY_SESSION_DEPTH, i);
            com.ironsource.mediationsdk.events.i.d().b(new com.ironsource.environment.c.a(14, jSONObject));
        }
        Object[] objArr = new Object[1];
        objArr[0] = Boolean.valueOf(ContextProvider.getInstance().getCurrentActiveActivity() != null);
        str2 = String.format(",Activity=%s", objArr);
        sb.append(str2);
        sb.append(String.format(",cachedUserAgent=%s", Boolean.valueOf(com.ironsource.environment.h.f5216a)));
        jSONObject.put(IronSourceConstants.EVENTS_EXT1, sb.toString());
        jSONObject.put(IronSourceConstants.KEY_SESSION_DEPTH, i);
        com.ironsource.mediationsdk.events.i.d().b(new com.ironsource.environment.c.a(14, jSONObject));
    }

    private synchronized void a(boolean z, boolean z2, IronSource.AD_UNIT... ad_unitArr) {
        int i = 0;
        for (IronSource.AD_UNIT ad_unit : ad_unitArr) {
            if (ad_unit.equals(IronSource.AD_UNIT.INTERSTITIAL)) {
                this.u = true;
            } else if (ad_unit.equals(IronSource.AD_UNIT.BANNER)) {
                this.aa = true;
            } else if (ad_unit.equals(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                this.t = true;
            } else if (ad_unit.equals(IronSource.AD_UNIT.NATIVE_AD)) {
                this.v = true;
            }
        }
        if (D.a().b() == D.a.INIT_FAILED) {
            try {
                if (this.d != null) {
                    int length = ad_unitArr.length;
                    while (i < length) {
                        IronSource.AD_UNIT ad_unit2 = ad_unitArr[i];
                        if (!this.V.contains(ad_unit2)) {
                            a(ad_unit2, true);
                        }
                        i++;
                    }
                }
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
        }
        if (!this.l) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(z2);
            int length2 = ad_unitArr.length;
            boolean z3 = false;
            while (i < length2) {
                IronSource.AD_UNIT ad_unit3 = ad_unitArr[i];
                if (this.V.contains(ad_unit3)) {
                    this.c.log(IronSourceLogger.IronSourceTag.API, ad_unit3 + " ad unit has started initializing.", 3);
                } else {
                    this.V.add(ad_unit3);
                    this.W.add(ad_unit3);
                    try {
                        mediationAdditionalData.put(ad_unit3.toString(), true);
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                    z3 = true;
                }
                i++;
            }
            if (z3) {
                int i2 = this.q + 1;
                this.q = i2;
                a(z, z2, i2, mediationAdditionalData);
            }
            return;
        }
        D.a().b(z2);
        if (this.U == null) {
            return;
        }
        JSONObject mediationAdditionalData2 = IronSourceUtils.getMediationAdditionalData(z2);
        boolean z4 = false;
        for (IronSource.AD_UNIT ad_unit4 : ad_unitArr) {
            if (this.V.contains(ad_unit4)) {
                a(ad_unit4);
            } else {
                this.V.add(ad_unit4);
                this.W.add(ad_unit4);
                try {
                    mediationAdditionalData2.put(ad_unit4.toString(), true);
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
                if (this.U == null || !this.U.contains(ad_unit4)) {
                    a(ad_unit4, false);
                } else {
                    b(ad_unit4);
                }
                z4 = true;
            }
        }
        if (z4) {
            int i3 = this.q + 1;
            this.q = i3;
            a(z, z2, i3, mediationAdditionalData2);
        }
        return;
    }

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

    public static boolean a(com.ironsource.mediationsdk.utils.k kVar) {
        return kVar != null && kVar.c();
    }

    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.k b(Context context, String str, a aVar) {
        com.ironsource.mediationsdk.utils.k kVar = 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.g, str, a2, this.k, this.D, this.p != null ? this.p.a() : null, k()), 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.e.a().b(), optString);
                if (TextUtils.isEmpty(stringFromURL)) {
                    IronLog.INTERNAL.warning("encoded response invalid - return null");
                    if (!an) {
                        an = true;
                        JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false);
                        try {
                            mediationAdditionalData.put("status", "false");
                            mediationAdditionalData.put("errorCode", 1);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        com.ironsource.mediationsdk.events.i.d().b(new com.ironsource.environment.c.a(114, mediationAdditionalData));
                    }
                    return null;
                }
            }
            com.ironsource.mediationsdk.utils.k kVar2 = new com.ironsource.mediationsdk.utils.k(context, this.g, str, stringFromURL);
            try {
                kVar2.e = k.a.c;
                if (kVar2.b()) {
                    return kVar2;
                }
                IronLog.INTERNAL.warning("response invalid - return null");
                return null;
            } catch (Exception e2) {
                e = e2;
                kVar = kVar2;
                IronLog.INTERNAL.warning("exception = " + e);
                e.printStackTrace();
                return kVar;
            }
        } catch (Exception e3) {
            e = e3;
            IronLog.INTERNAL.warning("exception = " + e);
            e.printStackTrace();
            return kVar;
        }
    }

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

    private void b(IronSource.AD_UNIT ad_unit) {
        int i = AnonymousClass2.f5567a[ad_unit.ordinal()];
        if (i == 1) {
            n();
            return;
        }
        if (i == 2) {
            u();
        } else if (i == 3) {
            this.b.a(this.g, this.h);
        } else {
            if (i != 4) {
                return;
            }
            v();
        }
    }

    private static void b(com.ironsource.sdk.controller.x xVar, Context context, com.ironsource.mediationsdk.utils.k kVar) {
        com.ironsource.mediationsdk.events.e.d().b(xVar.e(), context);
        com.ironsource.mediationsdk.events.e.d().a(xVar.d(), context);
        com.ironsource.mediationsdk.events.e.d().b(xVar.g());
        com.ironsource.mediationsdk.events.e.d().c(xVar.h());
        com.ironsource.mediationsdk.events.e.d().a(xVar.f());
        com.ironsource.mediationsdk.events.e.d().a(xVar.i(), context);
        com.ironsource.mediationsdk.events.e.d().b(xVar.j(), context);
        com.ironsource.mediationsdk.events.e.d().c(xVar.k(), context);
        com.ironsource.mediationsdk.events.e.d().d(xVar.l(), context);
        com.ironsource.mediationsdk.events.e.d().a(kVar.c.f.b());
        com.ironsource.mediationsdk.events.e.d().c = xVar.b();
        com.ironsource.mediationsdk.events.e.d().d = xVar.c();
    }

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

    private static void c(Activity activity) {
        ContextProvider.getInstance().updateActivity(activity);
        IronLog.INTERNAL.verbose("activity is updated to: " + activity.hashCode());
    }

    private void c(Activity activity, String str) {
        Placement placement;
        InterfaceC1395s interfaceC1395s;
        try {
            placement = n(str);
            if (placement == null) {
                try {
                    placement = y();
                } catch (Exception e) {
                    e = e;
                    this.c.logException(IronSourceLogger.IronSourceTag.API, "showProgrammaticRewardedVideo()", e);
                    if (activity == null) {
                    }
                    if (this.B == null) {
                    }
                    interfaceC1395s = this.x;
                    if (interfaceC1395s == null) {
                    }
                }
            }
            if (placement == null) {
                this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "showProgrammaticRewardedVideo error: empty default placement in response", 3);
                R.a().a(new IronSourceError(1021, "showProgrammaticRewardedVideo error: empty default placement in response"), (AdInfo) null);
                return;
            }
        } catch (Exception e2) {
            e = e2;
            placement = null;
        }
        if (activity == null) {
            c(activity);
        } else if (ContextProvider.getInstance().getCurrentActiveActivity() == null) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "Activity must be provided in showRewardedVideo when initializing SDK with context", 3);
            R.a().a(ErrorBuilder.buildInitFailedError("Activity must be provided in showRewardedVideo when initializing SDK with context", IronSourceConstants.REWARDED_VIDEO_AD_UNIT), (AdInfo) null);
            return;
        }
        if (this.B == null && (this.D || this.ah)) {
            this.B.a(activity, placement);
            return;
        }
        interfaceC1395s = this.x;
        if (interfaceC1395s == null) {
            interfaceC1395s.a(activity, placement);
            return;
        }
        this.c.log(IronSourceLogger.IronSourceTag.API, "showProgrammaticRewardedVideo - show called before init completed, managers not initiated yet", 3);
        R.a().a(new IronSourceError(1023, "showProgrammaticRewardedVideo - show called before init completed, managers not initiated yet"), (AdInfo) null);
    }

    private void d(Activity activity, String str) {
        try {
            InterstitialPlacement o = o(str);
            if (o == null) {
                o = B();
            }
            if (o == null) {
                this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "showProgrammaticInterstitial error: empty default placement in response", 3);
                C1396t.a().a(new IronSourceError(1020, "showProgrammaticInterstitial error: empty default placement in response"), (AdInfo) null);
                return;
            }
            if (activity != null) {
                c(activity);
            } else if (ContextProvider.getInstance().getCurrentActiveActivity() == null) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "Activity must be provided in showInterstitial when initializing SDK with context", 3);
                C1396t.a().a(new IronSourceError(510, "Activity must be provided in showInterstitial when initializing SDK with context"), (AdInfo) null);
                return;
            }
            if (this.F) {
                this.A.a(activity, new Placement(o));
            } else {
                this.y.a(activity, o.getB());
            }
        } catch (Exception e) {
            this.c.logException(IronSourceLogger.IronSourceTag.API, "showProgrammaticInterstitial()", e);
        }
    }

    private void l() {
        this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "Rewarded Video started in programmatic mode", 0);
        List<NetworkSettings> a2 = a(this.f.f5556a.f5469a);
        if (a2.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, this.I);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            a(IronSourceConstants.TROUBLESHOOTING_RV_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        this.x = this.f.c.f5462a.k.n ? new z(a2, this.f.c.f5462a, this.g, IronSourceUtils.getUserIdForNetworks(), com.ironsource.mediationsdk.utilities.c.a().b(), this.p) : new N(a2, this.f.c.f5462a, this.g, IronSourceUtils.getUserIdForNetworks(), com.ironsource.mediationsdk.utilities.c.a().b(), this.p);
        Boolean bool = this.o;
        if (bool != null) {
            this.x.a(this.n, bool.booleanValue());
        }
    }

    private void m() {
        this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "Rewarded Video started in demand only mode", 0);
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.f.f5556a.f5469a.size(); i++) {
            String str = this.f.f5556a.f5469a.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.f.b.a(str));
            }
        }
        if (arrayList.size() <= 0) {
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        synchronized (this.aj) {
            this.al = new com.ironsource.mediationsdk.demandOnly.e(arrayList, this.f.c.f5462a, this.g, this.h);
        }
        if (ContextProvider.getInstance().getCurrentActiveActivity() == null) {
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        Iterator<String> it = this.aj.iterator();
        while (it.hasNext()) {
            this.al.a(it.next(), (String) null, false);
        }
        this.aj.clear();
    }

    private Placement n(String str) {
        com.ironsource.mediationsdk.model.q qVar = this.f.c.f5462a;
        if (qVar != null) {
            Iterator<Placement> it = qVar.f5471a.iterator();
            while (it.hasNext()) {
                Placement next = it.next();
                if (next.getB().equals(str)) {
                    return next;
                }
            }
        }
        return null;
    }

    private void n() {
        if (this.r) {
            m();
            return;
        }
        com.ironsource.mediationsdk.model.q qVar = this.f.c.f5462a;
        this.ah = qVar.k.f5546a;
        this.I = a(qVar);
        if (this.D || this.ah) {
            o();
        } else {
            l();
        }
    }

    private InterstitialPlacement o(String str) {
        com.ironsource.mediationsdk.model.h hVar = this.f.c.b;
        if (hVar != null) {
            Iterator<InterstitialPlacement> it = hVar.f5463a.iterator();
            while (it.hasNext()) {
                InterstitialPlacement next = it.next();
                if (next.getB().equals(str)) {
                    return next;
                }
            }
        }
        return null;
    }

    private void o() {
        IronLog.INTERNAL.verbose();
        List<NetworkSettings> a2 = a(this.f.f5556a.f5469a);
        if (a2.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, this.I);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            a(IronSourceConstants.TROUBLESHOOTING_RV_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.REWARDED_VIDEO, false);
            return;
        }
        com.ironsource.mediationsdk.adunit.manager.i iVar = new com.ironsource.mediationsdk.adunit.manager.i(a2, this.f.c.f5462a, IronSourceUtils.getUserIdForNetworks(), this.D, com.ironsource.mediationsdk.utilities.c.a(), this.p, this.f.d());
        this.B = iVar;
        Boolean bool = this.o;
        if (bool != null) {
            iVar.b(bool.booleanValue());
        }
        if (this.E && this.D) {
            this.E = false;
            this.B.i();
        }
    }

    private void p() {
        IronLog.INTERNAL.verbose();
        List<NetworkSettings> a2 = a(this.f.f5556a.b);
        if (a2.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_IS_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.INTERSTITIAL, false);
            return;
        }
        com.ironsource.mediationsdk.adunit.manager.g gVar = new com.ironsource.mediationsdk.adunit.manager.g(a2, this.f.c.b, IronSourceUtils.getUserIdForNetworks(), com.ironsource.mediationsdk.utilities.c.a(), this.p, this.f.d());
        this.A = gVar;
        Boolean bool = this.o;
        if (bool != null) {
            gVar.b(bool.booleanValue());
        }
        if (this.G) {
            this.G = false;
            this.A.i();
        }
    }

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

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

    private void q() {
        this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "Adunit: Interstitial is now initiated - programmatic mode", 0);
        List<NetworkSettings> a2 = a(this.f.f5556a.b);
        if (a2.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_IS_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.INTERSTITIAL, false);
            return;
        }
        K k = new K(a2, this.f.c.b, this.g, IronSourceUtils.getUserIdForNetworks(), this.f.c.b.f, com.ironsource.mediationsdk.utilities.c.a().b(), this.p);
        this.y = k;
        Boolean bool = this.o;
        if (bool != null) {
            k.a(bool.booleanValue());
        }
        if (this.G) {
            this.G = false;
            this.y.d();
        }
    }

    private BannerPlacement r(String str) {
        BannerPlacement a2;
        com.ironsource.mediationsdk.model.d dVar = this.f.c.d;
        return dVar == null ? new EmptyBannerPlacement() : (TextUtils.isEmpty(str) || (a2 = dVar.a(str)) == null) ? dVar.a() : a2;
    }

    private void r() {
        IronLog.INTERNAL.verbose();
        List<NetworkSettings> a2 = a(this.f.f5556a.c);
        if (a2.size() > 0) {
            this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "Banner started in programmatic mode", 0);
            this.z = new H(a2, new com.ironsource.mediationsdk.events.d(this.g, IronSourceUtils.getUserIdForNetworks(), this.f.c.d), com.ironsource.mediationsdk.utilities.c.a().b(), this.p);
            x();
        } else {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_BN_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.BANNER, false);
        }
    }

    private void s() {
        IronLog.INTERNAL.verbose();
        List<NetworkSettings> a2 = a(this.f.f5556a.c);
        if (a2.size() > 0) {
            this.C = new com.ironsource.mediationsdk.adunit.manager.c(a2, this.f.c.d, IronSourceUtils.getUserIdForNetworks(), com.ironsource.mediationsdk.utilities.c.a(), this.p, this.f.d());
            x();
        } else {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_BN_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.BANNER, false);
        }
    }

    private void t() {
        this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "Interstitial started in demand only mode", 0);
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.f.f5556a.b.size(); i++) {
            String str = this.f.f5556a.b.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.f.b.a(str));
            }
        }
        if (arrayList.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, false, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_IS_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.INTERSTITIAL, false);
            return;
        }
        synchronized (this.ai) {
            this.J = new com.ironsource.mediationsdk.demandOnly.c(arrayList, this.f.c.b, this.g, this.h);
        }
        Iterator<String> it = this.ai.iterator();
        while (it.hasNext()) {
            this.J.a(it.next(), (String) null, false);
        }
        this.ai.clear();
    }

    private void u() {
        if (this.s) {
            t();
            return;
        }
        boolean z = this.f.c.b.g.f5546a;
        this.F = z;
        if (z) {
            p();
        } else {
            q();
        }
    }

    private void v() {
        if (this.Z) {
            w();
            return;
        }
        boolean z = this.f.c.d.h.f5546a;
        this.H = z;
        if (z) {
            s();
        } else {
            r();
        }
    }

    private void w() {
        this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "Banner started in demand only mode", 0);
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < this.f.f5556a.c.size(); i++) {
            String str = this.f.f5556a.c.get(i);
            if (!TextUtils.isEmpty(str)) {
                arrayList.add(this.f.b.a(str));
            }
        }
        if (arrayList.size() <= 0) {
            JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, false, 1);
            a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
            b(IronSourceConstants.TROUBLESHOOTING_BN_INIT_FAILED, mediationAdditionalData);
            a(IronSource.AD_UNIT.BANNER, false);
            return;
        }
        synchronized (this.ak) {
            this.K = new com.ironsource.d.a(arrayList, this.f.c.d, this.g, this.h);
        }
        Iterator<String> it = this.ak.iterator();
        while (it.hasNext()) {
            String next = it.next();
            this.K.a(this.ab.get(next), next);
        }
        this.ab.clear();
        this.ak.clear();
    }

    private void x() {
        if (this.ac.booleanValue()) {
            IronLog.INTERNAL.verbose("load banner after init");
            this.ac = Boolean.FALSE;
            a(this.ad, this.ae);
            this.ad = null;
            this.ae = null;
        }
    }

    private Placement y() {
        com.ironsource.mediationsdk.model.q qVar = this.f.c.f5462a;
        if (qVar != null) {
            return qVar.a();
        }
        return null;
    }

    private boolean z() {
        com.ironsource.mediationsdk.utils.k kVar = this.f;
        return (kVar == null || kVar.c == null || this.f.c.f5462a == null) ? false : true;
    }

    public final IronSourceBannerLayout a(Activity activity, ISBannerSize iSBannerSize) {
        this.c.log(IronSourceLogger.IronSourceTag.API, "createBanner()", 1);
        if (activity == null) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "createBanner() : Activity cannot be null", 3);
            return null;
        }
        ContextProvider.getInstance().updateActivity(activity);
        return new IronSourceBannerLayout(activity, iSBannerSize);
    }

    public final com.ironsource.mediationsdk.utils.k a(Context context, String str, a aVar) {
        com.ironsource.sdk.controller.x xVar;
        com.ironsource.sdk.controller.x g;
        synchronized (this.R) {
            if (this.f != null) {
                return new com.ironsource.mediationsdk.utils.k(this.f);
            }
            com.ironsource.mediationsdk.utils.k 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, this.g);
                if (b2 != null) {
                    IronSourceError buildUsingCachedConfigurationError = ErrorBuilder.buildUsingCachedConfigurationError(this.g, str);
                    this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, buildUsingCachedConfigurationError.toString() + ": " + b2.toString(), 1);
                    com.ironsource.mediationsdk.events.i.d().b(new com.ironsource.environment.c.a(IronSourceConstants.USING_CACHE_FOR_INIT_EVENT, IronSourceUtils.getMediationAdditionalData(false)));
                }
            }
            if (b2 != null) {
                this.f = b2;
                IronSourceUtils.saveLastResponse(context, b2.toString());
                com.ironsource.mediationsdk.utils.k kVar = this.f;
                this.e.setDebugLevel(kVar.c.f.a().a());
                this.c.setLoggerDebugLevel("console", kVar.c.f.a().b());
                boolean a2 = z() ? kVar.c.f5462a.b.a() : false;
                boolean a3 = C() ? kVar.c.b.b.a() : false;
                boolean a4 = E() ? kVar.c.d.f5461a.a() : false;
                boolean a5 = j() ? kVar.c.e.getG().a() : false;
                boolean a6 = h() ? kVar.c.c.c.a() : false;
                PixelSettings h = kVar.c.f.h();
                boolean f5552a = h.getF5552a();
                if (a2) {
                    xVar = kVar.c.f5462a.b;
                } else if (a6) {
                    xVar = kVar.c.c.c;
                } else {
                    com.ironsource.mediationsdk.events.i.d().g = false;
                    if (!a3) {
                        g = kVar.c.b.b;
                    } else if (a4) {
                        g = kVar.c.d.f5461a;
                    } else if (a5) {
                        g = kVar.c.e.getG();
                    } else {
                        com.ironsource.mediationsdk.events.e.d().g = false;
                        PixelEventsManager.x.g = f5552a;
                        if (f5552a) {
                            PixelEventsManager.x.a(h.getB(), context);
                            PixelEventsManager.x.a(h.getE(), context);
                            PixelEventsManager.x.b(h.getF(), context);
                            PixelEventsManager.x.c = h.getC();
                            PixelEventsManager.x.d = h.getD();
                        }
                        com.ironsource.mediationsdk.events.e.d().f5403a = true;
                        com.ironsource.mediationsdk.events.i.d().f5403a = true;
                        PixelEventsManager.x.f5403a = true;
                    }
                    b(g, context, kVar);
                    PixelEventsManager.x.g = f5552a;
                    if (f5552a) {
                    }
                    com.ironsource.mediationsdk.events.e.d().f5403a = true;
                    com.ironsource.mediationsdk.events.i.d().f5403a = true;
                    PixelEventsManager.x.f5403a = true;
                }
                a(xVar, context, kVar);
                if (!a3) {
                }
                b(g, context, kVar);
                PixelEventsManager.x.g = f5552a;
                if (f5552a) {
                }
                com.ironsource.mediationsdk.events.e.d().f5403a = true;
                com.ironsource.mediationsdk.events.i.d().f5403a = true;
                PixelEventsManager.x.f5403a = true;
            }
            return b2;
        }
    }

    public final void a(Activity activity) {
        if (!z()) {
            R.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);
            this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "showRewardedVideo can't be called before the Rewarded Video ad unit initialization completed successfully", 3);
            return;
        }
        Placement y = y();
        if (y != null) {
            a(activity, y.getB());
            return;
        }
        this.c.log(IronSourceLogger.IronSourceTag.INTERNAL, "showRewardedVideo error: empty default placement in response", 3);
        R.a().a(new IronSourceError(1021, "showRewardedVideo error: empty default placement in response"), (AdInfo) null);
    }

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

    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.c.log(IronSourceLogger.IronSourceTag.API, b2.getErrorMessage(), 3);
            if (iSDemandOnlyBannerLayout != null) {
                iSDemandOnlyBannerLayout.getListener().a(str, b2);
            }
            return;
        }
        IronSourceError a2 = a(D.a().b());
        if (a2 != null) {
            this.c.log(IronSourceLogger.IronSourceTag.API, a2.getErrorMessage(), 3);
            iSDemandOnlyBannerLayout.getListener().a(str, a2);
            return;
        }
        ContextProvider.getInstance().updateActivity(activity);
        if (b(iSDemandOnlyBannerLayout, str)) {
            return;
        }
        if (!F()) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "No banner configurations found", 3);
            iSDemandOnlyBannerLayout.getListener().a(str, ErrorBuilder.buildInitFailedError("the server response does not contain banner data", IronSourceConstants.BANNER_AD_UNIT));
        } else {
            if (a(iSDemandOnlyBannerLayout, str)) {
                return;
            }
            this.K.a(iSDemandOnlyBannerLayout, str, str2);
        }
    }

    public final void a(Activity activity, String str) {
        String str2 = "showRewardedVideo(" + str + ")";
        this.c.log(IronSourceLogger.IronSourceTag.API, str2, 1);
        try {
            if (this.r) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "Rewarded Video was initialized in demand only mode. Use showISDemandOnlyRewardedVideo instead", 3);
                R.a().a(ErrorBuilder.buildInitFailedError("Rewarded Video was initialized in demand only mode. Use showISDemandOnlyRewardedVideo instead", IronSourceConstants.REWARDED_VIDEO_AD_UNIT), (AdInfo) null);
            } else if (z()) {
                c(activity, str);
            } else {
                R.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);
            }
        } catch (Exception e) {
            this.c.logException(IronSourceLogger.IronSourceTag.API, str2, e);
            R.a().a(new IronSourceError(510, e.getMessage()), (AdInfo) null);
        }
    }

    public final synchronized void a(Activity activity, String str, String str2) {
        if (str2 != null) {
            b(activity, str, str2);
        } else {
            this.c.log(IronSourceLogger.IronSourceTag.API, "adm cannot be null", 3);
            com.ironsource.mediationsdk.demandOnly.i.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.c.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.u) {
                            a(ad_unit);
                        } else {
                            this.s = true;
                            if (!arrayList.contains(ad_unit)) {
                                arrayList.add(ad_unit);
                            }
                        }
                    }
                    if (ad_unit.equals(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                        if (this.t) {
                            a(ad_unit);
                        } else {
                            this.r = true;
                            if (!arrayList.contains(ad_unit)) {
                                arrayList.add(ad_unit);
                            }
                        }
                    }
                    if (ad_unit.equals(IronSource.AD_UNIT.BANNER)) {
                        if (this.aa) {
                            a(ad_unit);
                        } else {
                            this.Z = true;
                            if (!arrayList.contains(ad_unit)) {
                                arrayList.add(ad_unit);
                            }
                        }
                    }
                }
            }
            if (context != null) {
                if (context instanceof Activity) {
                    c((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.t) {
            a(IronSource.AD_UNIT.REWARDED_VIDEO);
        } else {
            this.r = true;
            arrayList.add(IronSource.AD_UNIT.REWARDED_VIDEO);
        }
        if (this.u) {
            a(IronSource.AD_UNIT.INTERSTITIAL);
        } else {
            this.s = true;
            arrayList.add(IronSource.AD_UNIT.INTERSTITIAL);
        }
        if (this.aa) {
            a(IronSource.AD_UNIT.BANNER);
        } else {
            this.Z = 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.mediationsdk.utils.j jVar;
        IronSourceError ironSourceError;
        com.ironsource.mediationsdk.utils.k a2;
        Context applicationContext;
        boolean isInitResponseCached;
        ConcurrentHashMap<String, List<String>> c;
        IronLog.INTERNAL.verbose();
        if (!IronSourcePreconditions.a((Object) context, "Init Failed - provided context is null")) {
            a("Provided context is null");
            return;
        }
        boolean z2 = context instanceof Activity;
        if (z2) {
            c((Activity) context);
        }
        if (initializationListener != null) {
            this.af = initializationListener;
        }
        if (this.T == null || !this.T.compareAndSet(true, false)) {
            if (ad_unitArr != null) {
                a(z2, z, ad_unitArr);
                if (D.a().b() == D.a.INITIATED && !z) {
                    G();
                    return;
                }
            } else {
                this.c.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.V.add(ad_unit);
                this.W.add(ad_unit);
                if (ad_unit.equals(IronSource.AD_UNIT.INTERSTITIAL)) {
                    this.u = true;
                }
                if (ad_unit.equals(IronSource.AD_UNIT.BANNER)) {
                    this.aa = true;
                }
                if (ad_unit.equals(IronSource.AD_UNIT.NATIVE_AD)) {
                    this.v = true;
                }
                if (ad_unit.equals(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                    this.t = true;
                }
            }
            IronLog.API.info("init(appKey:" + str + ")");
            jVar = new com.ironsource.mediationsdk.utils.j();
            if (str != null) {
                ironSourceError = new IronSourceError(506, "Init Fail - appKey is missing");
            } else {
                if (a(str, 5, 10)) {
                    if (!p(str)) {
                        ironSourceError = ErrorBuilder.buildInvalidCredentialsError("appKey", str, "should contain only english characters and numbers");
                    }
                    if (jVar.a()) {
                        this.g = str;
                    }
                    a2 = a(context, this.g);
                    if (a2 != null) {
                        ApplicationGeneralSettings f = a2.c.f.f();
                        DeviceConfigurationsDataHolder deviceConfigurationsDataHolder = DeviceConfigurationsDataHolder.f5215a;
                        DeviceConfigurationsDataHolder.a(f.getD());
                        DeviceConfigurationsDataHolder deviceConfigurationsDataHolder2 = DeviceConfigurationsDataHolder.f5215a;
                        DeviceConfigurationsDataHolder.c(f.getE());
                        DeviceConfigurationsDataHolder deviceConfigurationsDataHolder3 = DeviceConfigurationsDataHolder.f5215a;
                        DeviceConfigurationsDataHolder.a(f.getF());
                    }
                    ContextProvider.getInstance().updateAppContext(context.getApplicationContext());
                    Context applicationContext2 = context.getApplicationContext();
                    TimeUnit timeUnit = TimeUnit.HOURS;
                    DeviceConfigurationsDataHolder deviceConfigurationsDataHolder4 = DeviceConfigurationsDataHolder.f5215a;
                    com.ironsource.environment.h.a(applicationContext2, timeUnit.toMillis(DeviceConfigurationsDataHolder.d()));
                    com.ironsource.environment.c.e.a("medv", IronSourceUtils.getSDKVersion());
                    this.M.a(ISAdPlayer.a());
                    this.M.a(IronSourceUtils.isGooglePlayInstalled(context));
                    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);
                    }
                    c = com.ironsource.mediationsdk.utilities.c.a().c();
                    if (c.containsKey("is_deviceid_optout")) {
                        String str2 = c.get("is_deviceid_optout").get(0);
                        if (!TextUtils.isEmpty(str2)) {
                            boolean z3 = !MetaDataUtils.getMetaDataBooleanValue(str2);
                            DeviceConfigurationsDataHolder deviceConfigurationsDataHolder5 = DeviceConfigurationsDataHolder.f5215a;
                            DeviceConfigurationsDataHolder.b(z3);
                        }
                    }
                    if (this.Q != null && this.Q.compareAndSet(false, true)) {
                        com.ironsource.mediationsdk.events.j.a().a(new com.ironsource.mediationsdk.utils.f(context));
                        com.ironsource.mediationsdk.events.e.d().a(context, this.p);
                        com.ironsource.mediationsdk.events.i.d().a(context, this.p);
                        PixelEventsManager.x.a(context, this.p);
                    }
                    if (this.g == null) {
                        D.a().a(D.a.INIT_FAILED);
                        if (this.V.contains(IronSource.AD_UNIT.REWARDED_VIDEO)) {
                            R.a().a(false, (AdInfo) null);
                        }
                        if (this.V.contains(IronSource.AD_UNIT.OFFERWALL)) {
                            this.d.a(false, jVar.b());
                        }
                        IronSourceLoggerManager.getLogger().log(IronSourceLogger.IronSourceTag.API, jVar.b().toString(), 1);
                        return;
                    }
                    com.ironsource.environment.c.e.a(context);
                    com.ironsource.environment.c.e.a("apky", this.g);
                    com.ironsource.environment.c.e.a("sid", this.m);
                    com.ironsource.environment.c.e.a("plugin", ConfigFile.getConfigFile().getPluginType());
                    if (this.X) {
                        JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(z);
                        if (ad_unitArr != null) {
                            for (IronSource.AD_UNIT ad_unit2 : ad_unitArr) {
                                try {
                                    mediationAdditionalData.put(ad_unit2.toString(), true);
                                } catch (Exception unused) {
                                }
                            }
                        }
                        int i = this.q + 1;
                        this.q = i;
                        a(z2, z, i, mediationAdditionalData);
                        this.X = false;
                    }
                    D.a().a(this);
                    D.a().a(this.L);
                    D.a().a(context, str, this.h);
                    return;
                }
                ironSourceError = ErrorBuilder.buildInvalidCredentialsError("appKey", str, "length should be between 5-10 characters");
            }
            jVar.a(ironSourceError);
            if (jVar.a()) {
            }
            a2 = a(context, this.g);
            if (a2 != null) {
            }
            ContextProvider.getInstance().updateAppContext(context.getApplicationContext());
            Context applicationContext22 = context.getApplicationContext();
            TimeUnit timeUnit2 = TimeUnit.HOURS;
            DeviceConfigurationsDataHolder deviceConfigurationsDataHolder42 = DeviceConfigurationsDataHolder.f5215a;
            com.ironsource.environment.h.a(applicationContext22, timeUnit2.toMillis(DeviceConfigurationsDataHolder.d()));
            com.ironsource.environment.c.e.a("medv", IronSourceUtils.getSDKVersion());
            this.M.a(ISAdPlayer.a());
            this.M.a(IronSourceUtils.isGooglePlayInstalled(context));
            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);
            }
            c = com.ironsource.mediationsdk.utilities.c.a().c();
            if (c.containsKey("is_deviceid_optout")) {
            }
            if (this.Q != null) {
                com.ironsource.mediationsdk.events.j.a().a(new com.ironsource.mediationsdk.utils.f(context));
                com.ironsource.mediationsdk.events.e.d().a(context, this.p);
                com.ironsource.mediationsdk.events.i.d().a(context, this.p);
                PixelEventsManager.x.a(context, this.p);
            }
            if (this.g == null) {
            }
        }
        for (IronSource.AD_UNIT ad_unit3 : IronSource.AD_UNIT.values()) {
            this.V.add(ad_unit3);
        }
        this.t = true;
        this.u = true;
        this.aa = true;
        this.v = true;
        IronLog.API.info("init(appKey:" + str + ")");
        jVar = new com.ironsource.mediationsdk.utils.j();
        if (str != null) {
        }
        jVar.a(ironSourceError);
        if (jVar.a()) {
        }
        a2 = a(context, this.g);
        if (a2 != null) {
        }
        ContextProvider.getInstance().updateAppContext(context.getApplicationContext());
        Context applicationContext222 = context.getApplicationContext();
        TimeUnit timeUnit22 = TimeUnit.HOURS;
        DeviceConfigurationsDataHolder deviceConfigurationsDataHolder422 = DeviceConfigurationsDataHolder.f5215a;
        com.ironsource.environment.h.a(applicationContext222, timeUnit22.toMillis(DeviceConfigurationsDataHolder.d()));
        com.ironsource.environment.c.e.a("medv", IronSourceUtils.getSDKVersion());
        this.M.a(ISAdPlayer.a());
        this.M.a(IronSourceUtils.isGooglePlayInstalled(context));
        applicationContext = ContextProvider.getInstance().getApplicationContext();
        isInitResponseCached = IronSourceUtils.isInitResponseCached(applicationContext);
        long firstSessionTimestamp22 = IronSourceUtils.getFirstSessionTimestamp(applicationContext);
        if (!isInitResponseCached) {
        }
        c = com.ironsource.mediationsdk.utilities.c.a().c();
        if (c.containsKey("is_deviceid_optout")) {
        }
        if (this.Q != null) {
        }
        if (this.g == null) {
        }
    }

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

    public final void a(IronSourceBannerLayout ironSourceBannerLayout, String str) {
        IronLog.INTERNAL.verbose("placementName = " + str);
        if (this.Z) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "Banner was initialized in demand only mode. Use loadISDemandOnlyBanner instead", 3);
            C1392p.a().a(IronSource.AD_UNIT.BANNER, ErrorBuilder.buildInitFailedError("Banner was initialized in demand only mode. Use loadISDemandOnlyBanner instead", IronSourceConstants.BANNER_AD_UNIT));
            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.c.log(IronSourceLogger.IronSourceTag.API, sb2, 3);
            C1392p.a().a(IronSource.AD_UNIT.BANNER, ErrorBuilder.buildLoadFailedError(sb2));
            return;
        }
        if (!this.aa) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "init() must be called before loadBanner()", 3);
            C1392p.a().a(IronSource.AD_UNIT.BANNER, ErrorBuilder.buildLoadFailedError("init() must be called before loadBanner()"));
            return;
        }
        if (ironSourceBannerLayout.getSize().getDescription().equals("CUSTOM") && (ironSourceBannerLayout.getSize().getWidth() <= 0 || ironSourceBannerLayout.getSize().getHeight() <= 0)) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "loadBanner: Unsupported banner size. Height and width must be bigger than 0", 3);
            C1392p.a().a(IronSource.AD_UNIT.BANNER, ErrorBuilder.unsupportedBannerSize(""));
            return;
        }
        D.a b2 = D.a().b();
        if (b2 == D.a.INIT_FAILED) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
            C1392p.a().a(IronSource.AD_UNIT.BANNER, new IronSourceError(600, "Init() had failed"));
            return;
        }
        if (b2 == D.a.INIT_IN_PROGRESS) {
            if (D.a().c()) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
                C1392p.a().a(IronSource.AD_UNIT.BANNER, new IronSourceError(601, "Init() had failed"));
                return;
            } else {
                this.ad = ironSourceBannerLayout;
                this.ac = Boolean.TRUE;
                this.ae = str;
                return;
            }
        }
        if (!F()) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "No banner configurations found", 3);
            C1392p.a().a(IronSource.AD_UNIT.BANNER, new IronSourceError(IronSourceError.ERROR_BN_LOAD_NO_CONFIG, "the server response does not contain banner data"));
        } else if (this.z == null && this.C == null) {
            this.ad = ironSourceBannerLayout;
            this.ac = Boolean.TRUE;
            this.ae = str;
        } else if (this.H) {
            this.C.a(ironSourceBannerLayout, new Placement(r(str)));
        } else {
            this.z.a(ironSourceBannerLayout, r(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.t) {
            if (levelPlayRewardedVideoManualListener == null) {
                this.D = false;
                ironLog = IronLog.API;
                str = "Disabling rewarded video manual mode";
            } else {
                this.D = true;
                ironLog = IronLog.API;
                str = "Enabling rewarded video manual mode";
            }
            ironLog.info(str);
        }
        R.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.t) {
            if (rewardedVideoManualListener == null) {
                this.D = false;
                ironLog = IronLog.API;
                str = "Disabling rewarded video manual mode";
            } else {
                this.D = true;
                ironLog = IronLog.API;
                str = "Enabling rewarded video manual mode";
            }
            ironLog.info(str);
        }
        this.d.f5482a = rewardedVideoManualListener;
        R.a().f5284a = rewardedVideoManualListener;
    }

    @Override
    public final void a(String str) {
        try {
            this.c.log(IronSourceLogger.IronSourceTag.API, "onInitFailed(reason:" + str + ")", 1);
            IronSourceUtils.sendAutomationLog("Mediation init failed");
            if (this.d != null) {
                Iterator<IronSource.AD_UNIT> it = this.V.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)) {
            C1384c.a().a(metaDataKey, metaDataValue);
        } else if (D.a().b() == D.a.INITIATED && MetaDataUtils.isMediationKeysBeforeInit(metaDataKey)) {
            IronLog.API.error("setMetaData with key = " + metaDataKey + " must to be called before init");
        } else {
            com.ironsource.mediationsdk.utilities.c.a().a(metaDataKey, metaDataValue);
        }
        try {
            ConcurrentHashMap<String, List<String>> concurrentHashMap = C1384c.a().d;
            concurrentHashMap.putAll(com.ironsource.mediationsdk.utilities.c.a().c());
            JSONObject jSONObject = new JSONObject();
            for (Map.Entry<String, List<String>> entry : concurrentHashMap.entrySet()) {
                jSONObject.put(entry.getKey(), entry.getValue());
            }
            com.ironsource.environment.c.e.a("md", (Object) jSONObject);
        } catch (JSONException e) {
            IronLog.INTERNAL.error("got the following error " + e.getMessage());
            e.printStackTrace();
        }
        com.ironsource.mediationsdk.events.i.d().b(new com.ironsource.environment.c.a(D.a().b() == D.a.INITIATED ? 51 : 50, IronSourceUtils.getJsonForMetaData(str, list, metaDataValue)));
    }

    @Override
    public final void a(List<IronSource.AD_UNIT> list, boolean z, com.ironsource.mediationsdk.model.f fVar) {
        IronLog.INTERNAL.verbose();
        try {
            this.e.d = fVar.f.a().c();
            this.U = list;
            this.l = true;
            this.c.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.i.d().b(new com.ironsource.environment.c.a(114, mediationAdditionalData));
            }
            com.ironsource.mediationsdk.events.e.d().b();
            com.ironsource.mediationsdk.events.i.d().b();
            C1384c a2 = C1384c.a();
            String str = this.g;
            String str2 = this.h;
            a2.b = str;
            a2.c = str2;
            for (IronSource.AD_UNIT ad_unit : IronSource.AD_UNIT.values()) {
                if (this.V.contains(ad_unit)) {
                    if (list.contains(ad_unit)) {
                        b(ad_unit);
                    } else {
                        a(ad_unit, false);
                    }
                }
            }
            G();
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

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

    public final NativeAdManager b() {
        IronLog.INTERNAL.verbose();
        List<NetworkSettings> a2 = a(this.f.f5556a.d);
        if (a2.size() > 0) {
            return new NativeAdManager(a2, this.f.c.e, IronSourceUtils.getUserIdForNetworks(), com.ironsource.mediationsdk.utilities.c.a(), this.p, this.f.d());
        }
        JSONObject mediationAdditionalData = IronSourceUtils.getMediationAdditionalData(false, true, 1);
        a(mediationAdditionalData, new Object[][]{new Object[]{"errorCode", 1010}});
        b(IronSourceConstants.TROUBLESHOOTING_NT_INIT_FAILED, mediationAdditionalData);
        return null;
    }

    public final String b(Context context) {
        String str;
        com.ironsource.mediationsdk.utils.o oVar;
        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;
        }
        D.a b2 = D.a().b();
        if (b2 == D.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 == D.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.k a2 = this.f != null ? this.f : InitServerResponse.a(context);
            if (b2 == D.a.NOT_INIT) {
                com.ironsource.environment.c.e.a(context);
                com.ironsource.environment.c.e.a("medv", IronSourceUtils.getSDKVersion());
                com.ironsource.environment.c.e.a("sid", this.m);
                com.ironsource.environment.c.e.a("plugin", ConfigFile.getConfigFile().getPluginType());
                this.M.a(ISAdPlayer.a());
                this.M.a(IronSourceUtils.isGooglePlayInstalled(context));
            }
            if (b2 != D.a.INITIATED) {
                D.a().a(a2);
                if (a2 != null) {
                    D.a().a(context, a2);
                }
            }
            if (a2 == null || !a2.b()) {
                oVar = new com.ironsource.mediationsdk.utils.o();
            } else {
                oVar = a2.c.f.c();
                if (!oVar.d) {
                    oVar.b = a2.b.a(IronSourceConstants.IRONSOURCE_CONFIG_NAME);
                }
            }
            JSONObject a3 = TokenRepository.a(context, oVar);
            C1385d.a().a(a3, true);
            str = oVar.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 void b(Activity activity) {
        this.c.log(IronSourceLogger.IronSourceTag.API, "showInterstitial()", 1);
        try {
            if (this.s) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized in demand only mode. Use showISDemandOnlyInterstitial instead", 3);
                C1396t.a().a(new IronSourceError(510, "Interstitial was initialized in demand only mode. Use showISDemandOnlyInterstitial instead"), (AdInfo) null);
            } else {
                if (!C()) {
                    C1396t.a().a(ErrorBuilder.buildInitFailedError("showInterstitial can't be called before the Interstitial ad unit initialization completed successfully", IronSourceConstants.INTERSTITIAL_AD_UNIT), (AdInfo) null);
                    return;
                }
                InterstitialPlacement B = B();
                if (B != null) {
                    b(activity, B.getB());
                } else {
                    C1396t.a().a(new IronSourceError(1020, "showInterstitial error: empty default placement in response"), (AdInfo) null);
                }
            }
        } catch (Exception e) {
            this.c.logException(IronSourceLogger.IronSourceTag.API, "showInterstitial()", e);
            C1396t.a().a(new IronSourceError(510, e.getMessage()), (AdInfo) null);
        }
    }

    public final void b(Activity activity, String str) {
        String str2 = "showInterstitial(" + str + ")";
        this.c.log(IronSourceLogger.IronSourceTag.API, str2, 1);
        try {
            if (this.s) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized in demand only mode. Use showISDemandOnlyInterstitial instead", 3);
                C1396t.a().a(new IronSourceError(510, "Interstitial was initialized in demand only mode. Use showISDemandOnlyInterstitial instead"), (AdInfo) null);
            } else if (C()) {
                d(activity, str);
            } else {
                C1396t.a().a(ErrorBuilder.buildInitFailedError("showInterstitial can't be called before the Interstitial ad unit initialization completed successfully", IronSourceConstants.INTERSTITIAL_AD_UNIT), (AdInfo) null);
            }
        } catch (Exception e) {
            this.c.logException(IronSourceLogger.IronSourceTag.API, str2, e);
            C1396t.a().a(new IronSourceError(510, e.getMessage()), (AdInfo) null);
        }
    }

    public final synchronized void b(Activity activity, String str, String str2) {
        this.c.log(IronSourceLogger.IronSourceTag.API, "loadISDemandOnlyRewardedVideo() instanceId=" + str, 1);
        try {
        } catch (Throwable th) {
            this.c.logException(IronSourceLogger.IronSourceTag.API, "loadISDemandOnlyRewardedVideo", th);
            com.ironsource.mediationsdk.demandOnly.i.a().a(str, new IronSourceError(510, th.getMessage()));
        }
        if (!this.t) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "initISDemandOnly() must be called before loadISDemandOnlyRewardedVideo()", 3);
            com.ironsource.mediationsdk.demandOnly.i.a().a(str, new IronSourceError(508, "initISDemandOnly() must be called before loadISDemandOnlyRewardedVideo()"));
            return;
        }
        if (!this.r) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was initialized in mediation mode", 3);
            com.ironsource.mediationsdk.demandOnly.i.a().a(str, new IronSourceError(508, "Rewarded video was initialized in mediation mode"));
            return;
        }
        boolean z = false;
        if (activity != null) {
            c(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.c.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was initialized and loaded without Activity", 3);
            com.ironsource.mediationsdk.demandOnly.i.a().a(str, new IronSourceError(IronSourceError.ERROR_DO_RV_LOAD_MISSING_ACTIVITY, "Rewarded video was initialized and loaded without Activity"));
            return;
        }
        D.a b2 = D.a().b();
        if (b2 == D.a.INIT_FAILED) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
            com.ironsource.mediationsdk.demandOnly.i.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
            return;
        }
        if (b2 == D.a.INIT_IN_PROGRESS) {
            if (D.a().c()) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
                com.ironsource.mediationsdk.demandOnly.i.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
                return;
            }
            synchronized (this.aj) {
                this.aj.add(str);
            }
            if (str2 != null) {
                a(IronSourceConstants.TROUBLESHOOTING_DO_IAB_RV_LOAD_FAILED_INIT_IN_PROGRESS, IronSourceUtils.getMediationAdditionalData(true, true, this.I));
            }
            return;
        }
        if (!e()) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "No rewarded video configurations found", 3);
            com.ironsource.mediationsdk.demandOnly.i.a().a(str, ErrorBuilder.buildInitFailedError("the server response does not contain rewarded video data", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
            return;
        }
        synchronized (this.aj) {
            if (this.al == null) {
                this.aj.add(str);
                if (str2 != null) {
                    a(IronSourceConstants.TROUBLESHOOTING_DO_IAB_RV_LOAD_FAILED_INIT_IN_PROGRESS, IronSourceUtils.getMediationAdditionalData(true, true, this.I));
                }
            } else if (str2 == null) {
                this.al.a(str, (String) null, false);
            } else {
                this.al.a(str, str2, true);
            }
        }
    }

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

    @Override
    public final void c() {
        if (this.ac.booleanValue()) {
            this.ac = Boolean.FALSE;
            C1392p.a().a(IronSource.AD_UNIT.BANNER, new IronSourceError(603, "init() had failed"));
            this.ad = null;
            this.ae = null;
        }
        if (this.G) {
            this.G = false;
            C1392p.a().a(IronSource.AD_UNIT.INTERSTITIAL, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.INTERSTITIAL_AD_UNIT));
        }
        if (this.E) {
            this.E = false;
            C1392p.a().a(IronSource.AD_UNIT.REWARDED_VIDEO, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
        }
        synchronized (this.ai) {
            Iterator<String> it = this.ai.iterator();
            while (it.hasNext()) {
                com.ironsource.mediationsdk.demandOnly.h.a().a(it.next(), ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.INTERSTITIAL_AD_UNIT));
            }
            this.ai.clear();
        }
        synchronized (this.aj) {
            Iterator<String> it2 = this.aj.iterator();
            while (it2.hasNext()) {
                com.ironsource.mediationsdk.demandOnly.i.a().a(it2.next(), ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
            }
            this.aj.clear();
        }
        synchronized (this.ak) {
            Iterator<String> it3 = this.ak.iterator();
            while (it3.hasNext()) {
                String next = it3.next();
                ISDemandOnlyBannerLayout iSDemandOnlyBannerLayout = this.ab.get(next);
                if (iSDemandOnlyBannerLayout != null) {
                    iSDemandOnlyBannerLayout.getListener().a(next, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.BANNER_AD_UNIT));
                }
            }
            this.ak.clear();
            this.ab.clear();
        }
    }

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

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

    public final synchronized void d(Activity activity, String str, String str2) {
        this.c.log(IronSourceLogger.IronSourceTag.API, "loadISDemandOnlyInterstitial() instanceId=" + str, 1);
        try {
        } catch (Throwable th) {
            this.c.logException(IronSourceLogger.IronSourceTag.API, "loadDemandOnlyInterstitial", th);
            com.ironsource.mediationsdk.demandOnly.h.a().a(str, new IronSourceError(510, th.getMessage()));
        }
        if (!this.u) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "initISDemandOnly() must be called before loadISDemandOnlyInterstitial()", 3);
            com.ironsource.mediationsdk.demandOnly.h.a().a(str, new IronSourceError(510, "initISDemandOnly() must be called before loadISDemandOnlyInterstitial()"));
            return;
        }
        if (!this.s) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized in mediation mode. Use loadInterstitial instead", 3);
            com.ironsource.mediationsdk.demandOnly.h.a().a(str, new IronSourceError(510, "Interstitial was initialized in mediation mode. Use loadInterstitial instead"));
            return;
        }
        boolean z = false;
        if (activity != null) {
            c(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.c.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized and loaded without Activity", 3);
            com.ironsource.mediationsdk.demandOnly.h.a().a(str, new IronSourceError(IronSourceError.ERROR_DO_IS_LOAD_MISSING_ACTIVITY, "Interstitial was initialized and loaded without Activity"));
            return;
        }
        D.a b2 = D.a().b();
        if (b2 == D.a.INIT_FAILED) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
            com.ironsource.mediationsdk.demandOnly.h.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.INTERSTITIAL_AD_UNIT));
            return;
        }
        if (b2 == D.a.INIT_IN_PROGRESS) {
            if (D.a().c()) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "init() had failed", 3);
                com.ironsource.mediationsdk.demandOnly.h.a().a(str, ErrorBuilder.buildInitFailedError("init() had failed", IronSourceConstants.INTERSTITIAL_AD_UNIT));
                return;
            }
            synchronized (this.ai) {
                this.ai.add(str);
            }
            if (str2 != null) {
                b(IronSourceConstants.TROUBLESHOOTING_DO_IAB_IS_LOAD_FAILED_INIT_IN_PROGRESS, IronSourceUtils.getMediationAdditionalData(true, true, 1));
            }
            return;
        }
        if (!g()) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "No interstitial configurations found", 3);
            com.ironsource.mediationsdk.demandOnly.h.a().a(str, ErrorBuilder.buildInitFailedError("the server response does not contain interstitial data", IronSourceConstants.INTERSTITIAL_AD_UNIT));
            return;
        }
        synchronized (this.ai) {
            if (this.J == null) {
                this.ai.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.J.a(str, (String) null, false);
            } else {
                this.J.a(str, str2, true);
            }
        }
    }

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

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

    public final synchronized void e(String str) {
        this.c.log(IronSourceLogger.IronSourceTag.API, "showISDemandOnlyRewardedVideo() instanceId=" + str, 1);
        try {
        } catch (Exception e) {
            this.c.logException(IronSourceLogger.IronSourceTag.API, "showISDemandOnlyRewardedVideo", e);
            com.ironsource.mediationsdk.demandOnly.i.a().b(str, new IronSourceError(510, e.getMessage()));
        }
        if (!this.r) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was initialized in mediation mode. Use showRewardedVideo instead", 3);
            com.ironsource.mediationsdk.demandOnly.i.a().b(str, new IronSourceError(508, "Rewarded video was initialized in mediation mode. Use showRewardedVideo instead"));
            return;
        }
        if (this.al == null) {
            this.c.log(IronSourceLogger.IronSourceTag.API, "Rewarded video was not initiated", 3);
            com.ironsource.mediationsdk.demandOnly.i.a().b(str, new IronSourceError(508, "Rewarded video was not initiated"));
            return;
        }
        com.ironsource.mediationsdk.demandOnly.e eVar = this.al;
        if (eVar.f5382a.containsKey(str)) {
            com.ironsource.mediationsdk.demandOnly.f fVar = eVar.f5382a.get(str);
            eVar.a(IronSourceConstants.RV_INSTANCE_SHOW, fVar);
            fVar.a();
        } else {
            com.ironsource.mediationsdk.demandOnly.e.a(1500, str);
            com.ironsource.mediationsdk.demandOnly.i.a().b(str, ErrorBuilder.buildNonExistentInstanceError(IronSourceConstants.REWARDED_VIDEO_AD_UNIT));
        }
    }

    public boolean e() {
        return z() && A();
    }

    public final boolean f() {
        boolean z;
        try {
            if (this.s) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "Interstitial was initialized in demand only mode. Use isISDemandOnlyInterstitialReady instead", 3);
                return false;
            }
            boolean z2 = !this.F ? this.y == null || !this.y.e() : this.A == null || !this.A.g();
            try {
                com.ironsource.mediationsdk.events.e.d().b(new com.ironsource.environment.c.a(z2 ? IronSourceConstants.IS_CHECK_READY_TRUE : IronSourceConstants.IS_CHECK_READY_FALSE, IronSourceUtils.getMediationAdditionalData(false, true, 1)));
                this.c.log(IronSourceLogger.IronSourceTag.API, "isInterstitialReady():" + z2, 1);
                return z2;
            } catch (Throwable th) {
                z = z2;
                th = th;
                this.c.log(IronSourceLogger.IronSourceTag.API, "isInterstitialReady():" + z, 1);
                this.c.logException(IronSourceLogger.IronSourceTag.API, "isInterstitialReady()", th);
                return false;
            }
        } catch (Throwable th2) {
            th = th2;
            z = false;
        }
    }

    public final synchronized boolean f(String str) {
        boolean z;
        if (this.al != null) {
            com.ironsource.mediationsdk.demandOnly.e eVar = this.al;
            if (eVar.f5382a.containsKey(str)) {
                com.ironsource.mediationsdk.demandOnly.f fVar = eVar.f5382a.get(str);
                if (fVar.b()) {
                    com.ironsource.mediationsdk.demandOnly.e.a(IronSourceConstants.RV_INSTANCE_READY_TRUE, fVar, (Object[][]) null);
                    z = true;
                    if (z) {
                        return true;
                    }
                } else {
                    com.ironsource.mediationsdk.demandOnly.e.a(IronSourceConstants.RV_INSTANCE_READY_FALSE, fVar, (Object[][]) null);
                }
            } else {
                com.ironsource.mediationsdk.demandOnly.e.a(1500, str);
            }
            z = false;
            if (z) {
            }
        }
        return false;
    }

    public boolean g() {
        return C() && D();
    }

    public final synchronized boolean g(String str) {
        boolean z;
        if (this.J != null) {
            com.ironsource.mediationsdk.demandOnly.c cVar = this.J;
            if (cVar.f5379a.containsKey(str)) {
                com.ironsource.mediationsdk.demandOnly.d dVar = cVar.f5379a.get(str);
                if (dVar.b()) {
                    com.ironsource.mediationsdk.demandOnly.c.a(IronSourceConstants.IS_INSTANCE_READY_TRUE, dVar, (Object[][]) null);
                    z = true;
                    if (z) {
                        return true;
                    }
                } else {
                    com.ironsource.mediationsdk.demandOnly.c.a(IronSourceConstants.IS_INSTANCE_READY_FALSE, dVar, (Object[][]) null);
                }
            } else {
                com.ironsource.mediationsdk.demandOnly.c.a(2500, str);
            }
            z = false;
            if (z) {
            }
        }
        return false;
    }

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

    public boolean h() {
        com.ironsource.mediationsdk.utils.k kVar = this.f;
        return (kVar == null || kVar.c == null || this.f.c.c == null) ? false : true;
    }

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

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

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

    public boolean j() {
        com.ironsource.mediationsdk.utils.k kVar = this.f;
        return (kVar == null || kVar.c == null || this.f.c.e == null) ? false : true;
    }

    public final boolean k() {
        return this.r || this.s || this.Z;
    }

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

    public final boolean l(String str) {
        if (!E()) {
            return false;
        }
        BannerPlacement bannerPlacement = null;
        try {
            bannerPlacement = this.f.c.d.a(str);
            if (bannerPlacement == null && (bannerPlacement = this.f.c.d.a()) == null) {
                this.c.log(IronSourceLogger.IronSourceTag.API, "Banner default placement was not found", 3);
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (bannerPlacement == null) {
            return false;
        }
        return com.ironsource.mediationsdk.utils.j.b(ContextProvider.getInstance().getApplicationContext(), bannerPlacement.getB());
    }

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