Wait 5 seconds after connectivity change before sending

pull/178/head
M66B 4 years ago
parent fc353a2817
commit 8127267bed

@ -70,6 +70,7 @@ public class ServiceSend extends ServiceBase {
private ExecutorService executor = Helper.getBackgroundExecutor(1, "send");
private static final int PI_SEND = 1;
private static final long CONNECTIVITY_DELAY = 5000L; // milliseconds
private static final int IDENTITY_ERROR_AFTER = 30; // minutes
@Override
@ -133,6 +134,8 @@ public class ServiceSend extends ServiceBase {
});
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
lastSuitable = ConnectionHelper.getNetworkState(this).isSuitable();
NetworkRequest.Builder builder = new NetworkRequest.Builder();
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
cm.registerNetworkCallback(builder.build(), networkCallback);
@ -240,6 +243,13 @@ public class ServiceSend extends ServiceBase {
} catch (Throwable ex) {
Log.w(ex);
}
// Wait for stabilization of connection
try {
Thread.sleep(CONNECTIVITY_DELAY);
} catch (InterruptedException ex) {
Log.w(ex);
}
}
if (suitable)

Loading…
Cancel
Save