@Test public void createNegotiator_isAndroidLegacy() { ClassLoader cl = new ClassLoader(this.getClass().getClassLoader()) { @Override protected Class<?> findClass(String name) throws ClassNotFoundException { if ("org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl".equals(name)) { return null; } return super.findClass(name); } }; OkHttpProtocolNegotiator negotiator = OkHttpProtocolNegotiator.createNegotiator(cl); assertEquals(AndroidNegotiator.class, negotiator.getClass()); }
@VisibleForTesting static OkHttpProtocolNegotiator createNegotiator(ClassLoader loader) { boolean android = true; try { loader.loadClass("com.android.org.conscrypt.OpenSSLSocketImpl"); } catch (ClassNotFoundException e1) { logger.log(Level.FINE, "Unable to find Conscrypt. Skipping", e1); try { loader.loadClass("org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl"); } catch (ClassNotFoundException e2) { logger.log(Level.FINE, "Unable to find any OpenSSLSocketImpl. Skipping", e2); android = false; } } return android ? new AndroidNegotiator(DEFAULT_PLATFORM) : new OkHttpProtocolNegotiator(DEFAULT_PLATFORM); }
OkHttpProtocolNegotiator { @VisibleForTesting static OkHttpProtocolNegotiator createNegotiator(ClassLoader loader) { boolean android = true; try { loader.loadClass("com.android.org.conscrypt.OpenSSLSocketImpl"); } catch (ClassNotFoundException e1) { logger.log(Level.FINE, "Unable to find Conscrypt. Skipping", e1); try { loader.loadClass("org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl"); } catch (ClassNotFoundException e2) { logger.log(Level.FINE, "Unable to find any OpenSSLSocketImpl. Skipping", e2); android = false; } } return android ? new AndroidNegotiator(DEFAULT_PLATFORM) : new OkHttpProtocolNegotiator(DEFAULT_PLATFORM); } }
OkHttpProtocolNegotiator { @VisibleForTesting static OkHttpProtocolNegotiator createNegotiator(ClassLoader loader) { boolean android = true; try { loader.loadClass("com.android.org.conscrypt.OpenSSLSocketImpl"); } catch (ClassNotFoundException e1) { logger.log(Level.FINE, "Unable to find Conscrypt. Skipping", e1); try { loader.loadClass("org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl"); } catch (ClassNotFoundException e2) { logger.log(Level.FINE, "Unable to find any OpenSSLSocketImpl. Skipping", e2); android = false; } } return android ? new AndroidNegotiator(DEFAULT_PLATFORM) : new OkHttpProtocolNegotiator(DEFAULT_PLATFORM); } @VisibleForTesting  OkHttpProtocolNegotiator(Platform platform); }
OkHttpProtocolNegotiator { @VisibleForTesting static OkHttpProtocolNegotiator createNegotiator(ClassLoader loader) { boolean android = true; try { loader.loadClass("com.android.org.conscrypt.OpenSSLSocketImpl"); } catch (ClassNotFoundException e1) { logger.log(Level.FINE, "Unable to find Conscrypt. Skipping", e1); try { loader.loadClass("org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl"); } catch (ClassNotFoundException e2) { logger.log(Level.FINE, "Unable to find any OpenSSLSocketImpl. Skipping", e2); android = false; } } return android ? new AndroidNegotiator(DEFAULT_PLATFORM) : new OkHttpProtocolNegotiator(DEFAULT_PLATFORM); } @VisibleForTesting  OkHttpProtocolNegotiator(Platform platform); static OkHttpProtocolNegotiator get(); String negotiate(
      SSLSocket sslSocket, String hostname, @Nullable List<Protocol> protocols); String getSelectedProtocol(SSLSocket socket); }
OkHttpProtocolNegotiator { @VisibleForTesting static OkHttpProtocolNegotiator createNegotiator(ClassLoader loader) { boolean android = true; try { loader.loadClass("com.android.org.conscrypt.OpenSSLSocketImpl"); } catch (ClassNotFoundException e1) { logger.log(Level.FINE, "Unable to find Conscrypt. Skipping", e1); try { loader.loadClass("org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl"); } catch (ClassNotFoundException e2) { logger.log(Level.FINE, "Unable to find any OpenSSLSocketImpl. Skipping", e2); android = false; } } return android ? new AndroidNegotiator(DEFAULT_PLATFORM) : new OkHttpProtocolNegotiator(DEFAULT_PLATFORM); } @VisibleForTesting  OkHttpProtocolNegotiator(Platform platform); static OkHttpProtocolNegotiator get(); String negotiate(
      SSLSocket sslSocket, String hostname, @Nullable List<Protocol> protocols); String getSelectedProtocol(SSLSocket socket);  }