package 㿎.ሽ.ᨨ;

import java.io.IOException;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.Protocol;
import ඓ.K.K.K.C1293;
import 㿎.C2625;
import 㿎.ሽ.㳳.AbstractC2571;
import 㿎.ሽ.㳳.AbstractC2572;
import 㿎.ሽ.㳳.C2573;
import 㿎.ሽ.㳳.C2574;

/* renamed from: 㿎.ሽ.ᨨ.㴹  reason: contains not printable characters */
/* compiled from: Platform */
public class C2558 {

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final Logger f8642 = Logger.getLogger(C2625.class.getName());

    /* renamed from: K  reason: contains not printable characters */
    public static final C2558 f8643;

    static {
        boolean z;
        C2558 r0 = C2554.m6706();
        if (r0 == null) {
            if ("conscrypt".equals(System.getProperty("okhttp.platform"))) {
                z = true;
            } else {
                z = "Conscrypt".equals(Security.getProviders()[0].getName());
            }
            if ((!z || (r0 = C2553.m6699()) == null) && (r0 = C2551.m6691()) == null && (r0 = C2559.m6737()) == null) {
                r0 = new C2558();
            }
        }
        f8643 = r0;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public String m6724(SSLSocket sSLSocket) {
        return null;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public X509TrustManager m6725(SSLSocketFactory sSLSocketFactory) {
        try {
            Object r4 = m6722(sSLSocketFactory, Class.forName("sun.security.ssl.SSLContextImpl"), "context");
            if (r4 == null) {
                return null;
            }
            return (X509TrustManager) m6722(r4, X509TrustManager.class, "trustManager");
        } catch (ClassNotFoundException unused) {
            return null;
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean m6727(String str) {
        return true;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6733(Socket socket, InetSocketAddress inetSocketAddress, int i) throws IOException {
        socket.connect(inetSocketAddress, i);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6734(SSLSocket sSLSocket) {
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6735(SSLSocket sSLSocket, String str, List<Protocol> list) {
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6736(SSLSocketFactory sSLSocketFactory) {
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6731(int i, String str, Throwable th) {
        f8642.log(i == 5 ? Level.WARNING : Level.INFO, str, th);
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public AbstractC2572 m6726(X509TrustManager x509TrustManager) {
        return new C2573(x509TrustManager.getAcceptedIssuers());
    }

    /* renamed from: K  reason: contains not printable characters */
    public Object m6728(String str) {
        if (f8642.isLoggable(Level.FINE)) {
            return new Throwable(str);
        }
        return null;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6732(String str, Object obj) {
        if (obj == null) {
            str = C1293.m3412(str, " To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);");
        }
        m6731(5, str, (Throwable) obj);
    }

    /* renamed from: K  reason: contains not printable characters */
    public static List<String> m6723(List<Protocol> list) {
        ArrayList arrayList = new ArrayList(list.size());
        int size = list.size();
        for (int i = 0; i < size; i++) {
            Protocol protocol = list.get(i);
            if (protocol != Protocol.HTTP_1_0) {
                arrayList.add(protocol.toString());
            }
        }
        return arrayList;
    }

    /* renamed from: K  reason: contains not printable characters */
    public AbstractC2571 m6730(X509TrustManager x509TrustManager) {
        return new C2574(m6726(x509TrustManager));
    }

    /* renamed from: K  reason: contains not printable characters */
    public static <T> T m6722(Object obj, Class<T> cls, String str) {
        Object r5;
        for (Class<?> cls2 = obj.getClass(); cls2 != Object.class; cls2 = cls2.getSuperclass()) {
            try {
                Field declaredField = cls2.getDeclaredField(str);
                declaredField.setAccessible(true);
                Object obj2 = declaredField.get(obj);
                if (obj2 != null) {
                    if (cls.isInstance(obj2)) {
                        return cls.cast(obj2);
                    }
                }
                return null;
            } catch (NoSuchFieldException unused) {
            } catch (IllegalAccessException unused2) {
                throw new AssertionError();
            }
        }
        if (str.equals("delegate") || (r5 = m6722(obj, Object.class, "delegate")) == null) {
            return null;
        }
        return (T) m6722(r5, cls, str);
    }

    /* renamed from: K  reason: contains not printable characters */
    public SSLContext m6729() {
        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 e) {
            throw new IllegalStateException("No TLS provider", e);
        }
    }
}
