content: package okhttp3.internal.platform;
  
  import java.io.IOException;
  import java.net.InetSocketAddress;
  import java.net.Socket;
  import java.security.GeneralSecurityException;
  import java.security.KeyStore;
  import java.security.Provider;
  import java.security.SecureRandom;
  import java.security.Security;
  import java.security.cert.X509Certificate;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.List;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.net.ssl.KeyManager;
  import javax.net.ssl.SSLContext;
  import javax.net.ssl.SSLSocket;
  import javax.net.ssl.SSLSocketFactory;
  import javax.net.ssl.TrustManager;
  import javax.net.ssl.TrustManagerFactory;
  import javax.net.ssl.X509TrustManager;
  import kotlin.Metadata;
  import kotlin.collections.CollectionsKt;
  import kotlin.jvm.JvmStatic;
  import kotlin.jvm.internal.DefaultConstructorMarker;
  import kotlin.jvm.internal.Intrinsics;
  import mt.Log1F380D;
  import okhttp3.OkHttpClient;
  import okhttp3.Protocol;
  import okhttp3.internal.Util;
  import okhttp3.internal.platform.android.AndroidLog;
  import okhttp3.internal.tls.BasicCertificateChainCleaner;
  import okhttp3.internal.tls.BasicTrustRootIndex;
  import okhttp3.internal.tls.CertificateChainCleaner;
  import okhttp3.internal.tls.TrustRootIndex;
  import okio.Buffer;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u0000t\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0010\u0003\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0016\u0018\u0000 /2\u00020\u0001:\u0001/B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0010\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH\u0016J\u0010\u0010\u000b\u001a\u00020\f2\u0006\u0010\t\u001a\u00020\nH\u0016J-\u0010\r\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\b\u0010\u000e\u001a\u0004\u0018\u00010\u000f2\u0011\u0010\u0010\u001a\r\u0012\t\u0012\u00070\u0012¢\u0006\u0002\b\u00130\u0011H\u0016J \u0010\u0014\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001aH\u0016J\u0006\u0010\u001b\u001a\u00020\u000fJ\u0012\u0010\u001c\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0012\u0010\u001d\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u001e\u001a\u00020\u000fH\u0016J\u0010\u0010\u001f\u001a\u00020 2\u0006\u0010\u000e\u001a\u00020\u000fH\u0016J&\u0010!\u001a\u00020\u00042\u0006\u0010\"\u001a\u00020\u000f2\b\b\u0002\u0010#\u001a\u00020\u001a2\n\b\u0002\u0010$\u001a\u0004\u0018\u00010%H\u0016J\u001a\u0010&\u001a\u00020\u00042\u0006\u0010\"\u001a\u00020\u000f2\b\u0010'\u001a\u0004\u0018\u00010\u0001H\u0016J\b\u0010(\u001a\u00020)H\u0016J\u0010\u0010*\u001a\u00020+2\u0006\u0010\t\u001a\u00020\nH\u0016J\b\u0010,\u001a\u00020\nH\u0016J\b\u0010-\u001a\u00020\u000fH\u0016J\u0012\u0010\t\u001a\u0004\u0018\u00010\n2\u0006\u0010.\u001a\u00020+H\u0016¨\u00060"}, d2 = {"Lokhttp3/internal/platform/Platform;", "", "()V", "afterHandshake", "", "sslSocket", "Ljavax/net/ssl/SSLSocket;", "buildCertificateChainCleaner", "Lokhttp3/internal/tls/CertificateChainCleaner;", "trustManager", "Ljavax/net/ssl/X509TrustManager;", "buildTrustRootIndex", "Lokhttp3/internal/tls/TrustRootIndex;", "configureTlsExtensions", "hostname", "", "protocols", "", "Lokhttp3/Protocol;", "Lkotlin/jvm/JvmSuppressWildcards;", "connectSocket", "socket", "Ljava/net/Socket;", "address", "Ljava/net/InetSocketAddress;", "connectTimeout", "", "getPrefix", "getSelectedProtocol", "getStackTraceForCloseable", "closer", "isCleartextTrafficPermitted", "", "log", "message", "level", "t", "", "logCloseableLeak", "stackTrace", "newSSLContext", "Ljavax/net/ssl/SSLContext;", "newSslSocketFactory", "Ljavax/net/ssl/SSLSocketFactory;", "platformTrustManager", "toString", "sslSocketFactory", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
  /* compiled from: 01D7 */
  public class Platform {
      public static final Companion Companion;
      public static final int INFO = 4;
      public static final int WARN = 5;
      private static final Logger logger = Logger.getLogger(OkHttpClient.class.getName());
      /* access modifiers changed from: private */
      public static volatile Platform platform;
  
      @Metadata(bv = {1, 0, 3}, d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0012\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0000\b\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001a\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00130\u00122\f\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00150\u0012J\u0014\u0010\u0016\u001a\u00020\u00172\f\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00150\u0012J\b\u0010\u0018\u001a\u00020\u0010H\u0002J\b\u0010\u0019\u001a\u00020\u0010H\u0002J\b\u0010\u001a\u001a\u00020\u0010H\u0002J\b\u0010\u001b\u001a\u00020\u0010H\u0007J\u0010\u0010\u001c\u001a\u00020\u001d2\b\b\u0002\u0010\u000f\u001a\u00020\u0010R\u000e\u0010\u0003\u001a\u00020\u0004XT¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004XT¢\u0006\u0002\n\u0000R\u0011\u0010\u0006\u001a\u00020\u00078F¢\u0006\u0006\u001a\u0004\b\u0006\u0010\bR\u0014\u0010\t\u001a\u00020\u00078BX\u0004¢\u0006\u0006\u001a\u0004\b\t\u0010\bR\u0014\u0010\n\u001a\u00020\u00078BX\u0004¢\u0006\u0006\u001a\u0004\b\n\u0010\bR\u0014\u0010\u000b\u001a\u00020\u00078BX\u0004¢\u0006\u0006\u001a\u0004\b\u000b\u0010\bR\u0016\u0010\f\u001a\n \u000e*\u0004\u0018\u00010\r0\rX\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0010X\u000e¢\u0006\u0002\n\u0000¨\u0006\u001e"}, d2 = {"Lokhttp3/internal/platform/Platform$Companion;", "", "()V", "INFO", "", "WARN", "isAndroid", "", "()Z", "isBouncyCastlePreferred", "isConscryptPreferred", "isOpenJSSEPreferred", "logger", "Ljava/util/logging/Logger;", "kotlin.jvm.PlatformType", "platform", "Lokhttp3/internal/platform/Platform;", "alpnProtocolNames", "", "", "protocols", "Lokhttp3/Protocol;", "concatLengthPrefixed", "", "findAndroidPlatform", "findJvmPlatform", "findPlatform", "get", "resetForTests", "", "okhttp"}, k = 1, mv = {1, 4, 0})
      /* compiled from: 01DD */
      public static final class Companion {
          private Companion() {
          }
  
          public /* synthetic */ Companion(DefaultConstructorMarker $constructor_marker) {
              this();
          }
  
          private final Platform findAndroidPlatform() {
              AndroidLog.INSTANCE.enable();
              Platform buildIfSupported = Android10Platform.Companion.buildIfSupported();
              if (buildIfSupported != null) {
                  return buildIfSupported;
              }
              Platform buildIfSupported2 = AndroidPlatform.Companion.buildIfSupported();
              Intrinsics.checkNotNull(buildIfSupported2);
              return buildIfSupported2;
          }
  
          private final Platform findJvmPlatform() {
              OpenJSSEPlatform buildIfSupported;
              BouncyCastlePlatform buildIfSupported2;
              ConscryptPlatform buildIfSupported3;
              if (isConscryptPreferred() && (buildIfSupported3 = ConscryptPlatform.Companion.buildIfSupported()) != null) {
                  return buildIfSupported3;
              }
              if (isBouncyCastlePreferred() && (buildIfSupported2 = BouncyCastlePlatform.Companion.buildIfSupported()) != null) {
                  return buildIfSupported2;
              }
              if (isOpenJSSEPreferred() && (buildIfSupported = OpenJSSEPlatform.Companion.buildIfSupported()) != null) {
                  return buildIfSupported;
              }
              Jdk9Platform buildIfSupported4 = Jdk9Platform.Companion.buildIfSupported();
              if (buildIfSupported4 != null) {
                  return buildIfSupported4;
              }
              Platform buildIfSupported5 = Jdk8WithJettyBootPlatform.Companion.buildIfSupported();
              return buildIfSupported5 != null ? buildIfSupported5 : new Platform();
          }
  
          /* access modifiers changed from: private */
          public final Platform findPlatform() {
              return isAndroid() ? findAndroidPlatform() : findJvmPlatform();
          }
  
          private final boolean isBouncyCastlePreferred() {
              Provider provider = Security.getProviders()[0];
              Intrinsics.checkNotNullExpressionValue(provider, "Security.getProviders()[0]");
              return Intrinsics.areEqual((Object) "BC", (Object) provider.getName());
          }
  
          private final boolean isConscryptPreferred() {
              Provider provider = Security.getProviders()[0];
              Intrinsics.checkNotNullExpressionValue(provider, "Security.getProviders()[0]");
              return Intrinsics.areEqual((Object) "Conscrypt", (Object) provider.getName());
          }
  
          private final boolean isOpenJSSEPreferred() {
              Provider provider = Security.getProviders()[0];
              Intrinsics.checkNotNullExpressionValue(provider, "Security.getProviders()[0]");
              return Intrinsics.areEqual((Object) "OpenJSSE", (Object) provider.getName());
          }
  
          public static /* synthetic */ void resetForTests$default(Companion companion, Platform platform, int i, Object obj) {
              if ((i & 1) != 0) {
                  platform = companion.findPlatform();
              }
              companion.resetForTests(platform);
          }
  
          public final List<String> alpnProtocolNames(List<? extends Protocol> protocols) {
              Intrinsics.checkNotNullParameter(protocols, "protocols");
              Collection arrayList = new ArrayList();
              for (Object next : protocols) {
                  if (((Protocol) next) != Protocol.HTTP_1_0) {
                      arrayList.add(next);
                  }
              }
              Iterable<Protocol> iterable = (List) arrayList;
              Collection arrayList2 = new ArrayList(CollectionsKt.collectionSizeOrDefault(iterable, 10));
              for (Protocol protocol : iterable) {
                  arrayList2.add(protocol.toString());
              }
              return (List) arrayList2;
          }
  
          public final byte[] concatLengthPrefixed(List<? extends Protocol> protocols) {
              Intrinsics.checkNotNullParameter(protocols, "protocols");
              Buffer buffer = new Buffer();
              for (String next : alpnProtocolNames(protocols)) {
                  buffer.writeByte(next.length());
                  buffer.writeUtf8(next);
              }
              return buffer.readByteArray();
          }
  
          @JvmStatic
          public final Platform get() {
              return Platform.platform;
          }
  
          public final boolean isAndroid() {
              String property = System.getProperty("java.vm.name");
              Log1F380D.a((Object) property);
              return Intrinsics.areEqual((Object) "Dalvik", (Object) property);
          }
  
          public final void resetForTests(Platform platform) {
              Intrinsics.checkNotNullParameter(platform, "platform");
              Platform.platform = platform;
          }
      }
  
      static {
          Companion companion = new Companion((DefaultConstructorMarker) null);
          Companion = companion;
          platform = companion.findPlatform();
      }
  
      @JvmStatic
      public static final Platform get() {
          return Companion.get();
      }
  
      public static /* synthetic */ void log$default(Platform platform2, String str, int i, Throwable th, int i2, Object obj) {
          if (obj == null) {
              if ((i2 & 2) != 0) {
                  i = 4;
              }
              if ((i2 & 4) != 0) {
                  th = null;
                  Throwable th2 = null;
              }
              platform2.log(str, i, th);
              return;
          }
          throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: log");
      }
  
      public void afterHandshake(SSLSocket sslSocket) {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
      }
  
      public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager trustManager) {
          Intrinsics.checkNotNullParameter(trustManager, "trustManager");
          return new BasicCertificateChainCleaner(buildTrustRootIndex(trustManager));
      }
  
      public TrustRootIndex buildTrustRootIndex(X509TrustManager trustManager) {
          Intrinsics.checkNotNullParameter(trustManager, "trustManager");
          X509Certificate[] acceptedIssuers = trustManager.getAcceptedIssuers();
          Intrinsics.checkNotNullExpressionValue(acceptedIssuers, "trustManager.acceptedIssuers");
          return new BasicTrustRootIndex((X509Certificate[]) Arrays.copyOf(acceptedIssuers, acceptedIssuers.length));
      }
  
      public void configureTlsExtensions(SSLSocket sslSocket, String hostname, List<Protocol> protocols) {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
          Intrinsics.checkNotNullParameter(protocols, "protocols");
      }
  
      public void connectSocket(Socket socket, InetSocketAddress address, int connectTimeout) throws IOException {
          Intrinsics.checkNotNullParameter(socket, "socket");
          Intrinsics.checkNotNullParameter(address, "address");
          socket.connect(address, connectTimeout);
      }
  
      public final String getPrefix() {
          return "OkHttp";
      }
  
      public String getSelectedProtocol(SSLSocket sslSocket) {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
          return null;
      }
  
      public Object getStackTraceForCloseable(String closer) {
          Intrinsics.checkNotNullParameter(closer, "closer");
          if (logger.isLoggable(Level.FINE)) {
              return new Throwable(closer);
          }
          return null;
      }
  
      public boolean isCleartextTrafficPermitted(String hostname) {
          Intrinsics.checkNotNullParameter(hostname, "hostname");
          return true;
      }
  
      public void log(String message, int level, Throwable t) {
          Intrinsics.checkNotNullParameter(message, "message");
          logger.log(level == 5 ? Level.WARNING : Level.INFO, message, t);
      }
  
      public void logCloseableLeak(String message, Object stackTrace) {
          Intrinsics.checkNotNullParameter(message, "message");
          String str = message;
          if (stackTrace == 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(str, 5, (Throwable) stackTrace);
      }
  
      public SSLContext newSSLContext() {
          SSLContext instance = SSLContext.getInstance("TLS");
          Intrinsics.checkNotNullExpressionValue(instance, "SSLContext.getInstance(\"TLS\")");
          return instance;
      }
  
      public SSLSocketFactory newSslSocketFactory(X509TrustManager trustManager) {
          Intrinsics.checkNotNullParameter(trustManager, "trustManager");
          try {
              SSLContext newSSLContext = newSSLContext();
              newSSLContext.init((KeyManager[]) null, new TrustManager[]{trustManager}, (SecureRandom) null);
              SSLSocketFactory socketFactory = newSSLContext.getSocketFactory();
              Intrinsics.checkNotNullExpressionValue(socketFactory, "newSSLContext().apply {\n…ll)\n      }.socketFactory");
              return socketFactory;
          } catch (GeneralSecurityException e) {
              throw new AssertionError("No System TLS: " + e, e);
          }
      }
  
      public X509TrustManager platformTrustManager() {
          String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
          Log1F380D.a((Object) defaultAlgorithm);
          TrustManagerFactory instance = TrustManagerFactory.getInstance(defaultAlgorithm);
          KeyStore keyStore = null;
          instance.init((KeyStore) null);
          Intrinsics.checkNotNullExpressionValue(instance, "factory");
          TrustManager[] trustManagers = instance.getTrustManagers();
          Intrinsics.checkNotNull(trustManagers);
          boolean z = true;
          if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
              z = false;
          }
          if (z) {
              TrustManager trustManager = trustManagers[0];
              if (trustManager != null) {
                  return (X509TrustManager) trustManager;
              }
              throw new NullPointerException("null cannot be cast to non-null type javax.net.ssl.X509TrustManager");
          }
          StringBuilder append = new StringBuilder().append("Unexpected default trust managers: ");
          String arrays = Arrays.toString(trustManagers);
          Log1F380D.a((Object) arrays);
          Intrinsics.checkNotNullExpressionValue(arrays, "java.util.Arrays.toString(this)");
          throw new IllegalStateException(append.append(arrays).toString().toString());
      }
  
      public String toString() {
          String simpleName = getClass().getSimpleName();
          Intrinsics.checkNotNullExpressionValue(simpleName, "javaClass.simpleName");
          return simpleName;
      }
  
      public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
          Intrinsics.checkNotNullParameter(sslSocketFactory, "sslSocketFactory");
          try {
              Class<?> cls = Class.forName("sun.security.ssl.SSLContextImpl");
              Intrinsics.checkNotNullExpressionValue(cls, "sslContextClass");
              Object readFieldOrNull = Util.readFieldOrNull(sslSocketFactory, cls, "context");
              if (readFieldOrNull != null) {
                  return (X509TrustManager) Util.readFieldOrNull(readFieldOrNull, X509TrustManager.class, "trustManager");
              }
              return null;
          } catch (ClassNotFoundException e) {
              return null;
          }
      }
  }
  