From 4dd651b386ea6d126cb5c2c8884de9eee98c97e4 Mon Sep 17 00:00:00 2001 From: Erik Duisters Date: Thu, 29 Nov 2018 16:33:13 +0100 Subject: [PATCH] Align NetworkPacket.hasPayload with desktop Summary: On desktop NetworkPacket.hasPayload() tests m_payloadSize On android NetworkPacket.hasPayload() tests mPayload This patch makes android also test mPayloadSize to make things more consistent Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D17236 --- src/org/kde/kdeconnect/Backends/LanBackend/LanLink.java | 3 +-- src/org/kde/kdeconnect/NetworkPacket.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/org/kde/kdeconnect/Backends/LanBackend/LanLink.java b/src/org/kde/kdeconnect/Backends/LanBackend/LanLink.java index 919a25c1..36523725 100644 --- a/src/org/kde/kdeconnect/Backends/LanBackend/LanLink.java +++ b/src/org/kde/kdeconnect/Backends/LanBackend/LanLink.java @@ -150,7 +150,7 @@ public class LanLink extends BaseLink { //Prepare socket for the payload final ServerSocket server; - if (np.hasPayload() && np.getPayloadSize() != 0) { + if (np.hasPayload()) { server = LanLinkProvider.openServerSocketOnFreePort(LanLinkProvider.PAYLOAD_TRANSFER_MIN_PORT); JSONObject payloadTransferInfo = new JSONObject(); payloadTransferInfo.put("port", server.getLocalPort()); @@ -263,7 +263,6 @@ public class LanLink extends BaseLink { } if (np.hasPayloadTransferInfo()) { - Socket payloadSocket = new Socket(); try { int tcpPort = np.getPayloadTransferInfo().getInt("port"); diff --git a/src/org/kde/kdeconnect/NetworkPacket.java b/src/org/kde/kdeconnect/NetworkPacket.java index 084d0729..3593a03b 100644 --- a/src/org/kde/kdeconnect/NetworkPacket.java +++ b/src/org/kde/kdeconnect/NetworkPacket.java @@ -309,7 +309,7 @@ public class NetworkPacket { } public boolean hasPayload() { - return (mPayload != null); + return (mPayloadSize != 0); } public boolean hasPayloadTransferInfo() {