mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 13:17:43 +00:00
Fix crash when onNetworkChanged was called before link was initialized
This race condition could happen on slow devices
This commit is contained in:
parent
b189556d6a
commit
961a839ac3
@ -369,7 +369,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
|
||||
|
||||
NetworkPacket identity = NetworkPacket.createIdentityPacket(context);
|
||||
if (tcpServer == null || !tcpServer.isBound()) {
|
||||
throw new RuntimeException("Wont't broadcast UDP packet if TCP socket is not ready");
|
||||
throw new IllegalStateException("Wont't broadcast UDP packet if TCP socket is not ready");
|
||||
}
|
||||
int port = tcpServer.getLocalPort();
|
||||
identity.set("tcpPort", port);
|
||||
@ -420,7 +420,11 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
|
||||
|
||||
@Override
|
||||
public void onNetworkChange() {
|
||||
broadcastUdpPacket();
|
||||
try {
|
||||
broadcastUdpPacket();
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user