package uc; import android.content.Context; import android.content.SharedPreferences; import android.hardware.Sensor; import android.hardware.SensorManager; import android.os.RemoteException; import android.text.TextUtils; import bb.f1; import bb.h1; import bb.k1; import com.google.android.exoplayer.hls.HlsMediaPlaylist; import com.google.android.gms.internal.ads.zzcgz; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import za.q; public final class l61 implements q61, x51 { /* renamed from: a reason: collision with root package name */ public final p61 f158407a; /* renamed from: b reason: collision with root package name */ public final r61 f158408b; /* renamed from: c reason: collision with root package name */ public final y51 f158409c; /* renamed from: d reason: collision with root package name */ public final f61 f158410d; /* renamed from: e reason: collision with root package name */ public final w51 f158411e; /* renamed from: f reason: collision with root package name */ public final String f158412f; /* renamed from: g reason: collision with root package name */ public final Map<String, List<a61>> f158413g; /* renamed from: h reason: collision with root package name */ public String f158414h = "{}"; /* renamed from: i reason: collision with root package name */ public String f158415i = ""; /* renamed from: j reason: collision with root package name */ public long f158416j = Long.MAX_VALUE; /* renamed from: k reason: collision with root package name */ public g61 f158417k = g61.NONE; /* renamed from: l reason: collision with root package name */ public boolean f158418l; /* renamed from: m reason: collision with root package name */ public int f158419m; /* renamed from: n reason: collision with root package name */ public boolean f158420n; /* renamed from: o reason: collision with root package name */ public k61 f158421o = k61.UNKNOWN; public l61(p61 p612, r61 r612, y51 y512, Context context, zzcgz zzcgz, f61 f612) { this.f158407a = p612; this.f158408b = r612; this.f158409c = y512; this.f158413g = new HashMap(); this.f158411e = new w51(context); this.f158412f = zzcgz.f29087b; this.f158410d = f612; q.B.f198513m.f12096g = this; } public final void a() { String str; boolean z14; iq<Boolean> iqVar = pq.I5; ym ymVar = ym.f164106d; if (((Boolean) ymVar.f164109c.a(iqVar)).booleanValue()) { if (((Boolean) ymVar.f164109c.a(pq.X5)).booleanValue()) { k1 k1Var = (k1) q.B.f198507g.f(); k1Var.d(); synchronized (k1Var.f11991a) { z14 = k1Var.f12013w; } if (z14) { h(); return; } } k1 k1Var2 = (k1) q.B.f198507g.f(); k1Var2.d(); synchronized (k1Var2.f11991a) { str = k1Var2.f12012v; } if (!TextUtils.isEmpty(str)) { try { if (new JSONObject(str).optBoolean("isTestMode", false)) { h(); } } catch (JSONException unused) { } } } } public final void b(boolean z14) { if (!this.f158420n && z14) { h(); } e(z14, true); } public final synchronized void c(no noVar, k61 k612) { if (!d()) { try { noVar.r(g0.h(18, null, null)); } catch (RemoteException unused) { f1.f("Ad inspector cannot be opened because the device is not in test mode. See https://developers.google.com/admob/android/test-ads#enable_test_devices for more information."); } } else { if (!((Boolean) ym.f164106d.f164109c.a(pq.I5)).booleanValue()) { try { noVar.r(g0.h(1, null, null)); } catch (RemoteException unused2) { f1.f("Ad inspector had an internal error."); } } else { this.f158421o = k612; this.f158407a.a(noVar, new fw(this)); } } } public final synchronized boolean d() { if (((Boolean) ym.f164106d.f164109c.a(pq.X5)).booleanValue()) { return this.f158418l || q.B.f198513m.g(); } return this.f158418l; } /* JADX WARNING: Removed duplicated region for block: B:17:0x0036 */ /* JADX WARNING: Removed duplicated region for block: B:20:0x003b A[DONT_GENERATE] */ public final synchronized void e(boolean z14, boolean z15) { if (this.f158418l != z14) { this.f158418l = z14; if (z14) { if (!((Boolean) ym.f164106d.f164109c.a(pq.X5)).booleanValue() || !q.B.f198513m.g()) { i(); if (!z15) { k(); return; } return; } } if (!d()) { j(); } if (!z15) { } } } public final synchronized void f(g61 g612, boolean z14) { if (this.f158417k != g612) { if (d()) { j(); } this.f158417k = g612; if (d()) { i(); } if (z14) { k(); } } } public final synchronized JSONObject g() throws JSONException { JSONObject jSONObject; jSONObject = new JSONObject(); for (Map.Entry<String, List<a61>> entry : this.f158413g.entrySet()) { JSONArray jSONArray = new JSONArray(); for (a61 a612 : entry.getValue()) { if (a612.f154014e != z51.AD_REQUESTED) { jSONArray.put(a612.a()); } } if (jSONArray.length() > 0) { jSONObject.put(entry.getKey(), jSONArray); } } return jSONObject; } public final void h() { String str; this.f158420n = true; f61 f612 = this.f158410d; u51 u512 = f612.f156063a; d61 d612 = new d61(f612); s80<Boolean> s802 = u512.f162501e; s802.f161705b.a(new sf(u512, d612), u512.f162506j); this.f158407a.f160301d = this; this.f158408b.f161260g = this; this.f158409c.f163874j = this; k1 k1Var = (k1) q.B.f198507g.f(); k1Var.d(); synchronized (k1Var.f11991a) { str = k1Var.f12012v; } synchronized (this) { if (!TextUtils.isEmpty(str)) { try { JSONObject jSONObject = new JSONObject(str); e(jSONObject.optBoolean("isTestMode", false), false); f((g61) Enum.valueOf(g61.class, jSONObject.optString("gesture", HlsMediaPlaylist.ENCRYPTION_METHOD_NONE)), false); this.f158414h = jSONObject.optString("networkExtras", "{}"); this.f158416j = jSONObject.optLong("networkExtrasExpirationSecs", Long.MAX_VALUE); } catch (JSONException unused) { } } } } public final synchronized void i() { int ordinal = this.f158417k.ordinal(); if (ordinal == 1) { this.f158408b.a(); } else if (ordinal == 2) { this.f158409c.a(); } } public final synchronized void j() { SensorManager sensorManager; Sensor sensor; int ordinal = this.f158417k.ordinal(); if (ordinal == 1) { r61 r612 = this.f158408b; synchronized (r612) { if (r612.f161261h) { SensorManager sensorManager2 = r612.f161256c; if (sensorManager2 != null) { sensorManager2.unregisterListener(r612, r612.f161257d); f1.a("Stopped listening for shake gestures."); } r612.f161261h = false; } } } else if (ordinal == 2) { y51 y512 = this.f158409c; synchronized (y512) { if (!(!y512.f163875k || (sensorManager = y512.f163866b) == null || (sensor = y512.f163867c) == null)) { sensorManager.unregisterListener(y512, sensor); y512.f163875k = false; f1.a("Stopped listening for flick gestures."); } } } } public final void k() { String jSONObject; q qVar = q.B; h1 f14 = qVar.f198507g.f(); synchronized (this) { JSONObject jSONObject2 = new JSONObject(); try { jSONObject2.put("isTestMode", this.f158418l); jSONObject2.put("gesture", this.f158417k); if (this.f158416j > qVar.f198510j.currentTimeMillis() / 1000) { jSONObject2.put("networkExtras", this.f158414h); jSONObject2.put("networkExtrasExpirationSecs", this.f158416j); } } catch (JSONException unused) { } jSONObject = jSONObject2.toString(); } k1 k1Var = (k1) f14; Objects.requireNonNull(k1Var); if (((Boolean) ym.f164106d.f164109c.a(pq.I5)).booleanValue()) { k1Var.d(); synchronized (k1Var.f11991a) { if (!k1Var.f12012v.equals(jSONObject)) { k1Var.f12012v = jSONObject; SharedPreferences.Editor editor = k1Var.f11997g; if (editor != null) { editor.putString("inspector_info", jSONObject); k1Var.f11997g.apply(); } k1Var.e(); } } } } }