package com.ironsource; import android.content.Context; import com.ironsource.mediationsdk.logger.IronLog; import com.ironsource.qf; import com.ironsource.sdk.controller.FeaturesManager; import com.ironsource.sdk.utils.Logger; import com.ironsource.v8; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public class wu { private final String a; private Context b; private y8 c; private ia d; private int e; private ra f; private int g; private int h; private final String i = wu.class.getSimpleName(); private a j; public enum a { NOT_RECOVERED, RECOVERED, IN_RECOVERING, NOT_ALLOWED } public wu(Context context, y8 y8Var, ia iaVar, int i, ra raVar, String str) { a h = h(); this.j = h; if (h != a.NOT_ALLOWED) { this.b = context; this.c = y8Var; this.d = iaVar; this.e = i; this.f = raVar; this.g = 0; } this.a = str; } private a h() { this.h = FeaturesManager.getInstance().getInitRecoverTrials(); Logger.i(this.i, "getInitialState mMaxAllowedTrials: " + this.h); if (this.h > 0) { return a.NOT_RECOVERED; } Logger.i(this.i, "recovery is not allowed by config"); return a.NOT_ALLOWED; } private void j() { if (this.g != this.h) { this.j = a.NOT_RECOVERED; return; } Logger.i(this.i, "handleRecoveringEndedFailed | Reached max trials"); this.j = a.NOT_ALLOWED; a(); } private void k() { a(); this.j = a.RECOVERED; } public void a() { this.b = null; this.c = null; this.d = null; this.f = null; } public void a(boolean z) { if (this.j != a.IN_RECOVERING) { return; } if (z) { k(); } else { j(); } } public boolean a(qf.c cVar, qf.b bVar) { Logger.i(this.i, "shouldRecoverWebController: "); a aVar = this.j; if (aVar == a.NOT_ALLOWED) { Logger.i(this.i, "shouldRecoverWebController: false | recover is not allowed"); return false; } if (cVar != qf.c.Native) { Logger.i(this.i, "shouldRecoverWebController: false | current controller type is: " + cVar); return false; } if (bVar == qf.b.Loading || bVar == qf.b.None) { Logger.i(this.i, "shouldRecoverWebController: false | a Controller is currently loading"); return false; } if (aVar == a.RECOVERED) { Logger.i(this.i, "shouldRecoverWebController: false | already recovered"); return false; } if (aVar == a.IN_RECOVERING) { Logger.i(this.i, "shouldRecoverWebController: false | currently in recovering"); return false; } if (this.b == null || this.c == null || this.d == null) { Logger.i(this.i, "shouldRecoverWebController: false | missing mandatory param"); return false; } Logger.i(this.i, "shouldRecoverWebController: true | allow recovering "); return true; } public Context b() { return this.b; } public String c() { return this.a; } public y8 d() { return this.c; } public int e() { return this.e; } public ia f() { return this.d; } public ra g() { return this.f; } public JSONObject i() { JSONObject jSONObject = new JSONObject(); try { jSONObject.put(v8.h.A0, m()); jSONObject.put(v8.h.B0, this.g); jSONObject.put(v8.h.C0, this.h); } catch (JSONException e) { i9.d().a(e); IronLog.INTERNAL.error(e.toString()); } return jSONObject; } public boolean l() { return this.j == a.IN_RECOVERING; } public boolean m() { return this.j == a.RECOVERED; } public void n() { a aVar = this.j; a aVar2 = a.IN_RECOVERING; if (aVar != aVar2) { this.g++; Logger.i(this.i, "recoveringStarted - trial number " + this.g); this.j = aVar2; } } }