package m4;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import k4.AbstractC2384C;
import k4.AbstractC2395h;
import k4.C2387F;
import k4.C2389b;
import k4.EnumC2386E;

/* JADX INFO: loaded from: classes3.dex */
public final class R0 extends AbstractC2384C {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final k4.N f20740a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final k4.J f20741b;

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public C2548u0 f20745f;

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f20747h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public androidx.recyclerview.widget.i0 f20748i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ S0 f20749j;

    public R0(S0 s02, k4.N n6) {
        this.f20749j = s02;
        List list = n6.f19815b;
        this.f20744e = list;
        Logger logger = S0.f20758d0;
        s02.getClass();
        this.f20740a = n6;
        k4.J j4 = new k4.J("Subchannel", s02.f20807t.f20719b, k4.J.f19806d.incrementAndGet());
        this.f20741b = j4;
        i2 i2Var = s02.l;
        C2530o c2530o = new C2530o(j4, i2Var.e(), "Subchannel for " + list);
        this.f20743d = c2530o;
        this.f20742c = new C2524m(c2530o, i2Var);
    }

    @Override // k4.AbstractC2384C
    public final C2389b b() {
        return this.f20740a.f19816c;
    }

    @Override // k4.AbstractC2384C
    public final List h() {
        this.f20749j.f20800m.d();
        A4.g.t(this.f20746g, "not started");
        return this.f20744e;
    }

    @Override // k4.AbstractC2384C
    public final AbstractC2395h i() {
        return this.f20742c;
    }

    @Override // k4.AbstractC2384C
    public final Object j() {
        A4.g.t(this.f20746g, "Subchannel is not started");
        return this.f20745f;
    }

    @Override // k4.AbstractC2384C
    public final void n() {
        this.f20749j.f20800m.d();
        A4.g.t(this.f20746g, "not started");
        C2548u0 c2548u0 = this.f20745f;
        if (c2548u0.f21192v != null) {
            return;
        }
        c2548u0.f21182k.execute(new RunnableC2525m0(c2548u0, 1));
    }

    @Override // k4.AbstractC2384C
    public final void o() {
        androidx.recyclerview.widget.i0 i0Var;
        S0 s02 = this.f20749j;
        s02.f20800m.d();
        if (this.f20745f == null) {
            this.f20747h = true;
            return;
        }
        if (!this.f20747h) {
            this.f20747h = true;
        } else {
            if (!s02.f20770I || (i0Var = this.f20748i) == null) {
                return;
            }
            i0Var.d();
            this.f20748i = null;
        }
        if (!s02.f20770I) {
            this.f20748i = s02.f20800m.c(new B0(new I2.K(this, 10)), 5L, TimeUnit.SECONDS, s02.f20794f.f21089a.f21653d);
            return;
        }
        C2548u0 c2548u0 = this.f20745f;
        k4.r0 r0Var = S0.g0;
        c2548u0.getClass();
        c2548u0.f21182k.execute(new RunnableC2528n0(c2548u0, r0Var, 0));
    }

    @Override // k4.AbstractC2384C
    public final void q(k4.S s6) {
        S0 s02 = this.f20749j;
        s02.f20800m.d();
        A4.g.t(!this.f20746g, "already started");
        A4.g.t(!this.f20747h, "already shutdown");
        A4.g.t(!s02.f20770I, "Channel is being terminated");
        this.f20746g = true;
        List list = this.f20740a.f19815b;
        String str = s02.f20807t.f20719b;
        C2521l c2521l = s02.f20794f;
        ScheduledExecutorService scheduledExecutorService = c2521l.f21089a.f21653d;
        k2 k2Var = new k2(3, this, s6);
        s02.f20773L.getClass();
        C2548u0 c2548u0 = new C2548u0(list, str, s02.f20806s, c2521l, scheduledExecutorService, s02.f20803p, s02.f20800m, k2Var, s02.f20777P, new C0.J(13), this.f20743d, this.f20741b, this.f20742c, s02.f20808u);
        s02.f20775N.b(new C2387F("Child Subchannel started", EnumC2386E.f19792a, s02.l.e(), c2548u0));
        this.f20745f = c2548u0;
        s02.f20762A.add(c2548u0);
    }

    @Override // k4.AbstractC2384C
    public final void r(List list) {
        this.f20749j.f20800m.d();
        this.f20744e = list;
        C2548u0 c2548u0 = this.f20745f;
        c2548u0.getClass();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            A4.g.o(it.next(), "newAddressGroups contains null entry");
        }
        A4.g.l(!list.isEmpty(), "newAddressGroups is empty");
        c2548u0.f21182k.execute(new E(14, c2548u0, Collections.unmodifiableList(new ArrayList(list))));
    }

    public final String toString() {
        return this.f20741b.toString();
    }
}
