package com.tapjoy.internal; import android.content.Context; import android.content.IntentFilter; import android.os.Build; import com.tapjoy.TapjoyLog; import java.util.Hashtable; import java.util.concurrent.CountDownLatch; /* loaded from: classes4.dex */ public final class y2 implements Runnable { public boolean a; public String b; public Context c; public final x2 d = new x2(this); public final /* synthetic */ q2 e; public y2(q2 q2Var) { this.e = q2Var; } public final void a() { q2 q2Var = this.e; if (q2Var.f == this) { q2Var.f = null; } if (q2Var.d == 3) { this.e.a(1); } } @Override // java.lang.Runnable public final void run() { boolean a; this.e.a(3); this.c = this.e.a().a; IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"); if (Build.VERSION.SDK_INT >= 33) { this.c.registerReceiver(this.d, intentFilter, 4); } else { this.c.registerReceiver(this.d, intentFilter); } while (true) { try { CountDownLatch countDownLatch = new CountDownLatch(1); y.b.addObserver(new w2(this, countDownLatch)); v2 a2 = this.e.a(); q2 q2Var = this.e; Context context = a2.a; String str = a2.b; Hashtable hashtable = a2.c; r2 r2Var = q2Var.l; int i = r2Var.d; if (i > 5) { break; } r2Var.d = i + 1; a = super/*com.tapjoy.m1*/.a(context, str, hashtable, null); if (!a) { break; } try { countDownLatch.await(); } catch (InterruptedException e) { TapjoyLog.d("TapjoyConnectAutoRetry", e.getMessage()); } if (this.a) { this.e.a(5); this.e.c(); return; } String str2 = this.b; if (str2 != null && !str2.isEmpty()) { this.e.a(6); this.e.b(-1, this.b); return; } this.e.c(3, "Failed to connect"); q2 q2Var2 = this.e; long j = q2Var2.g * 2; q2Var2.g = j; q2Var2.g = Math.max(j, 1000L); q2 q2Var3 = this.e; q2Var3.g = Math.min(q2Var3.g, 3600000L); q2 q2Var4 = this.e; q2Var4.a(q2Var4.g); } finally { this.c.unregisterReceiver(this.d); a(); } } this.e.c(1, "Failed to connect"); } }