package g.i0.f;

import g.g0;
import g.n;
import g.s;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class f {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final g.a f6185a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final g.d f6187c;

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public List<Proxy> f6189e;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public List<InetSocketAddress> f6191g = Collections.emptyList();

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final List<g0> f6192h = new ArrayList();

    public static final class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final List<g0> f6193a;

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

        public a(List<g0> list) {
            this.f6193a = list;
        }

        public boolean a() {
            return this.f6194b < this.f6193a.size();
        }
    }

    public f(g.a aVar, d dVar, g.d dVar2, n nVar) {
        List<Proxy> listO;
        this.f6189e = Collections.emptyList();
        this.f6185a = aVar;
        this.f6186b = dVar;
        this.f6187c = dVar2;
        this.f6188d = nVar;
        s sVar = aVar.f6062a;
        Proxy proxy = aVar.f6069h;
        if (proxy != null) {
            listO = Collections.singletonList(proxy);
        } else {
            List<Proxy> listSelect = aVar.f6068g.select(sVar.q());
            listO = (listSelect == null || listSelect.isEmpty()) ? g.i0.c.o(Proxy.NO_PROXY) : g.i0.c.n(listSelect);
        }
        this.f6189e = listO;
        this.f6190f = 0;
    }

    public void a(g0 g0Var, IOException iOException) {
        g.a aVar;
        ProxySelector proxySelector;
        if (g0Var.f6130b.type() != Proxy.Type.DIRECT && (proxySelector = (aVar = this.f6185a).f6068g) != null) {
            proxySelector.connectFailed(aVar.f6062a.q(), g0Var.f6130b.address(), iOException);
        }
        d dVar = this.f6186b;
        synchronized (dVar) {
            dVar.f6182a.add(g0Var);
        }
    }

    public boolean b() {
        return c() || !this.f6192h.isEmpty();
    }

    public final boolean c() {
        return this.f6190f < this.f6189e.size();
    }
}
