package t4;

import androidx.recyclerview.widget.i0;
import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicLong;

/* JADX INFO: loaded from: classes3.dex */
public final class k {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public o f24327a;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Long f24330d;

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public volatile i0 f24328b = new i0(16);

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public i0 f24329c = new i0(16);

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

    public k(o oVar) {
        this.f24327a = oVar;
    }

    public final void a(s sVar) {
        if (d() && !sVar.f24355c) {
            sVar.t();
        } else if (!d() && sVar.f24355c) {
            sVar.f24355c = false;
            k4.r rVar = sVar.f24356d;
            if (rVar != null) {
                sVar.f24357e.a(rVar);
                sVar.f24358f.g(2, "Subchannel unejected: {0}", sVar);
            }
        }
        sVar.f24354b = this;
        this.f24332f.add(sVar);
    }

    public final void b(long j4) {
        this.f24330d = Long.valueOf(j4);
        this.f24331e++;
        Iterator it = this.f24332f.iterator();
        while (it.hasNext()) {
            ((s) it.next()).t();
        }
    }

    public final long c() {
        return ((AtomicLong) this.f24329c.f13106c).get() + ((AtomicLong) this.f24329c.f13105b).get();
    }

    public final boolean d() {
        return this.f24330d != null;
    }

    public final void e() {
        A4.g.t(this.f24330d != null, "not currently ejected");
        this.f24330d = null;
        for (s sVar : this.f24332f) {
            sVar.f24355c = false;
            k4.r rVar = sVar.f24356d;
            if (rVar != null) {
                sVar.f24357e.a(rVar);
                sVar.f24358f.g(2, "Subchannel unejected: {0}", sVar);
            }
        }
    }

    public final String toString() {
        return "AddressTracker{subchannels=" + this.f24332f + '}';
    }
}
