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 f6171a;

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

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

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

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

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

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

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

    public static final class a {

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

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

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

        public boolean a() {
            return this.f6180b < this.f6179a.size();
        }
    }

    public f(g.a aVar, d dVar, g.d dVar2, n nVar) {
        List<Proxy> listO;
        this.f6175e = Collections.emptyList();
        this.f6171a = aVar;
        this.f6172b = dVar;
        this.f6173c = dVar2;
        this.f6174d = nVar;
        s sVar = aVar.f6048a;
        Proxy proxy = aVar.f6055h;
        if (proxy != null) {
            listO = Collections.singletonList(proxy);
        } else {
            List<Proxy> listSelect = aVar.f6054g.select(sVar.q());
            listO = (listSelect == null || listSelect.isEmpty()) ? g.i0.c.o(Proxy.NO_PROXY) : g.i0.c.n(listSelect);
        }
        this.f6175e = listO;
        this.f6176f = 0;
    }

    public void a(g0 g0Var, IOException iOException) {
        g.a aVar;
        ProxySelector proxySelector;
        if (g0Var.f6116b.type() != Proxy.Type.DIRECT && (proxySelector = (aVar = this.f6171a).f6054g) != null) {
            proxySelector.connectFailed(aVar.f6048a.q(), g0Var.f6116b.address(), iOException);
        }
        d dVar = this.f6172b;
        synchronized (dVar) {
            dVar.f6168a.add(g0Var);
        }
    }

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

    public final boolean c() {
        return this.f6176f < this.f6175e.size();
    }
}
