diff --git a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java index 3b833650..1b1c5e79 100644 --- a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java +++ b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java @@ -75,10 +75,12 @@ import io.netty.util.concurrent.GenericFutureListener; public class LanLinkProvider extends BaseLinkProvider { + public static final int MIN_VERSION_WITH_SSL_SUPPORT = 6; + public static final String KEY_CUSTOM_DEVLIST_PREFERENCE = "device_list_preference"; + private final static int oldPort = 1714; private final static int port = 1716; - private static final int MIN_VERSION_WITH_SSL_SUPPORT = 6; private final Context context; @@ -89,7 +91,7 @@ public class LanLinkProvider extends BaseLinkProvider { private TcpHandler tcpHandler = new TcpHandler(); private UdpHandler udpHandler = new UdpHandler(); - // To prevent infinte loop if both device can only broadcast identity package but cannot connect via TCO + // To prevent infinte loop between Android < IceCream because both device can only broadcast identity package but cannot connect via TCP private ArrayList reverseConnectionBlackList = new ArrayList<>(); private Timer reverseConnectionTimer; diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java index cde5450b..d15ea327 100644 --- a/src/org/kde/kdeconnect/Device.java +++ b/src/org/kde/kdeconnect/Device.java @@ -36,6 +36,7 @@ import android.util.Log; import org.kde.kdeconnect.Backends.BaseLink; import org.kde.kdeconnect.Backends.BasePairingHandler; +import org.kde.kdeconnect.Backends.LanBackend.LanLinkProvider; import org.kde.kdeconnect.Helpers.ObjectsHelper; import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper; import org.kde.kdeconnect.Plugins.Plugin; @@ -70,6 +71,8 @@ public class Device implements BaseLink.PackageReceiver { private int notificationId; private int protocolVersion; + private static final int MIN_VERSION_WITH_CAPPABILITIES_SUPPORT = 6; + private DeviceType deviceType; private PairStatus pairStatus; @@ -639,7 +642,7 @@ public class Device implements BaseLink.PackageReceiver { hackToMakeRetrocompatiblePacketTypes(np); - if (protocolVersion >= 6 && !supportedOutgoingInterfaces.contains(np.getType()) && !NetworkPackage.protocolPackageTypes.contains(np.getType())) { + if (protocolVersion >= MIN_VERSION_WITH_CAPPABILITIES_SUPPORT && !supportedOutgoingInterfaces.contains(np.getType()) && !NetworkPackage.protocolPackageTypes.contains(np.getType())) { Log.e("Device/sendPackage", "Plugin tried to send an unsupported package: " + np.getType()); Log.e("Device/sendPackage", "Supported package types: " + Arrays.toString(supportedOutgoingInterfaces.toArray())); } @@ -652,7 +655,7 @@ public class Device implements BaseLink.PackageReceiver { @Override public void run() { - boolean useEncryption = (protocolVersion < 6 && (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_PAIR) && isPaired())); + boolean useEncryption = (protocolVersion < LanLinkProvider.MIN_VERSION_WITH_SSL_SUPPORT && (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_PAIR) && isPaired())); //Make a copy to avoid concurrent modification exception if the original list changes for (final BaseLink link : links) { @@ -786,7 +789,7 @@ public class Device implements BaseLink.PackageReceiver { HashMap> newPluginsByIncomingInterface = new HashMap<>(); HashMap> newPluginsByOutgoingInterface = new HashMap<>(); - final boolean supportsCapabilities = (protocolVersion >= 6); + final boolean supportsCapabilities = (protocolVersion >= MIN_VERSION_WITH_CAPPABILITIES_SUPPORT); for (String pluginKey : availablePlugins) { @@ -868,7 +871,7 @@ public class Device implements BaseLink.PackageReceiver { onPluginsChanged(); //Only send capabilities to devices using protocol version 6 or later - if (capabilitiesChanged && isReachable() && isPaired() && protocolVersion >= 6) { + if (capabilitiesChanged && isReachable() && isPaired() && protocolVersion >= MIN_VERSION_WITH_CAPPABILITIES_SUPPORT) { NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_CAPABILITIES); np.set("IncomingCapabilities", new ArrayList<>(newSupportedIncomingInterfaces)); np.set("OutgoingCapabilities", new ArrayList<>(newSupportedOutgoingInterfaces)); @@ -915,12 +918,12 @@ public class Device implements BaseLink.PackageReceiver { } public void hackToMakeRetrocompatiblePacketTypes(NetworkPackage np) { - if (protocolVersion >= 6) return; + if (protocolVersion >= MIN_VERSION_WITH_CAPPABILITIES_SUPPORT) return; np.mType = np.getType().replace(".request",""); } public String hackToMakeRetrocompatiblePacketTypes(String type) { - if (protocolVersion >= 6) return type; + if (protocolVersion >= MIN_VERSION_WITH_CAPPABILITIES_SUPPORT) return type; return type.replace(".request",""); }