package XnFJ5_9.Ft6VRog_36.FSaI4_7;

import XnFJ5_9.LGe8pk_15;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ProtocolException;
import java.net.UnknownServiceException;
import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocket;
/* compiled from: ConnectionSpecSelector.java */
/* loaded from: classes.dex */
public final class PGPF6hQ_2 {
    public int KQgRr5e_0 = 0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final List<LGe8pk_15> f1483KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public boolean f1484KQgRr5e_0;
    public boolean QxJ9d_1;

    public PGPF6hQ_2(List<LGe8pk_15> list) {
        this.f1483KQgRr5e_0 = list;
    }

    public LGe8pk_15 KQgRr5e_0(SSLSocket sSLSocket) throws IOException {
        LGe8pk_15 lGe8pk_15;
        int i = this.KQgRr5e_0;
        int size = this.f1483KQgRr5e_0.size();
        while (true) {
            if (i >= size) {
                lGe8pk_15 = null;
                break;
            }
            lGe8pk_15 = this.f1483KQgRr5e_0.get(i);
            if (lGe8pk_15.KQgRr5e_0(sSLSocket)) {
                this.KQgRr5e_0 = i + 1;
                break;
            }
            i++;
        }
        if (lGe8pk_15 != null) {
            this.f1484KQgRr5e_0 = m683KQgRr5e_0(sSLSocket);
            XnFJ5_9.Ft6VRog_36.PGPF6hQ_2.KQgRr5e_0.KQgRr5e_0(lGe8pk_15, sSLSocket, this.QxJ9d_1);
            return lGe8pk_15;
        }
        throw new UnknownServiceException("Unable to find acceptable protocols. isFallback=" + this.QxJ9d_1 + ", modes=" + this.f1483KQgRr5e_0 + ", supported protocols=" + Arrays.toString(sSLSocket.getEnabledProtocols()));
    }

    public boolean KQgRr5e_0(IOException iOException) {
        this.QxJ9d_1 = true;
        if (!this.f1484KQgRr5e_0 || (iOException instanceof ProtocolException) || (iOException instanceof InterruptedIOException)) {
            return false;
        }
        if (((iOException instanceof SSLHandshakeException) && (iOException.getCause() instanceof CertificateException)) || (iOException instanceof SSLPeerUnverifiedException)) {
            return false;
        }
        return iOException instanceof SSLException;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public final boolean m683KQgRr5e_0(SSLSocket sSLSocket) {
        for (int i = this.KQgRr5e_0; i < this.f1483KQgRr5e_0.size(); i++) {
            if (this.f1483KQgRr5e_0.get(i).KQgRr5e_0(sSLSocket)) {
                return true;
            }
        }
        return false;
    }
}
