Revert "Restored send delay"

This reverts commit ae0c2478cf.
pull/184/head
M66B 5 years ago
parent b331c69331
commit 23b08d943f

@ -79,7 +79,6 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
private static final int PI_SEND = 1; private static final int PI_SEND = 1;
private static final int RETRY_MAX = 3; private static final int RETRY_MAX = 3;
private static final int CONNECTIVITY_DELAY = 5000; // milliseconds
@Override @Override
public void onCreate() { public void onCreate() {
@ -291,46 +290,39 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
} }
private void _checkConnectivity() { private void _checkConnectivity() {
final Network active = ConnectionHelper.getActiveNetwork(this); Network active = ConnectionHelper.getActiveNetwork(this);
final boolean restart = !Objects.equals(lastActive, active); boolean restart = !Objects.equals(lastActive, active);
final boolean suitable = ConnectionHelper.getNetworkState(this).isSuitable(); if (restart) {
lastActive = active;
if (restart || lastSuitable != suitable) EntityLog.log(this, "Service send active=" + active);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override if (lastSuitable) {
public void run() { EntityLog.log(this, "Service send restart");
if (restart) { lastSuitable = false;
lastActive = active; owner.stop();
EntityLog.log(ServiceSend.this, "Service send active=" + active); handling.clear();
}
if (lastSuitable) { }
EntityLog.log(ServiceSend.this, "Service send restart");
lastSuitable = false;
owner.stop();
handling.clear();
}
}
if (lastSuitable != suitable) { boolean suitable = ConnectionHelper.getNetworkState(this).isSuitable();
lastSuitable = suitable; if (lastSuitable != suitable) {
EntityLog.log(ServiceSend.this, "Service send suitable=" + suitable); lastSuitable = suitable;
EntityLog.log(this, "Service send suitable=" + suitable);
try { try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build()); nm.notify(Helper.NOTIFICATION_SEND, getNotificationService().build());
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }
if (suitable) if (suitable)
owner.start(); owner.start();
else { else {
owner.stop(); owner.stop();
handling.clear(); handling.clear();
} }
} }
}
}, CONNECTIVITY_DELAY);
} }
private void processOperations(List<TupleOperationEx> ops) { private void processOperations(List<TupleOperationEx> ops) {

Loading…
Cancel
Save