content: package okhttp3.internal.platform.android;
  
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.nio.charset.Charset;
  import java.nio.charset.StandardCharsets;
  import java.util.List;
  import javax.net.ssl.SSLSocket;
  import javax.net.ssl.SSLSocketFactory;
  import javax.net.ssl.X509TrustManager;
  import kotlin.Metadata;
  import kotlin.jvm.internal.DefaultConstructorMarker;
  import kotlin.jvm.internal.Intrinsics;
  import mt.Log1F380D;
  import okhttp3.Protocol;
  import okhttp3.internal.platform.AndroidPlatform;
  import okhttp3.internal.platform.Platform;
  import okhttp3.internal.platform.android.DeferredSocketAdapter;
  import okhttp3.internal.platform.android.SocketAdapter;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\b\u0016\u0018\u0000 \u00182\u00020\u0001:\u0001\u0018B\u0015\u0012\u000e\u0010\u0002\u001a\n\u0012\u0006\b\u0000\u0012\u00020\u00040\u0003¢\u0006\u0002\u0010\u0005J(\u0010\f\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u00042\b\u0010\u000f\u001a\u0004\u0018\u00010\u00102\f\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00130\u0012H\u0016J\u0012\u0010\u0014\u001a\u0004\u0018\u00010\u00102\u0006\u0010\u000e\u001a\u00020\u0004H\u0016J\b\u0010\u0015\u001a\u00020\u0016H\u0016J\u0010\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u000e\u001a\u00020\u0004H\u0016R\u0016\u0010\u0006\u001a\n \b*\u0004\u0018\u00010\u00070\u0007X\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\t\u001a\n \b*\u0004\u0018\u00010\u00070\u0007X\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\n\u001a\n \b*\u0004\u0018\u00010\u00070\u0007X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\u0007X\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\u0002\u001a\n\u0012\u0006\b\u0000\u0012\u00020\u00040\u0003X\u0004¢\u0006\u0002\n\u0000¨\u0006\u0019"}, d2 = {"Lokhttp3/internal/platform/android/AndroidSocketAdapter;", "Lokhttp3/internal/platform/android/SocketAdapter;", "sslSocketClass", "Ljava/lang/Class;", "Ljavax/net/ssl/SSLSocket;", "(Ljava/lang/Class;)V", "getAlpnSelectedProtocol", "Ljava/lang/reflect/Method;", "kotlin.jvm.PlatformType", "setAlpnProtocols", "setHostname", "setUseSessionTickets", "configureTlsExtensions", "", "sslSocket", "hostname", "", "protocols", "", "Lokhttp3/Protocol;", "getSelectedProtocol", "isSupported", "", "matchesSocket", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
  /* compiled from: 01DF */
  public class AndroidSocketAdapter implements SocketAdapter {
      public static final Companion Companion;
      /* access modifiers changed from: private */
      public static final DeferredSocketAdapter.Factory playProviderFactory;
      private final Method getAlpnSelectedProtocol;
      private final Method setAlpnProtocols;
      private final Method setHostname;
      private final Method setUseSessionTickets;
      private final Class<? super SSLSocket> sslSocketClass;
  
      @Metadata(bv = {1, 0, 3}, d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\b\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0018\u0010\u0007\u001a\u00020\b2\u000e\u0010\t\u001a\n\u0012\u0006\b\u0000\u0012\u00020\u000b0\nH\u0002J\u000e\u0010\f\u001a\u00020\u00042\u0006\u0010\r\u001a\u00020\u000eR\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\u000f"}, d2 = {"Lokhttp3/internal/platform/android/AndroidSocketAdapter$Companion;", "", "()V", "playProviderFactory", "Lokhttp3/internal/platform/android/DeferredSocketAdapter$Factory;", "getPlayProviderFactory", "()Lokhttp3/internal/platform/android/DeferredSocketAdapter$Factory;", "build", "Lokhttp3/internal/platform/android/AndroidSocketAdapter;", "actualSSLSocketClass", "Ljava/lang/Class;", "Ljavax/net/ssl/SSLSocket;", "factory", "packageName", "", "okhttp"}, k = 1, mv = {1, 4, 0})
      /* compiled from: AndroidSocketAdapter.kt */
      public static final class Companion {
          private Companion() {
          }
  
          public /* synthetic */ Companion(DefaultConstructorMarker $constructor_marker) {
              this();
          }
  
          /* access modifiers changed from: private */
          public final AndroidSocketAdapter build(Class<? super SSLSocket> actualSSLSocketClass) {
              Class<? super SSLSocket> cls = actualSSLSocketClass;
              while (cls != null && (!Intrinsics.areEqual((Object) cls.getSimpleName(), (Object) "OpenSSLSocketImpl"))) {
                  cls = cls.getSuperclass();
                  if (cls == null) {
                      throw new AssertionError("No OpenSSLSocketImpl superclass of socket of type " + actualSSLSocketClass);
                  }
              }
              Intrinsics.checkNotNull(cls);
              return new AndroidSocketAdapter(cls);
          }
  
          public final DeferredSocketAdapter.Factory factory(String packageName) {
              Intrinsics.checkNotNullParameter(packageName, "packageName");
              return new AndroidSocketAdapter$Companion$factory$1(packageName);
          }
  
          public final DeferredSocketAdapter.Factory getPlayProviderFactory() {
              return AndroidSocketAdapter.playProviderFactory;
          }
      }
  
      static {
          Companion companion = new Companion((DefaultConstructorMarker) null);
          Companion = companion;
          playProviderFactory = companion.factory("com.google.android.gms.org.conscrypt");
      }
  
      public AndroidSocketAdapter(Class<? super SSLSocket> sslSocketClass2) {
          Intrinsics.checkNotNullParameter(sslSocketClass2, "sslSocketClass");
          this.sslSocketClass = sslSocketClass2;
          Method declaredMethod = sslSocketClass2.getDeclaredMethod("setUseSessionTickets", new Class[]{Boolean.TYPE});
          Intrinsics.checkNotNullExpressionValue(declaredMethod, "sslSocketClass.getDeclar…:class.javaPrimitiveType)");
          this.setUseSessionTickets = declaredMethod;
          this.setHostname = sslSocketClass2.getMethod("setHostname", new Class[]{String.class});
          this.getAlpnSelectedProtocol = sslSocketClass2.getMethod("getAlpnSelectedProtocol", new Class[0]);
          this.setAlpnProtocols = sslSocketClass2.getMethod("setAlpnProtocols", new Class[]{byte[].class});
      }
  
      public void configureTlsExtensions(SSLSocket sslSocket, String hostname, List<? extends Protocol> protocols) {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
          Intrinsics.checkNotNullParameter(protocols, "protocols");
          if (matchesSocket(sslSocket)) {
              try {
                  this.setUseSessionTickets.invoke(sslSocket, new Object[]{true});
                  if (hostname != null) {
                      this.setHostname.invoke(sslSocket, new Object[]{hostname});
                  }
                  this.setAlpnProtocols.invoke(sslSocket, new Object[]{Platform.Companion.concatLengthPrefixed(protocols)});
              } catch (IllegalAccessException e) {
                  throw new AssertionError(e);
              } catch (InvocationTargetException e2) {
                  throw new AssertionError(e2);
              }
          }
      }
  
      public String getSelectedProtocol(SSLSocket sslSocket) {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
          if (!matchesSocket(sslSocket)) {
              return null;
          }
          try {
              byte[] bArr = (byte[]) this.getAlpnSelectedProtocol.invoke(sslSocket, new Object[0]);
              if (bArr == null) {
                  return null;
              }
              Charset charset = StandardCharsets.UTF_8;
              Intrinsics.checkNotNullExpressionValue(charset, "StandardCharsets.UTF_8");
              String str = new String(bArr, charset);
              Log1F380D.a((Object) str);
              return str;
          } catch (NullPointerException e) {
              if (Intrinsics.areEqual((Object) e.getMessage(), (Object) "ssl == null")) {
                  String str2 = null;
                  return null;
              }
              throw e;
          } catch (IllegalAccessException e2) {
              throw new AssertionError(e2);
          } catch (InvocationTargetException e3) {
              throw new AssertionError(e3);
          }
      }
  
      public boolean isSupported() {
          return AndroidPlatform.Companion.isSupported();
      }
  
      public boolean matchesSocket(SSLSocket sslSocket) {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
          return this.sslSocketClass.isInstance(sslSocket);
      }
  
      public boolean matchesSocketFactory(SSLSocketFactory sslSocketFactory) {
          Intrinsics.checkNotNullParameter(sslSocketFactory, "sslSocketFactory");
          return SocketAdapter.DefaultImpls.matchesSocketFactory(this, sslSocketFactory);
      }
  
      public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
          Intrinsics.checkNotNullParameter(sslSocketFactory, "sslSocketFactory");
          return SocketAdapter.DefaultImpls.trustManager(this, sslSocketFactory);
      }
  }
  