diff --git a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java index 5af0fa64..9ec8e146 100644 --- a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java +++ b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java @@ -40,6 +40,7 @@ import org.apache.mina.transport.socket.nio.NioSocketConnector; import org.kde.kdeconnect.Backends.BaseLink; import org.kde.kdeconnect.Backends.BaseLinkProvider; import org.kde.kdeconnect.Device; +import org.kde.kdeconnect.Helpers.DeviceHelper; import org.kde.kdeconnect.NetworkPackage; import org.kde.kdeconnect.UserInterface.CustomDevicesActivity; @@ -127,8 +128,7 @@ public class LanLinkProvider extends BaseLinkProvider { NetworkPackage np = NetworkPackage.unserialize(theMessage); if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_IDENTITY)) { - - String myId = NetworkPackage.createIdentityPackage(context).getString("deviceId"); + String myId = DeviceHelper.getDeviceId(context); if (np.getString("deviceId").equals(myId)) { return; } @@ -167,7 +167,7 @@ public class LanLinkProvider extends BaseLinkProvider { Log.e("KDE/LanLinkProvider", "Expecting an identity package (B)"); return; } else { - String myId = NetworkPackage.createIdentityPackage(context).getString("deviceId"); + String myId = DeviceHelper.getDeviceId(context); if (identityPackage.getString("deviceId").equals(myId)) { return; } diff --git a/src/org/kde/kdeconnect/Helpers/DeviceHelper.java b/src/org/kde/kdeconnect/Helpers/DeviceHelper.java index 8a0e0fd6..4c48c907 100644 --- a/src/org/kde/kdeconnect/Helpers/DeviceHelper.java +++ b/src/org/kde/kdeconnect/Helpers/DeviceHelper.java @@ -26,6 +26,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.preference.PreferenceManager; +import android.provider.Settings; import android.util.Log; import java.util.HashMap; @@ -488,4 +489,7 @@ public class DeviceHelper { preferences.edit().putString(KEY_DEVICE_NAME_PREFERENCE, name).apply(); } + public static String getDeviceId(Context context) { + return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); + } } diff --git a/src/org/kde/kdeconnect/NetworkPackage.java b/src/org/kde/kdeconnect/NetworkPackage.java index b27a1385..d617ef5f 100644 --- a/src/org/kde/kdeconnect/NetworkPackage.java +++ b/src/org/kde/kdeconnect/NetworkPackage.java @@ -247,7 +247,7 @@ public class NetworkPackage { NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_IDENTITY); - String deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); + String deviceId = DeviceHelper.getDeviceId(context); try { np.mBody.put("deviceId", deviceId); np.mBody.put("deviceName", DeviceHelper.getDeviceName(context));