package g.i0.j;

import g.x;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final f f6405a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Logger f6406b;

    /* JADX WARN: Removed duplicated region for block: B:13:0x0041 A[Catch: ClassNotFoundException -> 0x0061, TRY_ENTER, TryCatch #3 {ClassNotFoundException -> 0x0061, blocks: (B:6:0x0014, B:13:0x0041, B:15:0x005a, B:5:0x000d, B:3:0x0005), top: B:48:0x0005, inners: #4 }] */
    /* JADX WARN: Removed duplicated region for block: B:14:0x0058  */
    static {
        /*
            Method dump skipped, instruction units count: 273
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i0.j.f.<clinit>():void");
    }

    public static List<String> b(List<x> list) {
        ArrayList arrayList = new ArrayList(list.size());
        int size = list.size();
        for (int i2 = 0; i2 < size; i2++) {
            x xVar = list.get(i2);
            if (xVar != x.HTTP_1_0) {
                arrayList.add(xVar.toString());
            }
        }
        return arrayList;
    }

    @Nullable
    public static <T> T n(Object obj, Class<T> cls, String str) {
        Object objN;
        for (Class<?> superclass = obj.getClass(); superclass != Object.class; superclass = superclass.getSuperclass()) {
            try {
                Field declaredField = superclass.getDeclaredField(str);
                declaredField.setAccessible(true);
                Object obj2 = declaredField.get(obj);
                if (obj2 != null && cls.isInstance(obj2)) {
                    return cls.cast(obj2);
                }
                return null;
            } catch (IllegalAccessException unused) {
                throw new AssertionError();
            } catch (NoSuchFieldException unused2) {
            }
        }
        if (str.equals("delegate") || (objN = n(obj, Object.class, "delegate")) == null) {
            return null;
        }
        return (T) n(objN, cls, str);
    }

    public void a(SSLSocket sSLSocket) {
    }

    public g.i0.l.c c(X509TrustManager x509TrustManager) {
        return new g.i0.l.a(d(x509TrustManager));
    }

    public g.i0.l.e d(X509TrustManager x509TrustManager) {
        return new g.i0.l.b(x509TrustManager.getAcceptedIssuers());
    }

    public void e(SSLSocketFactory sSLSocketFactory) {
    }

    public void f(SSLSocket sSLSocket, @Nullable String str, List<x> list) {
    }

    public void g(Socket socket, InetSocketAddress inetSocketAddress, int i2) throws IOException {
        socket.connect(inetSocketAddress, i2);
    }

    public SSLContext h() {
        if ("1.7".equals(System.getProperty("java.specification.version"))) {
            try {
                return SSLContext.getInstance("TLSv1.2");
            } catch (NoSuchAlgorithmException unused) {
            }
        }
        try {
            return SSLContext.getInstance("TLS");
        } catch (NoSuchAlgorithmException e2) {
            throw new IllegalStateException("No TLS provider", e2);
        }
    }

    @Nullable
    public String i(SSLSocket sSLSocket) {
        return null;
    }

    public Object j(String str) {
        if (f6406b.isLoggable(Level.FINE)) {
            return new Throwable(str);
        }
        return null;
    }

    public boolean k(String str) {
        return true;
    }

    public void l(int i2, String str, @Nullable Throwable th) {
        f6406b.log(i2 == 5 ? Level.WARNING : Level.INFO, str, th);
    }

    public void m(String str, Object obj) {
        if (obj == null) {
            str = a.b.c.a.a.p(str, " To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);");
        }
        l(5, str, (Throwable) obj);
    }

    @Nullable
    public X509TrustManager o(SSLSocketFactory sSLSocketFactory) {
        try {
            Object objN = n(sSLSocketFactory, Class.forName("sun.security.ssl.SSLContextImpl"), "context");
            if (objN == null) {
                return null;
            }
            return (X509TrustManager) n(objN, X509TrustManager.class, "trustManager");
        } catch (ClassNotFoundException unused) {
            return null;
        }
    }

    public String toString() {
        return getClass().getSimpleName();
    }
}
