diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0c351116..ac98525b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="1410" + android:versionName="1.4.1"> @@ -23,7 +23,7 @@ - + diff --git a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java index 1c728381..65c29aba 100644 --- a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java +++ b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java @@ -198,6 +198,20 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis SharedPreferences preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE); boolean isDeviceTrusted = preferences.getBoolean(deviceId, false); + if (isDeviceTrusted && !SslHelper.isCertificateStored(context, deviceId)) { + //Device paired with and old version, we can't use it as we lack the certificate + BackgroundService.RunCommand(context, new BackgroundService.InstanceCallback() { + @Override + public void onServiceStart(BackgroundService service) { + Device device = service.getDevice(deviceId); + if (device == null) return; + device.unpair(); + //Retry as unpaired + identityPackageReceived(identityPackage, socket, connectionStarted); + } + }); + } + Log.i("KDE/LanLinkProvider","Starting SSL handshake with " + identityPackage.getString("deviceName") + " trusted:"+isDeviceTrusted); final SSLSocket sslsocket = SslHelper.convertToSslSocket(context, socket, deviceId, isDeviceTrusted, clientMode); @@ -249,15 +263,6 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis } } catch (Exception e) { e.printStackTrace(); - BackgroundService.RunCommand(context, new BackgroundService.InstanceCallback() { - @Override - public void onServiceStart(BackgroundService service) { - Device device = service.getDevice(deviceId); - Log.e("LanLinkProvider", "Unpairing "+(device != null)); - if (device == null) return; - device.unpair(); - } - }); } } diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java index f0c1c950..c30e646b 100644 --- a/src/org/kde/kdeconnect/Device.java +++ b/src/org/kde/kdeconnect/Device.java @@ -284,7 +284,6 @@ public class Device implements BaseLink.PackageReceiver { SharedPreferences preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE); preferences.edit().remove(deviceId).apply(); - // FIXME : We delete all device info here, but the xml file still persists SharedPreferences devicePreferences = context.getSharedPreferences(deviceId, Context.MODE_PRIVATE); devicePreferences.edit().clear().apply(); diff --git a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java index ef7cf26c..5742329f 100644 --- a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java @@ -131,6 +131,12 @@ public class SslHelper { } } + public static boolean isCertificateStored(Context context, String deviceId) { + SharedPreferences devicePreferences = context.getSharedPreferences(deviceId, Context.MODE_PRIVATE); + String cert = devicePreferences.getString("certificate", ""); + return !cert.isEmpty(); + } + public static SSLContext getSslContext(Context context, String deviceId, boolean isDeviceTrusted) { //TODO: Cache try { diff --git a/src/org/kde/kdeconnect/Plugins/PluginFactory.java b/src/org/kde/kdeconnect/Plugins/PluginFactory.java index dfb46cce..1da88ef2 100644 --- a/src/org/kde/kdeconnect/Plugins/PluginFactory.java +++ b/src/org/kde/kdeconnect/Plugins/PluginFactory.java @@ -36,6 +36,7 @@ import org.kde.kdeconnect.Plugins.ReceiveNotificationsPlugin.ReceiveNotification import org.kde.kdeconnect.Plugins.RunCommandPlugin.RunCommandPlugin; import org.kde.kdeconnect.Plugins.SftpPlugin.SftpPlugin; import org.kde.kdeconnect.Plugins.SharePlugin.SharePlugin; +import org.kde.kdeconnect.Plugins.TelepathyPlugin.TelepathyPlugin; import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin; import java.util.Collections; @@ -110,7 +111,6 @@ public class PluginFactory { private static final Map pluginInfoCache = new TreeMap<>(); static { - //TODO: Use reflection to find all subclasses of Plugin, instead of adding them manually PluginFactory.registerPlugin(TelephonyPlugin.class); PluginFactory.registerPlugin(PingPlugin.class); PluginFactory.registerPlugin(MprisPlugin.class); @@ -121,7 +121,7 @@ public class PluginFactory { PluginFactory.registerPlugin(ReceiveNotificationsPlugin.class); PluginFactory.registerPlugin(MousePadPlugin.class); PluginFactory.registerPlugin(SharePlugin.class); - //PluginFactory.registerPlugin(TelepathyPlugin.class); + PluginFactory.registerPlugin(TelepathyPlugin.class); PluginFactory.registerPlugin(FindMyPhonePlugin.class); PluginFactory.registerPlugin(RunCommandPlugin.class); }