Skip to content

Commit f37a594

Browse files
authored
Merge pull request #99 from ConnectSDK/PLAT-47664-anishtd
PLAT-47664: LG TV Plus app crash on disconnecting TV in android 8.1.0
2 parents 48df1d7 + 1644547 commit f37a594

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

libs/Java-WebSocket-1.3.7.jar

112 KB
Binary file not shown.

libs/java-websocket-patch.jar

-106 KB
Binary file not shown.

src/com/connectsdk/service/webos/WebOSTVMouseSocketConnection.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@
2020

2121
package com.connectsdk.service.webos;
2222

23+
import java.io.IOException;
2324
import java.net.URI;
2425
import java.net.URISyntaxException;
26+
import java.security.KeyException;
27+
import java.security.NoSuchAlgorithmException;
28+
29+
import javax.net.ssl.SSLContext;
2530

2631
import org.java_websocket.WebSocket.READYSTATE;
2732
import org.java_websocket.client.WebSocketClient;
@@ -95,14 +100,19 @@ public void onClose(int arg0, String arg1, boolean arg2) {
95100
SSLContext sslContext = SSLContext.getInstance("TLS");
96101
customTrustManager = new WebOSTVTrustManager();
97102
sslContext.init(null, new WebOSTVTrustManager[] {customTrustManager}, null);
98-
WebSocketClient.WebSocketClientFactory fac = new DefaultSSLWebSocketClientFactory(sslContext);
99-
ws.setWebSocketFactory(fac);
103+
//Web-Socket 1.3.7 patch
104+
ws.setSocket(sslContext.getSocketFactory().createSocket());
105+
ws.setConnectionLostTimeout(0);
100106
} catch (KeyException e) {
101107
e.printStackTrace();
102108
} catch (NoSuchAlgorithmException e) {
103109
e.printStackTrace();
110+
} catch (IOException e) {
111+
e.printStackTrace();
112+
} catch (RuntimeException e) {
113+
e.printStackTrace();
104114
}
105-
115+
//patch ends
106116
ws.connect();
107117
}
108118

src/com/connectsdk/service/webos/WebOSTVServiceSocketClient.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.connectsdk.service.webos;
22

33
import java.io.ByteArrayInputStream;
4+
import java.io.IOException;
45
import java.io.UnsupportedEncodingException;
56
import java.net.URI;
67
import java.net.URISyntaxException;
@@ -10,17 +11,14 @@
1011
import java.security.cert.CertificateException;
1112
import java.security.cert.CertificateFactory;
1213
import java.security.cert.X509Certificate;
13-
import java.util.Arrays;
1414
import java.util.Iterator;
1515
import java.util.LinkedHashSet;
1616
import java.util.List;
1717
import java.util.Locale;
1818

1919
import javax.net.ssl.SSLContext;
20-
import javax.net.ssl.X509TrustManager;
2120

2221
import org.java_websocket.WebSocket;
23-
import org.java_websocket.client.DefaultSSLWebSocketClientFactory;
2422
import org.java_websocket.client.WebSocketClient;
2523
import org.java_websocket.handshake.ServerHandshake;
2624
import org.json.JSONArray;
@@ -678,14 +676,23 @@ else if (payloadType.equals("hello")) {
678676
}
679677

680678
private void setSSLContext(SSLContext sslContext) {
681-
setWebSocketFactory(new DefaultSSLWebSocketClientFactory(sslContext));
679+
//Web-Socket 1.3.7 patch
680+
try {
681+
setSocket(sslContext.getSocketFactory().createSocket());
682+
setConnectionLostTimeout(0);
683+
} catch (IOException e) {
684+
e.printStackTrace();
685+
} catch (RuntimeException e) {
686+
e.printStackTrace();
687+
}
688+
//patch ends
682689
}
683690

684691
protected void setupSSL() {
685692
try {
686693
SSLContext sslContext = SSLContext.getInstance("TLS");
687-
customTrustManager = new TrustManager();
688-
sslContext.init(null, new TrustManager [] {customTrustManager}, null);
694+
customTrustManager = new WebOSTVTrustManager();
695+
sslContext.init(null, new WebOSTVTrustManager [] {customTrustManager}, null);
689696
setSSLContext(sslContext);
690697

691698
if (!(mService.getServiceConfig() instanceof WebOSTVServiceConfig)) {

0 commit comments

Comments
 (0)