content: package okhttp3.internal.connection;
  
  import java.io.IOException;
  import java.io.InterruptedIOException;
  import java.net.ProtocolException;
  import java.net.UnknownServiceException;
  import java.security.cert.CertificateException;
  import java.util.Arrays;
  import java.util.List;
  import javax.net.ssl.SSLException;
  import javax.net.ssl.SSLHandshakeException;
  import javax.net.ssl.SSLPeerUnverifiedException;
  import javax.net.ssl.SSLSocket;
  import kotlin.Metadata;
  import kotlin.jvm.internal.Intrinsics;
  import mt.Log1F380D;
  import okhttp3.ConnectionSpec;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0000\u0018\u00002\u00020\u0001B\u0013\u0012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003¢\u0006\u0002\u0010\u0005J\u000e\u0010\u000b\u001a\u00020\u00042\u0006\u0010\f\u001a\u00020\rJ\u000e\u0010\u000e\u001a\u00020\u00072\u0006\u0010\u000f\u001a\u00020\u0010J\u0010\u0010\b\u001a\u00020\u00072\u0006\u0010\u0011\u001a\u00020\rH\u0002R\u0014\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0007X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u000e¢\u0006\u0002\n\u0000¨\u0006\u0012"}, d2 = {"Lokhttp3/internal/connection/ConnectionSpecSelector;", "", "connectionSpecs", "", "Lokhttp3/ConnectionSpec;", "(Ljava/util/List;)V", "isFallback", "", "isFallbackPossible", "nextModeIndex", "", "configureSecureSocket", "sslSocket", "Ljavax/net/ssl/SSLSocket;", "connectionFailed", "e", "Ljava/io/IOException;", "socket", "okhttp"}, k = 1, mv = {1, 4, 0})
  /* compiled from: 01CA */
  public final class ConnectionSpecSelector {
      private final List<ConnectionSpec> connectionSpecs;
      private boolean isFallback;
      private boolean isFallbackPossible;
      private int nextModeIndex;
  
      public ConnectionSpecSelector(List<ConnectionSpec> connectionSpecs2) {
          Intrinsics.checkNotNullParameter(connectionSpecs2, "connectionSpecs");
          this.connectionSpecs = connectionSpecs2;
      }
  
      private final boolean isFallbackPossible(SSLSocket socket) {
          int size = this.connectionSpecs.size();
          for (int i = this.nextModeIndex; i < size; i++) {
              if (this.connectionSpecs.get(i).isCompatible(socket)) {
                  return true;
              }
          }
          return false;
      }
  
      public final ConnectionSpec configureSecureSocket(SSLSocket sslSocket) throws IOException {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
          ConnectionSpec connectionSpec = null;
          int i = this.nextModeIndex;
          int size = this.connectionSpecs.size();
          while (true) {
              if (i >= size) {
                  break;
              }
              ConnectionSpec connectionSpec2 = this.connectionSpecs.get(i);
              if (connectionSpec2.isCompatible(sslSocket)) {
                  connectionSpec = connectionSpec2;
                  this.nextModeIndex = i + 1;
                  break;
              }
              i++;
          }
          if (connectionSpec != null) {
              this.isFallbackPossible = isFallbackPossible(sslSocket);
              connectionSpec.apply$okhttp(sslSocket, this.isFallback);
              return connectionSpec;
          }
          StringBuilder append = new StringBuilder().append("Unable to find acceptable protocols. isFallback=").append(this.isFallback).append(',').append(" modes=").append(this.connectionSpecs).append(',').append(" supported protocols=");
          String[] enabledProtocols = sslSocket.getEnabledProtocols();
          Intrinsics.checkNotNull(enabledProtocols);
          String arrays = Arrays.toString(enabledProtocols);
          Log1F380D.a((Object) arrays);
          Intrinsics.checkNotNullExpressionValue(arrays, "java.util.Arrays.toString(this)");
          throw new UnknownServiceException(append.append(arrays).toString());
      }
  
      public final boolean connectionFailed(IOException e) {
          Intrinsics.checkNotNullParameter(e, "e");
          this.isFallback = true;
          if (!this.isFallbackPossible) {
              return false;
          }
          if (e instanceof ProtocolException) {
              return false;
          }
          if (e instanceof InterruptedIOException) {
              return false;
          }
          if ((e instanceof SSLHandshakeException) && (e.getCause() instanceof CertificateException)) {
              return false;
          }
          if (e instanceof SSLPeerUnverifiedException) {
              return false;
          }
          return e instanceof SSLException;
      }
  }
  