package okhttp3.internal.platform.android; import java.util.List; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; import o.C14957gcv; import okhttp3.Protocol; import okhttp3.internal.platform.android.SocketAdapter; /* loaded from: classes.dex */ public final class DeferredSocketAdapter implements SocketAdapter { private SocketAdapter delegate; private final Factory socketAdapterFactory; /* loaded from: classes.dex */ public interface Factory { SocketAdapter create(SSLSocket sSLSocket); boolean matchesSocket(SSLSocket sSLSocket); } @Override // okhttp3.internal.platform.android.SocketAdapter public final boolean isSupported() { return true; } public DeferredSocketAdapter(Factory factory) { C14957gcv.e(factory, ""); this.socketAdapterFactory = factory; } @Override // okhttp3.internal.platform.android.SocketAdapter public final boolean matchesSocketFactory(SSLSocketFactory sSLSocketFactory) { return SocketAdapter.DefaultImpls.matchesSocketFactory(this, sSLSocketFactory); } @Override // okhttp3.internal.platform.android.SocketAdapter public final X509TrustManager trustManager(SSLSocketFactory sSLSocketFactory) { return SocketAdapter.DefaultImpls.trustManager(this, sSLSocketFactory); } @Override // okhttp3.internal.platform.android.SocketAdapter public final boolean matchesSocket(SSLSocket sSLSocket) { C14957gcv.e(sSLSocket, ""); return this.socketAdapterFactory.matchesSocket(sSLSocket); } @Override // okhttp3.internal.platform.android.SocketAdapter public final void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) { C14957gcv.e(sSLSocket, ""); C14957gcv.e(list, ""); SocketAdapter delegate = getDelegate(sSLSocket); if (delegate != null) { delegate.configureTlsExtensions(sSLSocket, str, list); } } @Override // okhttp3.internal.platform.android.SocketAdapter public final String getSelectedProtocol(SSLSocket sSLSocket) { C14957gcv.e(sSLSocket, ""); SocketAdapter delegate = getDelegate(sSLSocket); if (delegate == null) { return null; } return delegate.getSelectedProtocol(sSLSocket); } private final SocketAdapter getDelegate(SSLSocket sSLSocket) { SocketAdapter socketAdapter; synchronized (this) { if (this.delegate == null && this.socketAdapterFactory.matchesSocket(sSLSocket)) { this.delegate = this.socketAdapterFactory.create(sSLSocket); } socketAdapter = this.delegate; } return socketAdapter; } }