package o;

import java.net.UnknownServiceException;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.SSLSocket;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.nl, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1984nl {
    public int a;
    public boolean b;
    public boolean c;
    public final Object d;

    public C1984nl(Nq0 nq0, int i, boolean z, boolean z2) {
        this.d = nq0;
        this.a = i;
        this.b = z;
        this.c = z2;
    }

    /* JADX WARN: Type inference failed for: r1v3, types: [java.io.Serializable, java.lang.String[]] */
    public C1889ml a(SSLSocket sSLSocket) throws UnknownServiceException {
        C1889ml c1889ml;
        int i;
        boolean z;
        int i2 = this.a;
        List list = (List) this.d;
        int size = list.size();
        while (true) {
            if (i2 >= size) {
                c1889ml = null;
                break;
            }
            c1889ml = (C1889ml) list.get(i2);
            if (c1889ml.b(sSLSocket)) {
                this.a = i2 + 1;
                break;
            }
            i2++;
        }
        if (c1889ml == null) {
            throw new UnknownServiceException("Unable to find acceptable protocols. isFallback=" + this.c + ", modes=" + list + ", supported protocols=" + Arrays.toString(sSLSocket.getEnabledProtocols()));
        }
        int i3 = this.a;
        int size2 = list.size();
        while (true) {
            i = 0;
            if (i3 >= size2) {
                z = false;
                break;
            }
            if (((C1889ml) list.get(i3)).b(sSLSocket)) {
                z = true;
                break;
            }
            i3++;
        }
        this.b = z;
        boolean z2 = this.c;
        ?? r1 = c1889ml.d;
        String[] strArr = c1889ml.c;
        String[] strArrO = strArr != null ? AbstractC2264qi0.o(sSLSocket.getEnabledCipherSuites(), strArr, C0396Ph.c) : sSLSocket.getEnabledCipherSuites();
        String[] strArrO2 = r1 != 0 ? AbstractC2264qi0.o(sSLSocket.getEnabledProtocols(), r1, C2617uR.b) : sSLSocket.getEnabledProtocols();
        String[] supportedCipherSuites = sSLSocket.getSupportedCipherSuites();
        C1746lA c1746lA = C0396Ph.c;
        byte[] bArr = AbstractC2264qi0.a;
        int length = supportedCipherSuites.length;
        while (true) {
            if (i >= length) {
                i = -1;
                break;
            }
            if (c1746lA.compare(supportedCipherSuites[i], "TLS_FALLBACK_SCSV") == 0) {
                break;
            }
            i++;
        }
        if (z2 && i != -1) {
            String str = supportedCipherSuites[i];
            strArrO = (String[]) Arrays.copyOf(strArrO, strArrO.length + 1);
            strArrO[strArrO.length - 1] = str;
        }
        C1794ll c1794ll = new C1794ll();
        c1794ll.a = c1889ml.a;
        c1794ll.c = strArr;
        c1794ll.d = r1;
        c1794ll.b = c1889ml.b;
        c1794ll.b((String[]) Arrays.copyOf(strArrO, strArrO.length));
        c1794ll.d((String[]) Arrays.copyOf(strArrO2, strArrO2.length));
        C1889ml c1889mlA = c1794ll.a();
        if (c1889mlA.c() != null) {
            sSLSocket.setEnabledProtocols(c1889mlA.d);
        }
        if (c1889mlA.a() != null) {
            sSLSocket.setEnabledCipherSuites(c1889mlA.c);
        }
        return c1889ml;
    }

    public void b(String str) {
        ((Nq0) this.d).B(this.a, this.b, this.c, str, null, null, null);
    }

    public void c(Object obj, String str) {
        ((Nq0) this.d).B(this.a, this.b, this.c, str, obj, null, null);
    }

    public void d(String str, Object obj, Object obj2) {
        ((Nq0) this.d).B(this.a, this.b, this.c, str, obj, obj2, null);
    }

    public void e(String str, Object obj, Object obj2, Object obj3) {
        ((Nq0) this.d).B(this.a, this.b, this.c, str, obj, obj2, obj3);
    }

    public C1984nl(List list) {
        this.d = list;
    }
}
