package g;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import javax.net.ssl.SSLSocket;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final g[] f6126a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final g[] f6127b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final i f6128c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final i f6129d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final boolean f6130e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final boolean f6131f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    @Nullable
    public final String[] f6132g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    @Nullable
    public final String[] f6133h;

    public static final class a {

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

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        @Nullable
        public String[] f6135b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        @Nullable
        public String[] f6136c;

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

        public a(boolean z) {
            this.f6134a = z;
        }

        public a a(String... strArr) {
            if (!this.f6134a) {
                throw new IllegalStateException("no cipher suites for cleartext connections");
            }
            if (strArr.length == 0) {
                throw new IllegalArgumentException("At least one cipher suite is required");
            }
            this.f6135b = (String[]) strArr.clone();
            return this;
        }

        public a b(g... gVarArr) {
            if (!this.f6134a) {
                throw new IllegalStateException("no cipher suites for cleartext connections");
            }
            String[] strArr = new String[gVarArr.length];
            for (int i2 = 0; i2 < gVarArr.length; i2++) {
                strArr[i2] = gVarArr[i2].u;
            }
            a(strArr);
            return this;
        }

        public a c(boolean z) {
            if (!this.f6134a) {
                throw new IllegalStateException("no TLS extensions for cleartext connections");
            }
            this.f6137d = z;
            return this;
        }

        public a d(String... strArr) {
            if (!this.f6134a) {
                throw new IllegalStateException("no TLS versions for cleartext connections");
            }
            if (strArr.length == 0) {
                throw new IllegalArgumentException("At least one TLS version is required");
            }
            this.f6136c = (String[]) strArr.clone();
            return this;
        }

        public a e(h0... h0VarArr) {
            if (!this.f6134a) {
                throw new IllegalStateException("no TLS versions for cleartext connections");
            }
            String[] strArr = new String[h0VarArr.length];
            for (int i2 = 0; i2 < h0VarArr.length; i2++) {
                strArr[i2] = h0VarArr[i2].javaName;
            }
            d(strArr);
            return this;
        }
    }

    static {
        g gVar = g.p;
        g gVar2 = g.q;
        g gVar3 = g.r;
        g gVar4 = g.s;
        g gVar5 = g.t;
        g gVar6 = g.f6114j;
        g gVar7 = g.l;
        g gVar8 = g.k;
        g gVar9 = g.m;
        g gVar10 = g.o;
        g gVar11 = g.n;
        g[] gVarArr = {gVar, gVar2, gVar3, gVar4, gVar5, gVar6, gVar7, gVar8, gVar9, gVar10, gVar11};
        f6126a = gVarArr;
        g[] gVarArr2 = {gVar, gVar2, gVar3, gVar4, gVar5, gVar6, gVar7, gVar8, gVar9, gVar10, gVar11, g.f6112h, g.f6113i, g.f6110f, g.f6111g, g.f6108d, g.f6109e, g.f6107c};
        f6127b = gVarArr2;
        a aVar = new a(true);
        aVar.b(gVarArr);
        h0 h0Var = h0.TLS_1_3;
        h0 h0Var2 = h0.TLS_1_2;
        aVar.e(h0Var, h0Var2);
        aVar.c(true);
        a aVar2 = new a(true);
        aVar2.b(gVarArr2);
        h0 h0Var3 = h0.TLS_1_0;
        aVar2.e(h0Var, h0Var2, h0.TLS_1_1, h0Var3);
        aVar2.c(true);
        f6128c = new i(aVar2);
        a aVar3 = new a(true);
        aVar3.b(gVarArr2);
        aVar3.e(h0Var3);
        aVar3.c(true);
        f6129d = new i(new a(false));
    }

    public i(a aVar) {
        this.f6130e = aVar.f6134a;
        this.f6132g = aVar.f6135b;
        this.f6133h = aVar.f6136c;
        this.f6131f = aVar.f6137d;
    }

    public boolean a(SSLSocket sSLSocket) {
        if (!this.f6130e) {
            return false;
        }
        String[] strArr = this.f6133h;
        if (strArr != null && !g.i0.c.s(g.i0.c.o, strArr, sSLSocket.getEnabledProtocols())) {
            return false;
        }
        String[] strArr2 = this.f6132g;
        return strArr2 == null || g.i0.c.s(g.f6105a, strArr2, sSLSocket.getEnabledCipherSuites());
    }

    public boolean equals(@Nullable Object obj) {
        if (!(obj instanceof i)) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        i iVar = (i) obj;
        boolean z = this.f6130e;
        if (z != iVar.f6130e) {
            return false;
        }
        return !z || (Arrays.equals(this.f6132g, iVar.f6132g) && Arrays.equals(this.f6133h, iVar.f6133h) && this.f6131f == iVar.f6131f);
    }

    public int hashCode() {
        if (this.f6130e) {
            return ((((527 + Arrays.hashCode(this.f6132g)) * 31) + Arrays.hashCode(this.f6133h)) * 31) + (!this.f6131f ? 1 : 0);
        }
        return 17;
    }

    public String toString() {
        String string;
        List listUnmodifiableList;
        if (!this.f6130e) {
            return "ConnectionSpec()";
        }
        String[] strArr = this.f6132g;
        if (strArr != null) {
            if (strArr != null) {
                ArrayList arrayList = new ArrayList(strArr.length);
                for (String str : strArr) {
                    arrayList.add(g.a(str));
                }
                listUnmodifiableList = Collections.unmodifiableList(arrayList);
            } else {
                listUnmodifiableList = null;
            }
            string = listUnmodifiableList.toString();
        } else {
            string = "[all enabled]";
        }
        String[] strArr2 = this.f6133h;
        return "ConnectionSpec(cipherSuites=" + string + ", tlsVersions=" + (strArr2 != null ? (strArr2 != null ? h0.forJavaNames(strArr2) : null).toString() : "[all enabled]") + ", supportsTlsExtensions=" + this.f6131f + ")";
    }
}
