package m4;

import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

/* JADX INFO: renamed from: m4.y0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class RunnableC2560y0 implements Runnable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f21217a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ A0 f21218b;

    public /* synthetic */ RunnableC2560y0(A0 a02, int i6) {
        this.f21217a = i6;
        this.f21218b = a02;
    }

    @Override // java.lang.Runnable
    public final void run() {
        A0 a02;
        boolean z6;
        long jNextLong;
        boolean z7 = true;
        switch (this.f21217a) {
            case 0:
                synchronized (this.f21218b) {
                    a02 = this.f21218b;
                    if (a02.f20559d != 6) {
                        a02.f20559d = 6;
                    } else {
                        z7 = false;
                    }
                    break;
                }
                if (z7) {
                    l2.c cVar = a02.f20558c;
                    cVar.getClass();
                    ((n4.n) cVar.f20267b).a(k4.r0.f19946n.g("Keepalive failed. The connection is likely gone"));
                    return;
                }
                return;
            default:
                synchronized (this.f21218b) {
                    try {
                        A0 a03 = this.f21218b;
                        a03.f20561f = null;
                        int i6 = a03.f20559d;
                        if (i6 == 2) {
                            a03.f20559d = 4;
                            a03.f20560e = a03.f20556a.schedule(a03.f20562g, a03.f20565j, TimeUnit.NANOSECONDS);
                            z6 = true;
                        } else {
                            if (i6 == 3) {
                                a03.f20561f = a03.f20556a.schedule(a03.f20563h, a03.f20564i - a03.f20557b.b(), TimeUnit.NANOSECONDS);
                                this.f21218b.f20559d = 2;
                            }
                            z6 = false;
                        }
                    } finally {
                    }
                    break;
                }
                if (z6) {
                    l2.c cVar2 = this.f21218b.f20558c;
                    cVar2.getClass();
                    C2563z0 c2563z0 = new C2563z0(cVar2);
                    n4.n nVar = (n4.n) cVar2.f20267b;
                    J3.r rVar = J3.r.f3539a;
                    synchronized (nVar.f21733k) {
                        try {
                            A4.g.s(nVar.f21731i != null);
                            if (nVar.f21746y) {
                                k4.s0 s0VarM = nVar.m();
                                Logger logger = C2519k0.f21076g;
                                try {
                                    rVar.execute(new RunnableC2516j0(c2563z0, s0VarM));
                                    break;
                                } catch (Throwable th) {
                                    C2519k0.f21076g.log(Level.SEVERE, "Failed to execute PingCallback", th);
                                }
                                return;
                            }
                            C2519k0 c2519k0 = nVar.f21745x;
                            if (c2519k0 != null) {
                                jNextLong = 0;
                                z7 = false;
                            } else {
                                jNextLong = nVar.f21726d.nextLong();
                                nVar.f21727e.getClass();
                                E3.p pVar = new E3.p(0);
                                pVar.c();
                                C2519k0 c2519k02 = new C2519k0(jNextLong, pVar);
                                nVar.f21745x = c2519k02;
                                nVar.f21719L.getClass();
                                c2519k0 = c2519k02;
                            }
                            if (z7) {
                                nVar.f21731i.c((int) (jNextLong >>> 32), (int) jNextLong, false);
                            }
                            synchronized (c2519k0) {
                                try {
                                    if (!c2519k0.f21080d) {
                                        c2519k0.f21079c.put(c2563z0, rVar);
                                        return;
                                    }
                                    k4.s0 s0Var = c2519k0.f21081e;
                                    RunnableC2516j0 runnableC2516j0 = s0Var != null ? new RunnableC2516j0(c2563z0, s0Var) : new RunnableC2516j0(c2563z0, c2519k0.f21082f);
                                    try {
                                        rVar.execute(runnableC2516j0);
                                        return;
                                    } catch (Throwable th2) {
                                        C2519k0.f21076g.log(Level.SEVERE, "Failed to execute PingCallback", th2);
                                        return;
                                    }
                                } finally {
                                }
                            }
                        } finally {
                        }
                    }
                }
                return;
        }
    }
}
