From f093326f93dcfee32e1631ed1784a6c1ece83172 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Fri, 26 Aug 2016 19:08:03 +0200 Subject: [PATCH 1/5] Re-enabled SMS plugin --- AndroidManifest.xml | 2 +- src/org/kde/kdeconnect/Plugins/PluginFactory.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0c351116..ef9eb8c1 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -23,7 +23,7 @@ - + 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); } From 1b369d0bf8b1dbc8a0394099c1a834c73aea653d Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Fri, 26 Aug 2016 19:08:10 +0200 Subject: [PATCH 2/5] Bumped version to release --- AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index ef9eb8c1..c1e70837 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="1400" + android:versionName="1.4"> From 9c40374b0091d928de9b427302d1700c9cfa61cb Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Mon, 29 Aug 2016 11:48:30 +0200 Subject: [PATCH 3/5] Unpair only when there is no certificate Unpairing on every error was a bit too aggressive. BUG: 367937 --- .../Backends/LanBackend/LanLinkProvider.java | 23 +++++++++++-------- .../Helpers/SecurityHelpers/SslHelper.java | 6 +++++ 2 files changed, 20 insertions(+), 9 deletions(-) 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/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 { From 2989fe5ab3df852cb8a1a11e80bf914f6a90f4b5 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Mon, 29 Aug 2016 11:49:04 +0200 Subject: [PATCH 4/5] Bump version to release --- AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c1e70837..ac98525b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="1410" + android:versionName="1.4.1"> From a8838b57bb7c815d850a15f2162478083ef08ba6 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Mon, 29 Aug 2016 11:49:25 +0200 Subject: [PATCH 5/5] What XML file? --- src/org/kde/kdeconnect/Device.java | 1 - 1 file changed, 1 deletion(-) 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();