package com.applovin.impl.sdk; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import com.applovin.impl.e4; import com.applovin.impl.go; import com.applovin.impl.sdk.AppLovinBroadcastManager; import com.applovin.impl.sdk.h; import com.applovin.impl.sj; import com.applovin.sdk.AppLovinSdkUtils; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes2.dex */ class h implements AppLovinBroadcastManager.Receiver { private static AlertDialog c; private static final AtomicBoolean d = new AtomicBoolean(); private final i a; private go b; public interface a { void a(); void b(); } public h(i iVar, j jVar) { this.a = iVar; AppLovinBroadcastManager.registerReceiver(this, new IntentFilter(SessionTracker.ACTION_APPLICATION_PAUSED)); AppLovinBroadcastManager.registerReceiver(this, new IntentFilter(SessionTracker.ACTION_APPLICATION_RESUMED)); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void b(final j jVar, final a aVar) { if (this.a.f()) { jVar.J(); if (n.a()) { jVar.J().b("ConsentAlertManager", "Consent dialog already showing, skip showing of consent alert"); return; } return; } Activity b = jVar.e().b(); if (b != null && e4.a(j.l())) { AppLovinSdkUtils.runOnUiThread(new Runnable() { // from class: com.applovin.impl.sdk.h$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { h.this.a(jVar, aVar); } }); return; } if (b == null) { jVar.J(); if (n.a()) { jVar.J().b("ConsentAlertManager", "No parent Activity found - rescheduling consent alert..."); } } else { jVar.J(); if (n.a()) { jVar.J().b("ConsentAlertManager", "No internet available - rescheduling consent alert..."); } } d.set(false); a(((Long) jVar.a(sj.w0)).longValue(), jVar, aVar); } public void a(long j, final j jVar, final a aVar) { if (j <= 0) { return; } AlertDialog alertDialog = c; if (alertDialog == null || !alertDialog.isShowing()) { if (d.getAndSet(true)) { if (j >= this.b.c()) { jVar.J(); if (n.a()) { jVar.J().k("ConsentAlertManager", "Skip scheduling consent alert - one scheduled already with remaining time of " + this.b.c() + " milliseconds"); return; } return; } jVar.J(); if (n.a()) { jVar.J().a("ConsentAlertManager", "Scheduling consent alert earlier (" + j + "ms) than remaining scheduled time (" + this.b.c() + "ms)"); } this.b.a(); } jVar.J(); if (n.a()) { jVar.J().a("ConsentAlertManager", "Scheduling consent alert for " + j + " milliseconds"); } this.b = go.a(j, jVar, new Runnable() { // from class: com.applovin.impl.sdk.h$$ExternalSyntheticLambda1 @Override // java.lang.Runnable public final void run() { h.this.b(jVar, aVar); } }); } } @Override // com.applovin.impl.sdk.AppLovinBroadcastManager.Receiver public void onReceive(Intent intent, Map map) { if (this.b == null) { return; } String action = intent.getAction(); if (SessionTracker.ACTION_APPLICATION_PAUSED.equals(action)) { this.b.d(); } else if (SessionTracker.ACTION_APPLICATION_RESUMED.equals(action)) { this.b.e(); } } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(final j jVar, final a aVar) { AlertDialog create = new AlertDialog.Builder(jVar.e().b()).setTitle((CharSequence) jVar.a(sj.x0)).setMessage((CharSequence) jVar.a(sj.y0)).setCancelable(false).setPositiveButton((CharSequence) jVar.a(sj.z0), new DialogInterface.OnClickListener() { // from class: com.applovin.impl.sdk.h$$ExternalSyntheticLambda2 @Override // android.content.DialogInterface.OnClickListener public final void onClick(DialogInterface dialogInterface, int i) { h.a(h.a.this, dialogInterface, i); } }).setNegativeButton((CharSequence) jVar.a(sj.A0), new DialogInterface.OnClickListener() { // from class: com.applovin.impl.sdk.h$$ExternalSyntheticLambda3 @Override // android.content.DialogInterface.OnClickListener public final void onClick(DialogInterface dialogInterface, int i) { h.this.a(aVar, jVar, dialogInterface, i); } }).create(); c = create; create.show(); } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ void a(a aVar, DialogInterface dialogInterface, int i) { aVar.b(); dialogInterface.dismiss(); d.set(false); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(a aVar, j jVar, DialogInterface dialogInterface, int i) { aVar.a(); dialogInterface.dismiss(); d.set(false); a(((Long) jVar.a(sj.v0)).longValue(), jVar, aVar); } }