package com.applovin.adview; import android.R; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; import android.os.Process; import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; import android.webkit.WebView; import android.window.OnBackInvokedCallback; import android.window.OnBackInvokedDispatcher; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.view.ViewCompat; import com.applovin.impl.adview.activity.FullscreenAdService; import com.applovin.impl.ma; import com.applovin.impl.p9; import com.applovin.impl.r; import com.applovin.impl.s; import com.applovin.impl.sdk.j; import com.applovin.impl.sdk.n; import com.applovin.impl.sdk.utils.CollectionUtils; import com.applovin.impl.sdk.utils.JsonUtils; import com.applovin.impl.sdk.utils.StringUtils; import com.applovin.impl.sj; import com.applovin.impl.t6; import com.applovin.impl.tb; import com.applovin.impl.u9; import com.applovin.impl.uj; import com.applovin.impl.x1; import com.applovin.impl.yp; import com.applovin.impl.z3; import com.applovin.sdk.AppLovinSdk; import com.applovin.sdk.AppLovinSdkSettings; import com.ironsource.v8; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import org.json.JSONObject; /* loaded from: classes.dex */ public class AppLovinFullscreenActivity extends Activity implements t6 { @SuppressLint({"StaticFieldLeak"}) public static tb parentInterstitialWrapper; private j a; private p9 b; private final AtomicBoolean c = new AtomicBoolean(true); private com.applovin.impl.adview.activity.a d; private b f; private boolean g; private x1 h; private long i; public static class b implements OnBackInvokedCallback { private final Runnable a; public b(Runnable runnable) { this.a = runnable; } public void onBackInvoked() { this.a.run(); } } private void b() { j jVar = this.a; if (jVar == null || !((Boolean) jVar.a(sj.v2)).booleanValue()) { return; } final Long l = (Long) this.a.a(sj.w2); this.h = x1.a(l.longValue(), true, this.a, new Runnable() { // from class: com.applovin.adview.AppLovinFullscreenActivity$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { AppLovinFullscreenActivity.this.a(l); } }); } @Override // com.applovin.impl.t6 public void dismiss() { OnBackInvokedDispatcher onBackInvokedDispatcher; if (z3.l() && this.f != null) { onBackInvokedDispatcher = getOnBackInvokedDispatcher(); onBackInvokedDispatcher.unregisterOnBackInvokedCallback(this.f); this.f = null; } p9 p9Var = this.b; if (p9Var != null) { p9Var.f(); } else { finish(); } } @Override // android.app.Activity public void onBackPressed() { c(); } @Override // android.app.Activity, android.content.ComponentCallbacks public void onConfigurationChanged(@NonNull Configuration configuration) { super.onConfigurationChanged(configuration); p9 p9Var = this.b; if (p9Var != null) { p9Var.a(configuration); } } @Override // android.app.Activity public void onCreate(@Nullable Bundle bundle) { OnBackInvokedDispatcher onBackInvokedDispatcher; super.onCreate(bundle); if (bundle != null && parentInterstitialWrapper == null) { n.j("AppLovinFullscreenActivity", "Dismissing ad. Activity was destroyed while in background."); dismiss(); return; } try { requestWindowFeature(1); } catch (Throwable th) { n.c("AppLovinFullscreenActivity", "Failed to request window feature", th); } getWindow().setFlags(1024, 1024); getWindow().addFlags(16777216); getWindow().addFlags(128); View findViewById = findViewById(R.id.content); findViewById.setBackgroundColor(ViewCompat.MEASURED_STATE_MASK); String stringExtra = getIntent().getStringExtra("com.applovin.interstitial.sdk_key"); if (TextUtils.isEmpty(stringExtra)) { tb tbVar = parentInterstitialWrapper; if (tbVar != null && tbVar.f() != null) { tb.a(parentInterstitialWrapper.f(), parentInterstitialWrapper.c(), "Empty SDK key", null, this); } finish(); return; } j a2 = AppLovinSdk.getInstance(stringExtra, new AppLovinSdkSettings(this), this).a(); this.a = a2; this.g = ((Boolean) a2.a(sj.N2)).booleanValue(); findViewById.setFitsSystemWindows(true); r.a(this.g, this); if (z3.l() && ((Boolean) this.a.a(sj.c6)).booleanValue()) { this.f = new b(new Runnable() { // from class: com.applovin.adview.AppLovinFullscreenActivity$$ExternalSyntheticLambda1 @Override // java.lang.Runnable public final void run() { AppLovinFullscreenActivity.this.c(); } }); onBackInvokedDispatcher = getOnBackInvokedDispatcher(); onBackInvokedDispatcher.registerOnBackInvokedCallback(0, this.f); } a(); b(); tb tbVar2 = parentInterstitialWrapper; if (tbVar2 != null) { p9.a(tbVar2.f(), parentInterstitialWrapper.b(), parentInterstitialWrapper.c(), parentInterstitialWrapper.d(), parentInterstitialWrapper.h(), this.a, this, new a()); return; } Intent intent = new Intent(this, (Class) FullscreenAdService.class); com.applovin.impl.adview.activity.a aVar = new com.applovin.impl.adview.activity.a(this, this.a); this.d = aVar; bindService(intent, aVar, 1); if (z3.j()) { String str = this.a.g0().getExtraParameters().get("disable_set_data_dir_suffix"); if (StringUtils.isValidString(str) && Boolean.parseBoolean(str)) { return; } try { WebView.setDataDirectorySuffix(String.valueOf(Process.myPid())); } catch (Throwable unused) { } } } @Override // android.app.Activity public void onDestroy() { j jVar = this.a; if (jVar != null && ((Boolean) jVar.a(sj.u2)).booleanValue()) { this.a.i0().b(uj.L); this.a.i0().b(uj.N); this.a.i0().b(uj.O); } if (this.h != null) { this.a.i0().b(uj.M); this.h.a(); this.h = null; } com.applovin.impl.adview.activity.a aVar = this.d; if (aVar != null) { try { unbindService(aVar); } catch (Throwable unused) { } } p9 p9Var = this.b; if (p9Var != null) { if (!p9Var.j()) { this.b.f(); } this.b.t(); } parentInterstitialWrapper = null; super.onDestroy(); } @Override // android.app.Activity public void onPause() { super.onPause(); p9 p9Var = this.b; if (p9Var != null) { p9Var.u(); } } @Override // android.app.Activity public void onResume() { p9 p9Var; try { super.onResume(); if (this.c.get() || (p9Var = this.b) == null) { return; } p9Var.v(); } catch (IllegalArgumentException e) { this.a.J(); if (n.a()) { this.a.J().a("AppLovinFullscreenActivity", "Error was encountered in onResume().", e); } this.a.E().a("AppLovinFullscreenActivity", v8.h.u0, e); dismiss(); } } @Override // android.app.Activity public void onStop() { super.onStop(); p9 p9Var = this.b; if (p9Var != null) { p9Var.w(); } } public void setPresenter(@Nullable p9 p9Var) { this.b = p9Var; } /* JADX INFO: Access modifiers changed from: private */ public void c() { p9 p9Var = this.b; if (p9Var != null) { p9Var.s(); } if (yp.e(getApplicationContext())) { super.onBackPressed(); } } @Override // android.app.Activity, android.view.KeyEvent.Callback public boolean onKeyDown(int i, KeyEvent keyEvent) { p9 p9Var = this.b; if (p9Var != null) { p9Var.a(i, keyEvent); } return super.onKeyDown(i, keyEvent); } @Override // android.app.Activity, android.view.Window.Callback public void onWindowFocusChanged(boolean z) { if (this.b != null) { if (!this.c.getAndSet(false) || (this.b instanceof u9)) { this.b.b(z); } if (z) { r.a(this.g, this); } } super.onWindowFocusChanged(z); } private void a() { tb tbVar; j jVar = this.a; if (jVar == null || !((Boolean) jVar.a(sj.u2)).booleanValue() || (tbVar = parentInterstitialWrapper) == null || tbVar.f() == null) { return; } com.applovin.impl.sdk.ad.b f = parentInterstitialWrapper.f(); List f2 = f.f(); if (CollectionUtils.isEmpty(f2)) { return; } s sVar = (s) f2.get(0); JSONObject jSONObject = new JSONObject(); JsonUtils.putStringIfValid(jSONObject, "app_killed_postback_url", sVar.c()); JsonUtils.putStringIfValid(jSONObject, "app_killed_postback_backup_url", sVar.a()); this.a.i0().b(uj.N, jSONObject.toString()); this.a.i0().b(uj.L, Long.valueOf(System.currentTimeMillis())); this.a.i0().b(uj.O, CollectionUtils.toJsonString(ma.a(f), JsonUtils.EMPTY_JSON)); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(Long l) { this.i += l.longValue(); this.a.i0().b(uj.M, Long.valueOf(this.i)); } public class a implements p9.d { public a() { } @Override // com.applovin.impl.p9.d public void a(p9 p9Var) { AppLovinFullscreenActivity.this.b = p9Var; p9Var.y(); } @Override // com.applovin.impl.p9.d public void a(String str, Throwable th) { tb.a(AppLovinFullscreenActivity.parentInterstitialWrapper.f(), AppLovinFullscreenActivity.parentInterstitialWrapper.c(), str, th, AppLovinFullscreenActivity.this); } } }