mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 06:05:12 +00:00
Do the kdeconnect handshake in a new thread
Some Android versions seem to hang if calling sslSocket.getOutputStream() from within the HandshakeCompleted callback (maybe because calling it in on a socket that hasn't finished the SSL handshake is supposed to trigger the SSL handshake). BUG: 501241
This commit is contained in:
@@ -255,6 +255,8 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
final boolean clientMode = (connectionStarted == LanLink.ConnectionStarted.Locally);
|
final boolean clientMode = (connectionStarted == LanLink.ConnectionStarted.Locally);
|
||||||
final SSLSocket sslSocket = SslHelper.convertToSslSocket(context, socket, deviceId, deviceTrusted, clientMode);
|
final SSLSocket sslSocket = SslHelper.convertToSslSocket(context, socket, deviceId, deviceTrusted, clientMode);
|
||||||
sslSocket.addHandshakeCompletedListener(event -> {
|
sslSocket.addHandshakeCompletedListener(event -> {
|
||||||
|
// Start a new thread because some Android versions don't allow calling sslSocket.getOutputStream() from the callback
|
||||||
|
ThreadHelper.execute(() -> {
|
||||||
String mode = clientMode ? "client" : "server";
|
String mode = clientMode ? "client" : "server";
|
||||||
try {
|
try {
|
||||||
NetworkPacket secureIdentityPacket;
|
NetworkPacket secureIdentityPacket;
|
||||||
@@ -287,6 +289,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
Log.e("KDE/LanLinkProvider", "Handshake as " + mode + " failed with " + deviceName, e);
|
Log.e("KDE/LanLinkProvider", "Handshake as " + mode + " failed with " + deviceName, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//Handshake is blocking, so do it on another thread and free this thread to keep receiving new connection
|
//Handshake is blocking, so do it on another thread and free this thread to keep receiving new connection
|
||||||
Log.d("LanLinkProvider", "Starting handshake");
|
Log.d("LanLinkProvider", "Starting handshake");
|
||||||
|
Reference in New Issue
Block a user