package okhttp3.internal.platform.android; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; import o.C14953gcr; import o.C14957gcv; import okhttp3.internal.Util; import okhttp3.internal.platform.Platform; /* loaded from: classes.dex */ public final class StandardAndroidSocketAdapter extends AndroidSocketAdapter { public static final Companion Companion = new Companion(null); private final Class paramClass; private final Class sslSocketFactoryClass; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public StandardAndroidSocketAdapter(Class cls, Class cls2, Class cls3) { super(cls); C14957gcv.e(cls, ""); C14957gcv.e(cls2, ""); C14957gcv.e(cls3, ""); this.sslSocketFactoryClass = cls2; this.paramClass = cls3; } @Override // okhttp3.internal.platform.android.AndroidSocketAdapter, okhttp3.internal.platform.android.SocketAdapter public final boolean matchesSocketFactory(SSLSocketFactory sSLSocketFactory) { C14957gcv.e(sSLSocketFactory, ""); return this.sslSocketFactoryClass.isInstance(sSLSocketFactory); } @Override // okhttp3.internal.platform.android.AndroidSocketAdapter, okhttp3.internal.platform.android.SocketAdapter public final X509TrustManager trustManager(SSLSocketFactory sSLSocketFactory) { C14957gcv.e(sSLSocketFactory, ""); Object readFieldOrNull = Util.readFieldOrNull(sSLSocketFactory, this.paramClass, "sslParameters"); C14957gcv.e(readFieldOrNull); X509TrustManager x509TrustManager = (X509TrustManager) Util.readFieldOrNull(readFieldOrNull, X509TrustManager.class, "x509TrustManager"); return x509TrustManager == null ? (X509TrustManager) Util.readFieldOrNull(readFieldOrNull, X509TrustManager.class, "trustManager") : x509TrustManager; } /* loaded from: classes.dex */ public static final class Companion { private Companion() { } public static /* synthetic */ SocketAdapter buildIfSupported$default(Companion companion, String str, int i, Object obj) { if ((i & 1) != 0) { str = "com.android.org.conscrypt"; } return companion.buildIfSupported(str); } public final SocketAdapter buildIfSupported(String str) { C14957gcv.e(str, ""); try { Class cls = Class.forName(C14957gcv.c(str, (Object) ".OpenSSLSocketImpl")); if (cls == null) { throw new NullPointerException("null cannot be cast to non-null type java.lang.Class"); } Class cls2 = Class.forName(C14957gcv.c(str, (Object) ".OpenSSLSocketFactoryImpl")); if (cls2 == null) { throw new NullPointerException("null cannot be cast to non-null type java.lang.Class"); } Class cls3 = Class.forName(C14957gcv.c(str, (Object) ".SSLParametersImpl")); C14957gcv.c(cls3, ""); return new StandardAndroidSocketAdapter(cls, cls2, cls3); } catch (Exception e) { Platform.Companion.get().log("unable to load android socket classes", 5, e); return null; } } public /* synthetic */ Companion(C14953gcr c14953gcr) { this(); } } }