mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 09:58:08 +00:00
Remove interface not needed
This commit is contained in:
parent
6879e40341
commit
ffd99858e6
@ -43,7 +43,7 @@ public abstract class BaseLinkProvider {
|
||||
cr.onConnectionReceived(deviceId, certificate, identityPacket, link);
|
||||
}
|
||||
}
|
||||
protected void connectionLost(BaseLink link) {
|
||||
public void connectionLost(BaseLink link) {
|
||||
//Log.i("KDE/LinkProvider", "connectionLost");
|
||||
for(ConnectionReceiver cr : connectionReceivers) {
|
||||
cr.onConnectionLost(link);
|
||||
|
@ -14,6 +14,7 @@ import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.kde.kdeconnect.Backends.BaseLink;
|
||||
import org.kde.kdeconnect.Backends.BaseLinkProvider;
|
||||
import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
|
||||
import org.kde.kdeconnect.Helpers.ThreadHelper;
|
||||
@ -37,18 +38,12 @@ import kotlin.text.Charsets;
|
||||
|
||||
public class LanLink extends BaseLink {
|
||||
|
||||
public interface LinkDisconnectedCallback {
|
||||
void linkDisconnected(LanLink brokenLink);
|
||||
}
|
||||
|
||||
public enum ConnectionStarted {
|
||||
Locally, Remotely
|
||||
}
|
||||
|
||||
private volatile SSLSocket socket = null;
|
||||
|
||||
private final LinkDisconnectedCallback callback;
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
Log.i("LanLink/Disconnect","socket:"+ socket.hashCode());
|
||||
@ -96,7 +91,7 @@ public class LanLink extends BaseLink {
|
||||
boolean thereIsaANewSocket = (newSocket != socket);
|
||||
if (!thereIsaANewSocket) {
|
||||
Log.i("LanLink", "Socket closed and there's no new socket, disconnecting device");
|
||||
callback.linkDisconnected(LanLink.this);
|
||||
getLinkProvider().connectionLost(LanLink.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -104,13 +99,11 @@ public class LanLink extends BaseLink {
|
||||
return oldSocket;
|
||||
}
|
||||
|
||||
public LanLink(Context context, String deviceId, LanLinkProvider linkProvider, SSLSocket socket) throws IOException {
|
||||
public LanLink(Context context, String deviceId, BaseLinkProvider linkProvider, SSLSocket socket) throws IOException {
|
||||
super(context, deviceId, linkProvider);
|
||||
callback = linkProvider;
|
||||
reset(socket);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "LanLink";
|
||||
|
@ -11,6 +11,7 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.kde.kdeconnect.Backends.BaseLink;
|
||||
import org.kde.kdeconnect.Backends.BaseLinkProvider;
|
||||
import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect.Helpers.DeviceHelper;
|
||||
@ -48,7 +49,7 @@ import kotlin.text.Charsets;
|
||||
*
|
||||
* @see #identityPacketReceived(NetworkPacket, Socket, LanLink.ConnectionStarted)
|
||||
*/
|
||||
public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDisconnectedCallback {
|
||||
public class LanLinkProvider extends BaseLinkProvider {
|
||||
|
||||
private final static int UDP_PORT = 1716;
|
||||
private final static int MIN_PORT = 1716;
|
||||
@ -67,11 +68,10 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
|
||||
|
||||
private boolean listening = false;
|
||||
|
||||
@Override // SocketClosedCallback
|
||||
public void linkDisconnected(LanLink brokenLink) {
|
||||
String deviceId = brokenLink.getDeviceId();
|
||||
public void connectionLost(BaseLink link) {
|
||||
String deviceId = link.getDeviceId();
|
||||
visibleDevices.remove(deviceId);
|
||||
connectionLost(brokenLink);
|
||||
super.connectionLost(link);
|
||||
}
|
||||
|
||||
//They received my UDP broadcast and are connecting to me. The first thing they send should be their identity packet.
|
||||
|
Loading…
x
Reference in New Issue
Block a user