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

import android.os.SystemClock;
import androidx.media3.exoplayer.upstream.CmcdConfiguration;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: loaded from: classes2.dex */
public final class v31 implements n61 {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final AtomicReference f17498b = new AtomicReference(Boolean.FALSE);

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final i8.c f17499c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Executor f17500d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final n61 f17501e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final long f17502f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final cr0 f17503g;

    public v31(n61 n61Var, long j10, i8.c cVar, a30 a30Var, cr0 cr0Var) {
        this.f17499c = cVar;
        this.f17501e = n61Var;
        this.f17502f = j10;
        this.f17500d = a30Var;
        this.f17503g = cr0Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x010a  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x002d  */
    @Override // com.google.android.gms.internal.ads.n61
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final com.google.common.util.concurrent.w zza() {
        t31 t31Var;
        tn tnVar = ao.Yc;
        n7.y yVar = n7.y.f31093e;
        if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
            if (((Boolean) yVar.f31096c.b(ao.Xc)).booleanValue() && !((Boolean) this.f17498b.getAndSet(Boolean.TRUE)).booleanValue()) {
                y20 y20Var = b30.f9362d;
                u31 u31Var = new u31(this, 1);
                long j10 = this.f17502f;
                y20Var.scheduleWithFixedDelay(u31Var, j10, j10, TimeUnit.MILLISECONDS);
            }
            synchronized (this) {
                try {
                    AtomicReference atomicReference = this.f17497a;
                    t31 t31Var2 = (t31) atomicReference.get();
                    if (t31Var2 == null) {
                        com.google.common.util.concurrent.w wVarZza = this.f17501e.zza();
                        atomicReference.set(new t31(wVarZza, this.f17502f, this.f17499c));
                        return wVarZza;
                    }
                    if (!((Boolean) this.f17498b.get()).booleanValue()) {
                        ((i8.d) t31Var2.f16702c).getClass();
                        if (t31Var2.f16701b < SystemClock.elapsedRealtime()) {
                            com.google.common.util.concurrent.w wVar = t31Var2.f16700a;
                            n61 n61Var = this.f17501e;
                            t31 t31Var3 = new t31(n61Var.zza(), this.f17502f, this.f17499c);
                            this.f17497a.set(t31Var3);
                            if (((Boolean) yVar.f31096c.b(ao.Zc)).booleanValue()) {
                                if (((Boolean) yVar.f31096c.b(ao.f8775ad)).booleanValue()) {
                                    br0 br0VarA = this.f17503g.a();
                                    br0VarA.zzc("action", "scs");
                                    br0VarA.zzc(CmcdConfiguration.KEY_SESSION_ID, String.valueOf(n61Var.zzb()));
                                    br0VarA.b();
                                }
                                return wVar;
                            }
                            t31Var = t31Var3;
                        } else {
                            t31Var = t31Var2;
                        }
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        } else {
            AtomicReference atomicReference2 = this.f17497a;
            t31Var = (t31) atomicReference2.get();
            if (t31Var != null) {
                ((i8.d) t31Var.f16702c).getClass();
                if (t31Var.f16701b < SystemClock.elapsedRealtime()) {
                    n61 n61Var2 = this.f17501e;
                    t31 t31Var4 = new t31(n61Var2.zza(), this.f17502f, this.f17499c);
                    atomicReference2.set(t31Var4);
                    t31Var = t31Var4;
                }
            }
        }
        return t31Var.f16700a;
    }

    @Override // com.google.android.gms.internal.ads.n61
    public final int zzb() {
        return this.f17501e.zzb();
    }
}
