From 9a9ce47a5f0217405aa96c00598d4080edad27f3 Mon Sep 17 00:00:00 2001 From: tehcneko <7764726+tehcneko@users.noreply.github.com> Date: Sat, 10 Apr 2021 10:02:27 +0800 Subject: [PATCH] Fix bug with new clash for android --- app/build.gradle | 1 - .../com/hippo/ehviewer/client/EhSSLSocketFactory.java | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 375d67e04..da9af594d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -134,7 +134,6 @@ dependencies { implementation 'com.github.seven332:yorozuya-thread:0.1.1' implementation 'com.github.seven332:yorozuya-collect:0.1.4' implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0' - def appCenterSdkVersion = '4.1.0' implementation "com.microsoft.appcenter:appcenter-analytics:4.1.1" implementation "com.microsoft.appcenter:appcenter-crashes:4.1.1" implementation "com.microsoft.appcenter:appcenter-distribute:4.1.1" diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java b/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java index 62b3c6711..9c1193c48 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.java @@ -25,15 +25,14 @@ public class EhSSLSocketFactory extends SSLSocketFactory { @Override public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { + SSLSocketFactory defaultFactory = (SSLSocketFactory) getDefault(); if (!Settings.getDF()) { - return ((SSLSocketFactory) getDefault()).createSocket(s, host, port, autoClose); + return defaultFactory.createSocket(s, host, port, autoClose); } - InetAddress address = s.getInetAddress(); - // okhttp 4.9 don't like this - //if (autoClose) s.close(); - SSLSocket socket = (SSLSocket) getDefault().createSocket(address, port); + String address = s.getInetAddress().getHostAddress(); + SSLSocket socket = (SSLSocket) defaultFactory.createSocket(s, address, port, autoClose); SSLSession sslSession = socket.getSession(); - Log.d("EhSSLSocketFactory", "Host: " + host + " Address: " + address.getHostAddress() + " Protocol:" + sslSession.getProtocol() + " CipherSuite:" + sslSession.getCipherSuite()); + Log.d("EhSSLSocketFactory", "Host: " + host + " Address: " + address + " Protocol:" + sslSession.getProtocol() + " CipherSuite:" + sslSession.getCipherSuite()); socket.setEnabledProtocols(socket.getSupportedProtocols()); return socket; }