mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 06:05:12 +00:00
Added global preference to use ssl or not in case ssl is not working on some devices
This commit is contained in:
@@ -144,5 +144,6 @@
|
||||
<string name="no_players_connected">No players found</string>
|
||||
<string name="custom_dev_list_help">Use this option only if your device is not automatically detected. Enter IP address or hostname below and touch the button to add it to the list. Touch an existing item to remove it from the list.</string>
|
||||
<string name="mpris_player_on_device">%1$s on %2$s</string>
|
||||
<string name="use_ssl">Use SSL for communication</string>
|
||||
|
||||
</resources>
|
||||
|
@@ -11,5 +11,11 @@
|
||||
android:dialogTitle="@string/device_name"
|
||||
android:singleLine="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="use_ssl_preference"
|
||||
android:title="@string/use_ssl"
|
||||
android:defaultValue="true"
|
||||
/>
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
@@ -31,6 +31,7 @@ import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
|
||||
import org.kde.kdeconnect.NetworkPackage;
|
||||
import org.kde.kdeconnect.UserInterface.CustomDevicesActivity;
|
||||
import org.kde.kdeconnect.UserInterface.MainSettingsActivity;
|
||||
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
@@ -153,8 +154,8 @@ public class LanLinkProvider extends BaseLinkProvider {
|
||||
|
||||
if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_IDENTITY)) {
|
||||
|
||||
String myId = NetworkPackage.createIdentityPackage(context).getString("deviceId");
|
||||
if (np.getString("deviceId").equals(myId)) {
|
||||
NetworkPackage myIdentityPackage = NetworkPackage.createIdentityPackage(context);
|
||||
if (np.getString("deviceId").equals(myIdentityPackage.getString("deviceId"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
||||
// Check if ssl supported, and add ssl handler
|
||||
// Sslengine is returning null in some cases
|
||||
try {
|
||||
if (np.getBoolean("sslSupported", false)) {
|
||||
if (myIdentityPackage.getBoolean("sslSupported") && np.getBoolean("sslSupported", false)) {
|
||||
Log.e("KDE/LanLinkProvider", "Remote device " + np.getString("deviceName") + " supports ssl");
|
||||
final SSLEngine sslEngine = SslHelper.getSslEngine(context, np.getString("deviceId"), SslHelper.SslMode.Client);
|
||||
SslHandler sslHandler = new SslHandler(sslEngine);
|
||||
@@ -250,8 +251,9 @@ public class LanLinkProvider extends BaseLinkProvider {
|
||||
|
||||
Log.i("KDE/LanLinkProvider", "Connection successful: " + channel.isActive());
|
||||
|
||||
// If remote device supports ssl, add ssl handler to channel
|
||||
if (identityPackage.getBoolean("sslSupported", false)) {
|
||||
// If I and remote device supports ssl, add ssl handler to channel
|
||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(MainSettingsActivity.KEY_USE_SSL_PREFERENCE, true)
|
||||
&& identityPackage.getBoolean("sslSupported", false)) {
|
||||
// add ssl handler with start tls true
|
||||
SSLEngine sslEngine = SslHelper.getSslEngine(context, identityPackage.getString("deviceId"), SslHelper.SslMode.Server);
|
||||
SslHandler sslHandler = new SslHandler(sslEngine, true);
|
||||
|
@@ -206,7 +206,7 @@ public class NetworkPackage {
|
||||
DeviceHelper.getDeviceName()));
|
||||
np.mBody.put("protocolVersion", NetworkPackage.ProtocolVersion);
|
||||
np.mBody.put("deviceType", DeviceHelper.isTablet()? "tablet" : "phone");
|
||||
np.mBody.put("sslSupported", true);
|
||||
np.mBody.put("sslSupported", PreferenceManager.getDefaultSharedPreferences(context).getBoolean(MainSettingsActivity.KEY_USE_SSL_PREFERENCE, true));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("NetworkPacakge","Exception on createIdentityPackage");
|
||||
|
@@ -40,6 +40,7 @@ import org.kde.kdeconnect_tp.R;
|
||||
public class MainSettingsActivity extends AppCompatPreferenceActivity {
|
||||
|
||||
public static final String KEY_DEVICE_NAME_PREFERENCE = "device_name_preference";
|
||||
public static final String KEY_USE_SSL_PREFERENCE = "use_ssl_preference";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
Reference in New Issue
Block a user