package okhttp3.internal.platform; import android.security.NetworkSecurityPolicy; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; import kotlin.Metadata; import kotlin.collections.CollectionsKt; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import okhttp3.Protocol; import okhttp3.internal.platform.android.Android10SocketAdapter; import okhttp3.internal.platform.android.AndroidCertificateChainCleaner; import okhttp3.internal.platform.android.AndroidSocketAdapter; import okhttp3.internal.platform.android.BouncyCastleSocketAdapter; import okhttp3.internal.platform.android.ConscryptSocketAdapter; import okhttp3.internal.platform.android.DeferredSocketAdapter; import okhttp3.internal.platform.android.SocketAdapter; import okhttp3.internal.tls.CertificateChainCleaner; /* compiled from: Android10Platform.kt */ @Metadata(bv = {1, 0, 3}, d1 = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0007\u0018\u0000 \u00172\u00020\u0001:\u0001\u0017B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH\u0016J(\u0010\n\u001a\u00020\u000b2\u0006\u0010\f\u001a\u00020\r2\b\u0010\u000e\u001a\u0004\u0018\u00010\u000f2\f\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\u00110\u0004H\u0016J\u0012\u0010\u0012\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\f\u001a\u00020\rH\u0016J\u0010\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u000e\u001a\u00020\u000fH\u0017J\u0012\u0010\b\u001a\u0004\u0018\u00010\t2\u0006\u0010\u0015\u001a\u00020\u0016H\u0016R\u0014\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00050\u0004X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0018"}, d2 = {"Lokhttp3/internal/platform/Android10Platform;", "Lokhttp3/internal/platform/Platform;", "()V", "socketAdapters", "", "Lokhttp3/internal/platform/android/SocketAdapter;", "buildCertificateChainCleaner", "Lokhttp3/internal/tls/CertificateChainCleaner;", "trustManager", "Ljavax/net/ssl/X509TrustManager;", "configureTlsExtensions", "", "sslSocket", "Ljavax/net/ssl/SSLSocket;", "hostname", "", "protocols", "Lokhttp3/Protocol;", "getSelectedProtocol", "isCleartextTrafficPermitted", "", "sslSocketFactory", "Ljavax/net/ssl/SSLSocketFactory;", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0}) /* loaded from: classes3.dex */ public final class Android10Platform extends Platform { /* renamed from: Companion, reason: from kotlin metadata */ public static final Companion INSTANCE = new Companion(null); private static final boolean isSupported = Platform.INSTANCE.isAndroid(); private final List socketAdapters; public Android10Platform() { List listOfNotNull = CollectionsKt.listOfNotNull((Object[]) new SocketAdapter[]{Android10SocketAdapter.INSTANCE.buildIfSupported(), new DeferredSocketAdapter(AndroidSocketAdapter.INSTANCE.getPlayProviderFactory()), new DeferredSocketAdapter(ConscryptSocketAdapter.INSTANCE.getFactory()), new DeferredSocketAdapter(BouncyCastleSocketAdapter.INSTANCE.getFactory())}); ArrayList arrayList = new ArrayList(); for (Object obj : listOfNotNull) { if (((SocketAdapter) obj).isSupported()) { arrayList.add(obj); } } this.socketAdapters = arrayList; } @Override // okhttp3.internal.platform.Platform public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) { Object obj; Intrinsics.checkNotNullParameter(sslSocketFactory, "sslSocketFactory"); Iterator it = this.socketAdapters.iterator(); while (true) { if (!it.hasNext()) { obj = null; break; } obj = it.next(); if (((SocketAdapter) obj).matchesSocketFactory(sslSocketFactory)) { break; } } SocketAdapter socketAdapter = (SocketAdapter) obj; if (socketAdapter != null) { return socketAdapter.trustManager(sslSocketFactory); } return null; } @Override // okhttp3.internal.platform.Platform public void configureTlsExtensions(SSLSocket sslSocket, String hostname, List protocols) { Object obj; Intrinsics.checkNotNullParameter(sslSocket, "sslSocket"); Intrinsics.checkNotNullParameter(protocols, "protocols"); Iterator it = this.socketAdapters.iterator(); while (true) { if (!it.hasNext()) { obj = null; break; } else { obj = it.next(); if (((SocketAdapter) obj).matchesSocket(sslSocket)) { break; } } } SocketAdapter socketAdapter = (SocketAdapter) obj; if (socketAdapter != null) { socketAdapter.configureTlsExtensions(sslSocket, hostname, protocols); } } @Override // okhttp3.internal.platform.Platform public String getSelectedProtocol(SSLSocket sslSocket) { Object obj; Intrinsics.checkNotNullParameter(sslSocket, "sslSocket"); Iterator it = this.socketAdapters.iterator(); while (true) { if (!it.hasNext()) { obj = null; break; } obj = it.next(); if (((SocketAdapter) obj).matchesSocket(sslSocket)) { break; } } SocketAdapter socketAdapter = (SocketAdapter) obj; if (socketAdapter != null) { return socketAdapter.getSelectedProtocol(sslSocket); } return null; } @Override // okhttp3.internal.platform.Platform public boolean isCleartextTrafficPermitted(String hostname) { Intrinsics.checkNotNullParameter(hostname, "hostname"); return NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted(hostname); } @Override // okhttp3.internal.platform.Platform public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager trustManager) { Intrinsics.checkNotNullParameter(trustManager, "trustManager"); AndroidCertificateChainCleaner buildIfSupported = AndroidCertificateChainCleaner.INSTANCE.buildIfSupported(trustManager); return buildIfSupported != null ? buildIfSupported : super.buildCertificateChainCleaner(trustManager); } /* compiled from: Android10Platform.kt */ @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\b\u0010\u0006\u001a\u0004\u0018\u00010\u0007R\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0003\u0010\u0005¨\u0006\b"}, d2 = {"Lokhttp3/internal/platform/Android10Platform$Companion;", "", "()V", "isSupported", "", "()Z", "buildIfSupported", "Lokhttp3/internal/platform/Platform;", "okhttp"}, k = 1, mv = {1, 4, 0}) /* loaded from: classes3.dex */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final boolean isSupported() { return Android10Platform.isSupported; } public final Platform buildIfSupported() { if (isSupported()) { return new Android10Platform(); } return null; } } }