package com.google.android.gms.ads.internal.overlay;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.view.textclassifier.TextClassifier;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.Toolbar;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.gms.internal.ads.ao;
import com.google.android.gms.internal.ads.aw0;
import com.google.android.gms.internal.ads.br0;
import com.google.android.gms.internal.ads.bw0;
import com.google.android.gms.internal.ads.c60;
import com.google.android.gms.internal.ads.cf0;
import com.google.android.gms.internal.ads.cr0;
import com.google.android.gms.internal.ads.d70;
import com.google.android.gms.internal.ads.fk0;
import com.google.android.gms.internal.ads.h60;
import com.google.android.gms.internal.ads.il;
import com.google.android.gms.internal.ads.iy;
import com.google.android.gms.internal.ads.js;
import com.google.android.gms.internal.ads.ks;
import com.google.android.gms.internal.ads.mw0;
import com.google.android.gms.internal.ads.oy;
import com.google.android.gms.internal.ads.pw0;
import com.google.android.gms.internal.ads.rw0;
import com.google.android.gms.internal.ads.sw0;
import com.google.android.gms.internal.ads.tn;
import com.google.android.gms.internal.ads.x50;
import com.google.android.gms.internal.ads.yn;
import com.google.android.gms.internal.ads.zv1;
import com.google.android.gms.internal.ads.zzfsm;
import e.s0;
import java.util.Collections;
import java.util.concurrent.ScheduledFuture;
import n7.x;
import n7.y;
import okhttp3.internal.http2.Http2Connection;
import p7.l0;
import p7.r0;
import xyz.stream.utils.a0;

/* JADX INFO: loaded from: classes2.dex */
public abstract class l extends oy implements f {
    public static final int Z = Color.argb(0, 0, 0, 0);
    public s0 R;
    public boolean S;
    public boolean T;
    public Toolbar X;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Activity f7928b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public x50 f7929c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public j f7930d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public zzu f7931e;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public FrameLayout f7933g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public WebChromeClient.CustomViewCallback f7934h;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public i f7937k;

    @Nullable
    @VisibleForTesting
    AdOverlayInfoParcel zzc;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f7932f = false;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f7935i = false;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public boolean f7936j = false;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public boolean f7938l = false;
    public int Y = 1;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final Object f7939m = new Object();
    public final e.f Q = new e.f(this);
    public boolean U = false;
    public boolean V = false;
    public boolean W = true;

    public l(Activity activity) {
        this.f7928b = activity;
    }

    private static final void zzL(@Nullable sw0 sw0Var, @Nullable View view) {
        if (sw0Var == null || view == null) {
            return;
        }
        if (((Boolean) y.f31093e.f31096c.b(ao.c6)).booleanValue() && sw0Var.f16603b.f16874e == zzfsm.HTML) {
            return;
        }
        m7.n.C.f30485x.c(sw0Var.f16602a, view);
    }

    public final void R2() {
        AdOverlayInfoParcel adOverlayInfoParcel;
        p pVar;
        if (!this.f7928b.isFinishing() || this.U) {
            return;
        }
        this.U = true;
        x50 x50Var = this.f7929c;
        if (x50Var != null) {
            x50Var.h0(this.Y - 1);
            synchronized (this.f7939m) {
                try {
                    if (!this.S && this.f7929c.m0()) {
                        tn tnVar = ao.O5;
                        y yVar = y.f31093e;
                        if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue() && !this.V && (adOverlayInfoParcel = this.zzc) != null && (pVar = adOverlayInfoParcel.f7890c) != null) {
                            pVar.w1();
                        }
                        s0 s0Var = new s0(this, 24);
                        this.R = s0Var;
                        r0.f31763l.postDelayed(s0Var, ((Long) yVar.f31096c.b(ao.f9111v1)).longValue());
                        return;
                    }
                } finally {
                }
            }
        }
        S2();
    }

    public final void S2() {
        x50 x50Var;
        p pVar;
        if (this.V) {
            return;
        }
        this.V = true;
        x50 x50Var2 = this.f7929c;
        if (x50Var2 != null) {
            this.f7937k.removeView(x50Var2.o());
            j jVar = this.f7930d;
            if (jVar != null) {
                this.f7929c.X(jVar.f7926d);
                this.f7929c.t0(false);
                if (((Boolean) y.f31093e.f31096c.b(ao.Td)).booleanValue() && this.f7929c.getParent() != null) {
                    ((ViewGroup) this.f7929c.getParent()).removeView(this.f7929c.o());
                }
                ViewGroup viewGroup = this.f7930d.f7925c;
                View viewO = this.f7929c.o();
                j jVar2 = this.f7930d;
                viewGroup.addView(viewO, jVar2.f7923a, jVar2.f7924b);
                this.f7930d = null;
            } else {
                Activity activity = this.f7928b;
                if (activity.getApplicationContext() != null) {
                    this.f7929c.X(activity.getApplicationContext());
                }
            }
            this.f7929c = null;
        }
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel != null && (pVar = adOverlayInfoParcel.f7890c) != null) {
            pVar.O(this.Y);
        }
        AdOverlayInfoParcel adOverlayInfoParcel2 = this.zzc;
        if (adOverlayInfoParcel2 == null || (x50Var = adOverlayInfoParcel2.f7891d) == null) {
            return;
        }
        zzL(x50Var.x(), this.zzc.f7891d.o());
    }

    public final void T2(bw0 bw0Var) throws zzh {
        iy iyVar;
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel == null || (iyVar = adOverlayInfoParcel.Y) == null) {
            throw new zzh("noioou");
        }
        iyVar.F(new k8.b(bw0Var));
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x002e  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x0117  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x012c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void U2(Configuration configuration) {
        boolean zIsInMultiWindowMode;
        boolean z10;
        boolean z11;
        m7.h hVar;
        int i10;
        int i11;
        m7.h hVar2;
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        boolean z12 = true;
        boolean z13 = (adOverlayInfoParcel == null || (hVar2 = adOverlayInfoParcel.R) == null || !hVar2.f30446b) ? false : true;
        m7.n.C.f30467f.getClass();
        tn tnVar = ao.P5;
        y yVar = y.f31093e;
        boolean zBooleanValue = ((Boolean) yVar.f31096c.b(tnVar)).booleanValue();
        yn ynVar = yVar.f31096c;
        Activity activity = this.f7928b;
        if (zBooleanValue) {
            if (((Boolean) ynVar.b(ao.R5)).booleanValue()) {
                zIsInMultiWindowMode = activity.isInMultiWindowMode();
            } else {
                q7.e eVar = x.f31085g.f31086a;
                int iG = q7.e.g(activity.getResources().getDisplayMetrics(), configuration.screenHeightDp);
                int iG2 = q7.e.g(activity.getResources().getDisplayMetrics(), configuration.screenWidthDp);
                WindowManager windowManager = (WindowManager) activity.getApplicationContext().getSystemService("window");
                DisplayMetrics displayMetrics = new DisplayMetrics();
                windowManager.getDefaultDisplay().getMetrics(displayMetrics);
                int i12 = displayMetrics.heightPixels;
                int i13 = displayMetrics.widthPixels;
                int identifier = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
                int dimensionPixelSize = identifier > 0 ? activity.getResources().getDimensionPixelSize(identifier) : 0;
                int iIntValue = ((Integer) ynVar.b(ao.N5)).intValue() * ((int) Math.round(((double) activity.getResources().getDisplayMetrics().density) + 0.5d));
                zIsInMultiWindowMode = Math.abs(i12 - (iG + dimensionPixelSize)) > iIntValue || Math.abs(i13 - iG2) > iIntValue;
            }
        }
        if ((!this.f7936j || z13 || ((Boolean) ynVar.b(ao.f8813d1)).booleanValue()) && (!zIsInMultiWindowMode || ((Boolean) ynVar.b(ao.f8797c1)).booleanValue())) {
            AdOverlayInfoParcel adOverlayInfoParcel2 = this.zzc;
            if (adOverlayInfoParcel2 == null || (hVar = adOverlayInfoParcel2.R) == null || !hVar.f30451g) {
                z10 = true;
                z11 = false;
                Window window = activity.getWindow();
                if (!((Boolean) ynVar.b(ao.C1)).booleanValue()) {
                    View decorView = window.getDecorView();
                    if (z10) {
                        i11 = z11 ? 5894 : 5380;
                    } else {
                        i11 = 256;
                        z12 = false;
                    }
                    decorView.setSystemUiVisibility(i11);
                } else if (z10) {
                    window.addFlags(1024);
                    window.clearFlags(2048);
                    if (z11) {
                        window.getDecorView().setSystemUiVisibility(4098);
                    }
                } else {
                    window.addFlags(2048);
                    window.clearFlags(1024);
                    z12 = false;
                }
                if (((Boolean) ynVar.b(ao.Ge)).booleanValue() || (i10 = Build.VERSION.SDK_INT) > 34 || i10 < 28 || !z12) {
                    return;
                }
                window.getAttributes().layoutInDisplayCutoutMode = 1;
                o6.b.B(window, false);
                return;
            }
            z10 = true;
        } else {
            z10 = false;
        }
        z11 = z10;
        Window window2 = activity.getWindow();
        if (!((Boolean) ynVar.b(ao.C1)).booleanValue()) {
        }
        if (((Boolean) ynVar.b(ao.Ge)).booleanValue()) {
        }
    }

    public final void V2(ViewGroup viewGroup) {
        sw0 sw0VarX;
        rw0 rw0VarA0;
        x50 x50Var = this.f7929c;
        if (x50Var == null) {
            return;
        }
        tn tnVar = ao.f8818d6;
        y yVar = y.f31093e;
        if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue() && (rw0VarA0 = x50Var.a0()) != null) {
            rw0VarA0.f(viewGroup);
        } else if (((Boolean) yVar.f31096c.b(ao.c6)).booleanValue() && (sw0VarX = x50Var.x()) != null && sw0VarX.f16603b.f16874e == zzfsm.HTML) {
            m7.n.C.f30485x.getClass();
            pw0.g(new mw0(sw0VarX.f16602a, viewGroup, 0));
        }
    }

    public final void W2(boolean z10) {
        if (this.zzc.Z) {
            return;
        }
        tn tnVar = ao.T5;
        y yVar = y.f31093e;
        int iIntValue = ((Integer) yVar.f31096c.b(tnVar)).intValue();
        boolean z11 = ((Boolean) yVar.f31096c.b(ao.f9162y1)).booleanValue() || z10;
        q qVar = new q();
        qVar.f7951a = 0;
        qVar.f7952b = 0;
        qVar.f7953c = 0;
        qVar.f7954d = 50;
        qVar.f7951a = true != z11 ? 0 : iIntValue;
        qVar.f7952b = true != z11 ? iIntValue : 0;
        qVar.f7953c = iIntValue;
        this.f7931e = new zzu(this.f7928b, qVar, this);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
        layoutParams.addRule(10);
        layoutParams.addRule(true != z11 ? 9 : 11);
        X2(z10, this.zzc.f7894g);
        this.f7937k.addView(this.f7931e, layoutParams);
        V2(this.f7931e);
    }

    public final void X2(boolean z10, boolean z11) {
        AdOverlayInfoParcel adOverlayInfoParcel;
        m7.h hVar;
        AdOverlayInfoParcel adOverlayInfoParcel2;
        m7.h hVar2;
        tn tnVar = ao.f9128w1;
        y yVar = y.f31093e;
        boolean z12 = true;
        boolean z13 = ((Boolean) yVar.f31096c.b(tnVar)).booleanValue() && (adOverlayInfoParcel2 = this.zzc) != null && (hVar2 = adOverlayInfoParcel2.R) != null && hVar2.f30452h;
        tn tnVar2 = ao.f9145x1;
        yn ynVar = yVar.f31096c;
        boolean z14 = ((Boolean) ynVar.b(tnVar2)).booleanValue() && (adOverlayInfoParcel = this.zzc) != null && (hVar = adOverlayInfoParcel.R) != null && hVar.f30453i;
        if (z10 && z11 && z13 && !z14) {
            new zv1(this.f7929c, "useCustomClose", 11).c("Custom close has been disabled for interstitial ads in this ad slot.");
        }
        zzu zzuVar = this.f7931e;
        if (zzuVar != null) {
            if (!z14 && (!z11 || z13)) {
                z12 = false;
            }
            ImageButton imageButton = zzuVar.f7957a;
            if (!z12) {
                imageButton.setVisibility(0);
                return;
            }
            imageButton.setVisibility(8);
            if (((Long) ynVar.b(ao.A1)).longValue() > 0) {
                imageButton.animate().cancel();
                imageButton.clearAnimation();
            }
        }
    }

    public final void Y2(int i10) {
        int i11;
        Activity activity = this.f7928b;
        int i12 = activity.getApplicationInfo().targetSdkVersion;
        tn tnVar = ao.L6;
        y yVar = y.f31093e;
        if (i12 >= ((Integer) yVar.f31096c.b(tnVar)).intValue()) {
            int i13 = activity.getApplicationInfo().targetSdkVersion;
            tn tnVar2 = ao.M6;
            yn ynVar = yVar.f31096c;
            if (i13 <= ((Integer) ynVar.b(tnVar2)).intValue() && (i11 = Build.VERSION.SDK_INT) >= ((Integer) ynVar.b(ao.N6)).intValue() && i11 <= ((Integer) ynVar.b(ao.O6)).intValue()) {
                return;
            }
        }
        try {
            activity.setRequestedOrientation(i10);
        } catch (Throwable th) {
            m7.n.C.f30469h.e("AdOverlay.setRequestedOrientation", th);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x002c  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0064  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void Z2(boolean z10) throws zzh {
        boolean z11;
        boolean z12;
        boolean z13;
        Activity activity;
        int i10;
        boolean z14;
        boolean z15 = this.T;
        Activity activity2 = this.f7928b;
        if (!z15) {
            activity2.requestWindowFeature(1);
        }
        Window window = activity2.getWindow();
        if (window == null) {
            throw new zzh("Invalid activity, no window available.");
        }
        x50 x50Var = this.zzc.f7891d;
        c60 c60VarZzP = x50Var != null ? x50Var.zzP() : null;
        if (c60VarZzP != null) {
            synchronized (c60VarZzP.f9750c) {
                z14 = c60VarZzP.S;
            }
            z11 = z14;
        }
        this.f7938l = false;
        if (z11) {
            int i11 = this.zzc.f7897j;
            if (i11 == 6) {
                z12 = activity2.getResources().getConfiguration().orientation == 1;
                this.f7938l = z12;
            } else if (i11 == 7) {
                z12 = activity2.getResources().getConfiguration().orientation == 2;
                this.f7938l = z12;
            }
        } else {
            z12 = false;
        }
        StringBuilder sb = new StringBuilder(String.valueOf(z12).length() + 41);
        sb.append("Delay onShow to next orientation change: ");
        sb.append(z12);
        q7.j.a(sb.toString());
        Y2(this.zzc.f7897j);
        window.setFlags(Http2Connection.OKHTTP_CLIENT_WINDOW_SIZE, Http2Connection.OKHTTP_CLIENT_WINDOW_SIZE);
        q7.j.a("Hardware acceleration on the AdActivity window enabled.");
        if (this.f7936j) {
            this.f7937k.setBackgroundColor(Z);
        } else {
            this.f7937k.setBackgroundColor(-16777216);
        }
        activity2.setContentView(this.f7937k);
        this.T = true;
        if (z10) {
            try {
                h60 h60Var = m7.n.C.f30465d;
                x50 x50Var2 = this.zzc.f7891d;
                d70 d70VarZzN = x50Var2 != null ? x50Var2.zzN() : null;
                x50 x50Var3 = this.zzc.f7891d;
                String strZzO = x50Var3 != null ? x50Var3.zzO() : null;
                AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
                q7.a aVar = adOverlayInfoParcel.f7900m;
                x50 x50Var4 = adOverlayInfoParcel.f7891d;
                z13 = z11;
                m7.a aVarZzk = x50Var4 != null ? x50Var4.zzk() : null;
                activity = activity2;
                x50 x50VarZza = h60.zza(activity2, d70VarZzN, strZzO, true, z11, null, null, aVar, null, null, aVarZzk, new il(), null, null, null, null, null);
                this.f7929c = x50VarZza;
                c60 c60VarZzP2 = x50VarZza.zzP();
                AdOverlayInfoParcel adOverlayInfoParcel2 = this.zzc;
                js jsVar = adOverlayInfoParcel2.S;
                ks ksVar = adOverlayInfoParcel2.f7892e;
                d dVar = adOverlayInfoParcel2.f7896i;
                x50 x50Var5 = adOverlayInfoParcel2.f7891d;
                c60VarZzP2.zzab(null, jsVar, null, ksVar, dVar, true, null, x50Var5 != null ? x50Var5.zzP().X : null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
                this.f7929c.zzP().f9756f = new a0(this);
                AdOverlayInfoParcel adOverlayInfoParcel3 = this.zzc;
                String str = adOverlayInfoParcel3.f7899l;
                if (str != null) {
                    this.f7929c.loadUrl(str);
                } else {
                    String str2 = adOverlayInfoParcel3.f7895h;
                    if (str2 == null) {
                        throw new zzh("No URL or HTML to display in ad overlay.");
                    }
                    this.f7929c.loadDataWithBaseURL(adOverlayInfoParcel3.f7893f, str2, "text/html", "UTF-8", null);
                }
                x50 x50Var6 = this.zzc.f7891d;
                if (x50Var6 != null) {
                    x50Var6.Z(this);
                }
            } catch (Exception e10) {
                throw new zzh("Could not obtain webview for the overlay.", e10);
            }
        } else {
            z13 = z11;
            activity = activity2;
            x50 x50Var7 = this.zzc.f7891d;
            this.f7929c = x50Var7;
            x50Var7.X(activity);
        }
        if (this.zzc.Z) {
            i10 = 0;
            CookieManager.getInstance().setAcceptThirdPartyCookies(this.f7929c.c(), false);
            tn tnVar = ao.f8978n1;
            y yVar = y.f31093e;
            if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue() && Build.VERSION.SDK_INT >= 27) {
                this.f7929c.c().setTextClassifier(TextClassifier.NO_OP);
            }
            if (((Boolean) yVar.f31096c.b(ao.f8995o1)).booleanValue()) {
                this.f7929c.c().setDownloadListener(h.f7920a);
            }
        } else {
            i10 = 0;
        }
        this.f7929c.U(this);
        x50 x50Var8 = this.zzc.f7891d;
        if (x50Var8 != null) {
            zzL(x50Var8.x(), this.f7937k);
        }
        if (this.zzc.f7898k != 5) {
            ViewParent parent = this.f7929c.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(this.f7929c.o());
            }
            if (this.f7936j) {
                this.f7929c.g0();
            }
            if (this.zzc.Z) {
                Toolbar toolbar = new Toolbar(activity);
                this.X = toolbar;
                toolbar.setId(View.generateViewId());
                this.f7929c.o().setId(View.generateViewId());
                this.X.setBackgroundColor(-12303292);
                this.X.setVisibility(i10);
                try {
                    this.X.setNavigationIcon(m7.n.C.f30469h.zzf().getDrawable(k7.a.admob_close_button_white_cross, null));
                } catch (Resources.NotFoundException | NullPointerException unused) {
                    l0.h();
                }
                this.X.setNavigationOnClickListener(this.Q);
                this.X.setTitleMarginStart(i10);
                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -2);
                layoutParams.addRule(10);
                this.f7937k.addView(this.X, layoutParams);
                RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -2);
                layoutParams2.addRule(3, this.X.getId());
                layoutParams2.addRule(12);
                this.f7937k.addView(this.f7929c.o(), layoutParams2);
                V2(this.X);
            } else {
                this.f7937k.addView(this.f7929c.o(), -1, -1);
            }
        }
        if (!z10 && !this.f7938l) {
            this.f7929c.zzI();
        }
        if (this.zzc.f7898k != 5) {
            boolean z16 = z13;
            W2(z16);
            if (this.f7929c.x0()) {
                X2(z16, true);
                return;
            }
            return;
        }
        aw0 aw0Var = new aw0();
        aw0Var.f9295a = activity;
        aw0Var.zzb(this);
        aw0Var.zzc(this.zzc.T);
        aw0Var.zzd(this.zzc.U);
        try {
            T2(aw0Var.a());
        } catch (RemoteException | zzh e11) {
            throw new zzh(e11.getMessage(), e11);
        }
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void g() {
        p pVar;
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel != null && (pVar = adOverlayInfoParcel.f7890c) != null) {
            pVar.r0();
        }
        x50 x50Var = this.f7929c;
        if (x50Var != null) {
            try {
                this.f7937k.removeView(x50Var.o());
            } catch (NullPointerException unused) {
            }
        }
        R2();
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void o0(int i10, String[] strArr, int[] iArr) {
        if (i10 == 12345) {
            aw0 aw0Var = new aw0();
            Activity activity = this.f7928b;
            if (activity == null) {
                throw new NullPointerException("Null activity");
            }
            aw0Var.f9295a = activity;
            aw0Var.zzb(this.zzc.f7898k == 5 ? this : null);
            try {
                this.zzc.Y.x1(strArr, iArr, new k8.b(aw0Var.a()));
            } catch (RemoteException unused) {
            }
        }
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void p(k8.a aVar) {
        U2((Configuration) k8.b.O(aVar));
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void u0(Bundle bundle) {
        bundle.putBoolean("com.google.android.gms.ads.internal.overlay.hasResumed", this.f7935i);
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void y0(int i10, int i11, Intent intent) {
        cr0 cr0VarG;
        AdOverlayInfoParcel adOverlayInfoParcel;
        if (i10 == 236) {
            tn tnVar = ao.f9058re;
            y yVar = y.f31093e;
            if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
                StringBuilder sb = new StringBuilder(String.valueOf(i11).length() + 66);
                sb.append("Callback from intent launch with requestCode: 236 and resultCode: ");
                sb.append(i11);
                l0.g(sb.toString());
                x50 x50Var = this.f7929c;
                if (x50Var == null || x50Var.zzP() == null || (cr0VarG = x50Var.zzP().g()) == null || (adOverlayInfoParcel = this.zzc) == null || !((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
                    return;
                }
                br0 br0VarA = cr0VarG.a();
                br0VarA.zzc("action", "hilca");
                String str = adOverlayInfoParcel.T;
                if (str == null) {
                    str = "";
                }
                br0VarA.zzc("gqi", str);
                StringBuilder sb2 = new StringBuilder(String.valueOf(i11).length());
                sb2.append(i11);
                br0VarA.zzc("hilr", sb2.toString());
                if (i11 == -1 && intent != null) {
                    String stringExtra = intent.getStringExtra("callerPackage");
                    String stringExtra2 = intent.getStringExtra("loadingStage");
                    if (stringExtra != null) {
                        br0VarA.zzc("hilcp", stringExtra);
                    }
                    if (stringExtra2 != null) {
                        br0VarA.zzc("hills", stringExtra2);
                    }
                }
                br0VarA.d();
            }
        }
    }

    public final void zzb() {
        this.Y = 3;
        Activity activity = this.f7928b;
        activity.finish();
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel == null || adOverlayInfoParcel.f7898k != 5) {
            return;
        }
        activity.overridePendingTransition(0, 0);
        x50 x50Var = this.f7929c;
        if (x50Var != null) {
            x50Var.U(null);
        }
    }

    public final void zzc() {
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel != null && this.f7932f) {
            Y2(adOverlayInfoParcel.f7897j);
        }
        if (this.f7933g != null) {
            this.f7928b.setContentView(this.f7937k);
            this.T = true;
            this.f7933g.removeAllViews();
            this.f7933g = null;
        }
        WebChromeClient.CustomViewCallback customViewCallback = this.f7934h;
        if (customViewCallback != null) {
            customViewCallback.onCustomViewHidden();
            this.f7934h = null;
        }
        this.f7932f = false;
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zze() {
        this.Y = 1;
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zzf() {
        p pVar;
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel == null || (pVar = adOverlayInfoParcel.f7890c) == null) {
            return;
        }
        pVar.Z1();
    }

    @Override // com.google.android.gms.internal.ads.py
    public final boolean zzg() {
        this.Y = 1;
        if (this.f7929c == null) {
            return true;
        }
        if (((Boolean) y.f31093e.f31096c.b(ao.f8856fa)).booleanValue() && this.f7929c.canGoBack()) {
            this.f7929c.goBack();
            return false;
        }
        boolean zU0 = this.f7929c.u0();
        if (!zU0) {
            this.f7929c.d("onbackblocked", Collections.emptyMap());
        }
        return zU0;
    }

    @Override // com.google.android.gms.internal.ads.oy, com.google.android.gms.internal.ads.py
    public void zzh(Bundle bundle) {
        p pVar;
        if (!this.T) {
            this.f7928b.requestWindowFeature(1);
        }
        this.f7935i = bundle != null && bundle.getBoolean("com.google.android.gms.ads.internal.overlay.hasResumed", false);
        try {
            Activity activity = this.f7928b;
            AdOverlayInfoParcel adOverlayInfoParcelZza = AdOverlayInfoParcel.zza(activity.getIntent());
            this.zzc = adOverlayInfoParcelZza;
            if (adOverlayInfoParcelZza == null) {
                throw new zzh("Could not get info for ad overlay.");
            }
            if (adOverlayInfoParcelZza.Z) {
                if (Build.VERSION.SDK_INT >= 28) {
                    activity.setShowWhenLocked(true);
                } else {
                    activity.getWindow().addFlags(524288);
                }
            }
            if (this.zzc.f7900m.f32214c > 7500000) {
                this.Y = 4;
            }
            if (activity.getIntent() != null) {
                this.W = activity.getIntent().getBooleanExtra("shouldCallOnOverlayOpened", true);
            }
            AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
            m7.h hVar = adOverlayInfoParcel.R;
            if (hVar != null) {
                boolean z10 = hVar.f30445a;
                this.f7936j = z10;
                if (z10) {
                    if (adOverlayInfoParcel.f7898k != 5 && hVar.f30450f != -1) {
                        new k(this).b();
                    }
                }
            } else if (adOverlayInfoParcel.f7898k == 5) {
                this.f7936j = true;
                if (adOverlayInfoParcel.f7898k != 5) {
                    new k(this).b();
                }
            } else {
                this.f7936j = false;
            }
            if (bundle == null) {
                if (this.W) {
                    cf0 cf0Var = this.zzc.W;
                    if (cf0Var != null) {
                        synchronized (cf0Var) {
                            ScheduledFuture scheduledFuture = cf0Var.f9879c;
                            if (scheduledFuture != null) {
                                scheduledFuture.cancel(true);
                            }
                        }
                    }
                    p pVar2 = this.zzc.f7890c;
                    if (pVar2 != null) {
                        pVar2.zzh();
                    }
                }
                AdOverlayInfoParcel adOverlayInfoParcel2 = this.zzc;
                if (adOverlayInfoParcel2.f7898k != 1) {
                    n7.a aVar = adOverlayInfoParcel2.f7889b;
                    if (aVar != null) {
                        aVar.onAdClicked();
                    }
                    fk0 fk0Var = this.zzc.X;
                    if (fk0Var != null) {
                        fk0Var.w();
                    }
                }
            }
            AdOverlayInfoParcel adOverlayInfoParcel3 = this.zzc;
            if (adOverlayInfoParcel3 != null && (pVar = adOverlayInfoParcel3.f7890c) != null) {
                pVar.B0();
            }
            AdOverlayInfoParcel adOverlayInfoParcel4 = this.zzc;
            i iVar = new i(activity, adOverlayInfoParcel4.Q, adOverlayInfoParcel4.f7900m.f32212a, adOverlayInfoParcel4.V);
            this.f7937k = iVar;
            iVar.setId(1000);
            m7.n.C.f30467f.d(activity);
            AdOverlayInfoParcel adOverlayInfoParcel5 = this.zzc;
            int i10 = adOverlayInfoParcel5.f7898k;
            if (i10 == 1) {
                Z2(false);
                return;
            }
            if (i10 == 2) {
                this.f7930d = new j(adOverlayInfoParcel5.f7891d);
                Z2(false);
            } else if (i10 == 3) {
                Z2(true);
            } else {
                if (i10 != 5) {
                    throw new zzh("Could not determine ad overlay type.");
                }
                Z2(false);
            }
        } catch (zzh e10) {
            q7.j.d(e10.getMessage());
            this.Y = 4;
            this.f7928b.finish();
        }
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zzi() {
        p pVar;
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel == null || (pVar = adOverlayInfoParcel.f7890c) == null) {
            return;
        }
        pVar.M();
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zzj() {
        p pVar;
        if (((Boolean) y.f31093e.f31096c.b(ao.Q5)).booleanValue()) {
            x50 x50Var = this.f7929c;
            if (x50Var == null || x50Var.K()) {
                q7.j.d("The webview does not exist. Ignoring action.");
            } else {
                this.f7929c.onResume();
            }
        }
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel == null || (pVar = adOverlayInfoParcel.f7890c) == null) {
            return;
        }
        pVar.b1();
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zzk() {
        p pVar;
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel != null && (pVar = adOverlayInfoParcel.f7890c) != null) {
            pVar.i1();
        }
        U2(this.f7928b.getResources().getConfiguration());
        if (((Boolean) y.f31093e.f31096c.b(ao.Q5)).booleanValue()) {
            return;
        }
        x50 x50Var = this.f7929c;
        if (x50Var == null || x50Var.K()) {
            q7.j.d("The webview does not exist. Ignoring action.");
        } else {
            this.f7929c.onResume();
        }
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zzl() {
        p pVar;
        zzc();
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel != null && (pVar = adOverlayInfoParcel.f7890c) != null) {
            pVar.O0();
        }
        if (!((Boolean) y.f31093e.f31096c.b(ao.Q5)).booleanValue() && this.f7929c != null && (!this.f7928b.isFinishing() || this.f7930d == null)) {
            this.f7929c.onPause();
        }
        R2();
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zzp() {
        p pVar;
        AdOverlayInfoParcel adOverlayInfoParcel = this.zzc;
        if (adOverlayInfoParcel != null && (pVar = adOverlayInfoParcel.f7890c) != null) {
            pVar.W();
        }
        if (((Boolean) y.f31093e.f31096c.b(ao.Q5)).booleanValue() && this.f7929c != null && (!this.f7928b.isFinishing() || this.f7930d == null)) {
            this.f7929c.onPause();
        }
        R2();
    }

    @Override // com.google.android.gms.internal.ads.py
    public final void zzs() {
        this.T = true;
    }
}
