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

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.IBinder;
import android.os.SystemClock;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import java.util.Iterator;

/* JADX INFO: loaded from: classes2.dex */
public final class jd1 implements id1 {

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

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final int f12830p;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public long f12816b = 0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public long f12817c = -1;

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

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f12831q = 2;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f12832r = 2;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f12819e = 0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public String f12820f = "";

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public String f12821g = "";

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public String f12822h = "";

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public String f12823i = "";

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public zzfot f12824j = zzfot.SCAR_REQUEST_TYPE_UNSPECIFIED;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public String f12825k = "";

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public String f12826l = "";

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public String f12827m = "";

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

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

    public jd1(Context context, int i10) {
        this.f12815a = context;
        this.f12830p = i10;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 a(boolean z10) {
        synchronized (this) {
            this.f12818d = z10;
        }
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 b(Throwable th) {
        synchronized (this) {
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.U9)).booleanValue()) {
                String strZzg = q7.e.zzg(dz.f(th));
                if (strZzg == null) {
                    strZzg = "";
                }
                this.f12826l = strZzg;
                String strF = dz.f(th);
                ru ruVarC = ru.c(new kq1('\n'));
                strF.getClass();
                this.f12825k = (String) new rq1(ruVarC, strF).iterator().next();
            }
        }
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 c(zzfot zzfotVar) {
        synchronized (this) {
            this.f12824j = zzfotVar;
        }
        return this;
    }

    /* JADX WARN: Code restructure failed: missing block: B:13:0x002a, code lost:
    
        r2.f12821g = r0;
     */
    @Override // com.google.android.gms.internal.ads.id1
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final id1 e(db1 db1Var) {
        synchronized (this) {
            try {
                String str = db1Var.f10364b.f19181b;
                if (!TextUtils.isEmpty(str)) {
                    this.f12820f = str;
                }
                Iterator it = db1Var.f10363a.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    }
                    String str2 = ((wa1) it.next()).Y;
                    if (!TextUtils.isEmpty(str2)) {
                        break;
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 g(n7.l2 l2Var) {
        synchronized (this) {
            try {
                IBinder iBinder = l2Var.zze;
                if (iBinder != null) {
                    oe0 oe0Var = (oe0) iBinder;
                    String strZzk = oe0Var.zzk();
                    if (!TextUtils.isEmpty(strZzk)) {
                        this.f12820f = strZzk;
                    }
                    String strZzf = oe0Var.zzf();
                    if (!TextUtils.isEmpty(strZzf)) {
                        this.f12821g = strZzf;
                    }
                }
            } finally {
            }
        }
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 h(int i10) {
        synchronized (this) {
            this.f12831q = i10;
        }
        return this;
    }

    public final synchronized void i() {
        Configuration configuration;
        m7.n nVar = m7.n.C;
        p7.t0 t0Var = nVar.f30467f;
        Context context = this.f12815a;
        this.f12819e = t0Var.f(context);
        Resources resources = context.getResources();
        int i10 = 2;
        if (resources != null && (configuration = resources.getConfiguration()) != null) {
            i10 = configuration.orientation == 2 ? 4 : 3;
        }
        this.f12832r = i10;
        nVar.f30472k.getClass();
        this.f12816b = SystemClock.elapsedRealtime();
        this.f12829o = true;
    }

    public final synchronized void j() {
        m7.n.C.f30472k.getClass();
        this.f12817c = SystemClock.elapsedRealtime();
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final /* bridge */ /* synthetic */ id1 zza() {
        i();
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final synchronized boolean zzb() {
        return this.f12829o;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final /* bridge */ /* synthetic */ id1 zzc() {
        j();
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 zze(String str) {
        synchronized (this) {
            this.f12823i = str;
        }
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 zzi(String str) {
        synchronized (this) {
            this.f12822h = str;
        }
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final id1 zzk(String str) {
        synchronized (this) {
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.U9)).booleanValue()) {
                this.f12827m = str;
            }
        }
        return this;
    }

    @Override // com.google.android.gms.internal.ads.id1
    public final boolean zzl() {
        return !TextUtils.isEmpty(this.f12822h);
    }

    @Override // com.google.android.gms.internal.ads.id1
    @Nullable
    public final synchronized kd1 zzm() {
        try {
            if (this.f12828n) {
                return null;
            }
            this.f12828n = true;
            if (!this.f12829o) {
                i();
            }
            if (this.f12817c < 0) {
                j();
            }
            return new kd1(this);
        } catch (Throwable th) {
            throw th;
        }
    }
}
