Added send retry max setting

This commit is contained in:
M66B
2024-03-07 19:58:56 +01:00
parent b0ec6e7489
commit f98dc7a60c
4 changed files with 86 additions and 3 deletions

View File

@@ -79,6 +79,7 @@ import biweekly.component.VEvent;
import biweekly.property.Method;
public class ServiceSend extends ServiceBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private int retry_max = RETRY_MAX_DEFAULT;
private TupleUnsent lastUnsent = null;
private Network lastActive = null;
private boolean lastSuitable = false;
@@ -91,7 +92,6 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
private static final ExecutorService executor =
Helper.getBackgroundExecutor(1, "send");
private static final int RETRY_MAX = 3;
private static final long RETRY_WAIT = 5000L; // milliseconds
private static final int CONNECTIVITY_DELAY = 5000; // milliseconds
private static final int PROGRESS_UPDATE_INTERVAL = 1000; // milliseconds
@@ -100,12 +100,17 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
static final int PI_SEND = 1;
static final int PI_FIX = 2;
static final int RETRY_MAX_DEFAULT = 3;
@Override
public void onCreate() {
EntityLog.log(this, "Service send create");
super.onCreate();
startForeground(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false));
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
retry_max = prefs.getInt("send_retry_max", RETRY_MAX_DEFAULT);
owner = new TwoStateOwner(this, "send");
PowerManager pm = Helper.getSystemService(this, PowerManager.class);
@@ -471,7 +476,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
(ex instanceof AuthenticationFailedException && !ConnectionHelper.isIoError(ex)) ||
ex instanceof SendFailedException ||
ex instanceof IllegalArgumentException);
int tries_left = (unrecoverable ? 0 : RETRY_MAX - op.tries);
int tries_left = (unrecoverable ? 0 : retry_max - op.tries);
db.operation().setOperationError(op.id, Log.formatThrowable(ex));
if (message != null) {