package okhttp3.internal.platform; 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.OkHttpClient; import okhttp3.Protocol; import okhttp3.internal.Util; import okhttp3.internal.tls.BasicCertificateChainCleaner; import okhttp3.internal.tls.BasicTrustRootIndex; import okhttp3.internal.tls.CertificateChainCleaner; import okhttp3.internal.tls.TrustRootIndex; import okio.Buffer; /* loaded from: classes5.dex */ public class Platform { public static final Platform PLATFORM = findPlatform(); public static final Logger logger = Logger.getLogger(OkHttpClient.class.getName()); public static Platform get() { return PLATFORM; } public void afterHandshake(SSLSocket sSLSocket) { } public void configureSslSocketFactory(SSLSocketFactory sSLSocketFactory) { } public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) { } public String getPrefix() { return "OkHttp"; } public String getSelectedProtocol(SSLSocket sSLSocket) { return null; } public boolean isCleartextTrafficPermitted(String str) { return true; } public void connectSocket(Socket socket, InetSocketAddress inetSocketAddress, int i) { socket.connect(inetSocketAddress, i); } public void log(int i, String str, Throwable th) { logger.log(i == 5 ? Level.WARNING : Level.INFO, str, th); } public Object getStackTraceForCloseable(String str) { if (logger.isLoggable(Level.FINE)) { return new Throwable(str); } return null; } public void logCloseableLeak(String str, Object obj) { if (obj == null) { str = str + " To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);"; } log(5, str, (Throwable) obj); } public static List alpnProtocolNames(List list) { ArrayList arrayList = new ArrayList(list.size()); int size = list.size(); for (int i = 0; i < size; i++) { Protocol protocol = (Protocol) list.get(i); if (protocol != Protocol.HTTP_1_0) { arrayList.add(protocol.toString()); } } return arrayList; } public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager x509TrustManager) { return new BasicCertificateChainCleaner(buildTrustRootIndex(x509TrustManager)); } public static boolean isConscryptPreferred() { if ("conscrypt".equals(Util.getSystemProperty("okhttp.platform", null))) { return true; } return "Conscrypt".equals(Security.getProviders()[0].getName()); } public static Platform findPlatform() { if (isAndroid()) { return findAndroidPlatform(); } return findJvmPlatform(); } public static boolean isAndroid() { return "Dalvik".equals(System.getProperty("java.vm.name")); } public static Platform findJvmPlatform() { ConscryptPlatform buildIfSupported; if (isConscryptPreferred() && (buildIfSupported = ConscryptPlatform.buildIfSupported()) != null) { return buildIfSupported; } Jdk9Platform buildIfSupported2 = Jdk9Platform.buildIfSupported(); if (buildIfSupported2 != null) { return buildIfSupported2; } Platform buildIfSupported3 = Jdk8WithJettyBootPlatform.buildIfSupported(); return buildIfSupported3 != null ? buildIfSupported3 : new Platform(); } public static Platform findAndroidPlatform() { Platform buildIfSupported = Android10Platform.buildIfSupported(); if (buildIfSupported != null) { return buildIfSupported; } Platform buildIfSupported2 = AndroidPlatform.buildIfSupported(); if (buildIfSupported2 != null) { return buildIfSupported2; } throw new NullPointerException("No platform found on Android"); } public static byte[] concatLengthPrefixed(List list) { Buffer buffer = new Buffer(); int size = list.size(); for (int i = 0; i < size; i++) { Protocol protocol = (Protocol) list.get(i); if (protocol != Protocol.HTTP_1_0) { buffer.writeByte(protocol.toString().length()); buffer.writeUtf8(protocol.toString()); } } return buffer.readByteArray(); } public SSLContext getSSLContext() { try { return SSLContext.getInstance("TLS"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("No TLS provider", e); } } public TrustRootIndex buildTrustRootIndex(X509TrustManager x509TrustManager) { return new BasicTrustRootIndex(x509TrustManager.getAcceptedIssuers()); } public String toString() { return getClass().getSimpleName(); } }