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

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

/* JADX INFO: loaded from: classes2.dex */
public final class ub1 implements xe0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final HashSet f17199a = new HashSet();

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final v20 f17201c;

    public ub1(Context context, v20 v20Var) {
        this.f17200b = context;
        this.f17201c = v20Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:77:0x00ce A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Bundle a() {
        String str;
        Bundle bundle;
        int identifier;
        boolean z10;
        int i10;
        Bundle bundle2;
        v20 v20Var = this.f17201c;
        Context context = this.f17200b;
        v20Var.getClass();
        HashSet<o20> hashSet = new HashSet();
        synchronized (v20Var.f17479a) {
            HashSet hashSet2 = v20Var.f17483e;
            hashSet.addAll(hashSet2);
            hashSet2.clear();
        }
        Bundle bundle3 = new Bundle();
        t20 t20Var = v20Var.f17482d;
        u20 u20Var = v20Var.f17481c;
        synchronized (u20Var) {
            str = u20Var.f17066b;
        }
        synchronized (t20Var.f16680f) {
            try {
                bundle = new Bundle();
                if (!((p7.o0) t20Var.f16683i).C()) {
                    bundle.putString("session_id", t20Var.f16682h);
                }
                bundle.putLong("basets", t20Var.f16676b);
                bundle.putLong("currts", t20Var.f16675a);
                bundle.putString("seq_num", str);
                bundle.putInt("preqs", t20Var.f16677c);
                bundle.putInt("preqs_in_session", t20Var.f16678d);
                bundle.putLong("time_in_session", t20Var.f16679e);
                bundle.putInt("pclick", t20Var.f16684j);
                bundle.putInt("pimp", t20Var.f16685k);
                int i11 = c00.f9688a;
                Context applicationContext = context.getApplicationContext();
                if (applicationContext != null) {
                    context = applicationContext;
                }
                identifier = context.getResources().getIdentifier("Theme.Translucent", "style", "android");
            } catch (PackageManager.NameNotFoundException unused) {
                q7.j.d("Fail to fetch AdActivity theme");
                q7.j.c("Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.");
            } finally {
            }
            if (identifier == 0) {
                q7.j.c("Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.");
            } else {
                if (identifier == context.getPackageManager().getActivityInfo(new ComponentName(context.getPackageName(), "com.google.android.gms.ads.AdActivity"), 0).theme) {
                    z10 = true;
                    bundle.putBoolean("support_transparent_background", z10);
                    synchronized (t20Var.f16680f) {
                        i10 = t20Var.f16686l;
                    }
                    bundle.putInt("consent_form_action_identifier", i10);
                } else {
                    q7.j.c("Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.");
                }
            }
            z10 = false;
            bundle.putBoolean("support_transparent_background", z10);
            synchronized (t20Var.f16680f) {
            }
        }
        bundle3.putBundle("app", bundle);
        Bundle bundle4 = new Bundle();
        Iterator it = v20Var.f17484f.iterator();
        if (it.hasNext()) {
            com.google.android.gms.measurement.internal.u1.x(it.next());
            throw null;
        }
        bundle3.putBundle("slots", bundle4);
        ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
        for (o20 o20Var : hashSet) {
            synchronized (o20Var.f14812d) {
                try {
                    bundle2 = new Bundle();
                    bundle2.putString("seq_num", o20Var.f14813e);
                    bundle2.putString("slotid", o20Var.f14814f);
                    bundle2.putBoolean("ismediation", false);
                    bundle2.putLong("treq", o20Var.f14818j);
                    bundle2.putLong("tresponse", o20Var.f14819k);
                    bundle2.putLong("timp", o20Var.f14815g);
                    bundle2.putLong("tload", o20Var.f14816h);
                    bundle2.putLong("pcc", o20Var.f14817i);
                    bundle2.putLong("tfetch", -1L);
                    ArrayList<? extends Parcelable> arrayList2 = new ArrayList<>();
                    for (n20 n20Var : o20Var.f14811c) {
                        n20Var.getClass();
                        Bundle bundle5 = new Bundle();
                        bundle5.putLong("topen", n20Var.f14413a);
                        bundle5.putLong("tclose", n20Var.f14414b);
                        arrayList2.add(bundle5);
                    }
                    bundle2.putParcelableArrayList("tclick", arrayList2);
                } finally {
                }
            }
            arrayList.add(bundle2);
        }
        bundle3.putParcelableArrayList("ads", arrayList);
        synchronized (this) {
            HashSet hashSet3 = this.f17199a;
            hashSet3.clear();
            hashSet3.addAll(hashSet);
        }
        return bundle3;
    }

    @Override // com.google.android.gms.internal.ads.xe0
    public final synchronized void q(n7.l2 l2Var) {
        if (l2Var.f30997a != 3) {
            v20 v20Var = this.f17201c;
            HashSet hashSet = this.f17199a;
            synchronized (v20Var.f17479a) {
                v20Var.f17483e.addAll(hashSet);
            }
        }
    }
}
