mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-28 20:57:42 +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);
|
cr.onConnectionReceived(deviceId, certificate, identityPacket, link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void connectionLost(BaseLink link) {
|
public void connectionLost(BaseLink link) {
|
||||||
//Log.i("KDE/LinkProvider", "connectionLost");
|
//Log.i("KDE/LinkProvider", "connectionLost");
|
||||||
for(ConnectionReceiver cr : connectionReceivers) {
|
for(ConnectionReceiver cr : connectionReceivers) {
|
||||||
cr.onConnectionLost(link);
|
cr.onConnectionLost(link);
|
||||||
|
@ -14,6 +14,7 @@ import androidx.annotation.WorkerThread;
|
|||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.kde.kdeconnect.Backends.BaseLink;
|
import org.kde.kdeconnect.Backends.BaseLink;
|
||||||
|
import org.kde.kdeconnect.Backends.BaseLinkProvider;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
|
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
|
||||||
import org.kde.kdeconnect.Helpers.ThreadHelper;
|
import org.kde.kdeconnect.Helpers.ThreadHelper;
|
||||||
@ -37,18 +38,12 @@ import kotlin.text.Charsets;
|
|||||||
|
|
||||||
public class LanLink extends BaseLink {
|
public class LanLink extends BaseLink {
|
||||||
|
|
||||||
public interface LinkDisconnectedCallback {
|
|
||||||
void linkDisconnected(LanLink brokenLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ConnectionStarted {
|
public enum ConnectionStarted {
|
||||||
Locally, Remotely
|
Locally, Remotely
|
||||||
}
|
}
|
||||||
|
|
||||||
private volatile SSLSocket socket = null;
|
private volatile SSLSocket socket = null;
|
||||||
|
|
||||||
private final LinkDisconnectedCallback callback;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
Log.i("LanLink/Disconnect","socket:"+ socket.hashCode());
|
Log.i("LanLink/Disconnect","socket:"+ socket.hashCode());
|
||||||
@ -96,7 +91,7 @@ public class LanLink extends BaseLink {
|
|||||||
boolean thereIsaANewSocket = (newSocket != socket);
|
boolean thereIsaANewSocket = (newSocket != socket);
|
||||||
if (!thereIsaANewSocket) {
|
if (!thereIsaANewSocket) {
|
||||||
Log.i("LanLink", "Socket closed and there's no new socket, disconnecting device");
|
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;
|
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);
|
super(context, deviceId, linkProvider);
|
||||||
callback = linkProvider;
|
|
||||||
reset(socket);
|
reset(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "LanLink";
|
return "LanLink";
|
||||||
|
@ -11,6 +11,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.kde.kdeconnect.Backends.BaseLink;
|
||||||
import org.kde.kdeconnect.Backends.BaseLinkProvider;
|
import org.kde.kdeconnect.Backends.BaseLinkProvider;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
import org.kde.kdeconnect.Helpers.DeviceHelper;
|
import org.kde.kdeconnect.Helpers.DeviceHelper;
|
||||||
@ -48,7 +49,7 @@ import kotlin.text.Charsets;
|
|||||||
*
|
*
|
||||||
* @see #identityPacketReceived(NetworkPacket, Socket, LanLink.ConnectionStarted)
|
* @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 UDP_PORT = 1716;
|
||||||
private final static int MIN_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;
|
private boolean listening = false;
|
||||||
|
|
||||||
@Override // SocketClosedCallback
|
public void connectionLost(BaseLink link) {
|
||||||
public void linkDisconnected(LanLink brokenLink) {
|
String deviceId = link.getDeviceId();
|
||||||
String deviceId = brokenLink.getDeviceId();
|
|
||||||
visibleDevices.remove(deviceId);
|
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.
|
//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