mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 14:15:14 +00:00
Fix catch not working because broadcastUdpPacket starts a thread
We don't want to crash if we get onNetworkChange before tcpServer has been initialized, however the way to do it was wrong because the exception was being thrown from a new thread.
This commit is contained in:
@@ -369,7 +369,8 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
|
||||
|
||||
NetworkPacket identity = NetworkPacket.createIdentityPacket(context);
|
||||
if (tcpServer == null || !tcpServer.isBound()) {
|
||||
throw new IllegalStateException("Wont't broadcast UDP packet if TCP socket is not ready");
|
||||
Log.i("LanLinkProvider", "Won't broadcast UDP packet if TCP socket is not ready yet");
|
||||
return;
|
||||
}
|
||||
int port = tcpServer.getLocalPort();
|
||||
identity.set("tcpPort", port);
|
||||
@@ -420,11 +421,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
|
||||
|
||||
@Override
|
||||
public void onNetworkChange() {
|
||||
try {
|
||||
broadcastUdpPacket();
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
broadcastUdpPacket();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user