Refactoring

This commit is contained in:
M66B 2024-03-07 15:02:27 +01:00
parent 4ea1b549f0
commit 503c1f521e
1 changed files with 5 additions and 3 deletions

View File

@ -470,13 +470,13 @@ 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);
db.operation().setOperationError(op.id, Log.formatThrowable(ex));
if (message != null) {
db.message().setMessageError(message.id, Log.formatThrowable(ex));
try {
int tries_left = (unrecoverable ? 0 : RETRY_MAX - op.tries);
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
if (NotificationHelper.areNotificationsEnabled(nm)) {
NotificationCompat.Builder builder = getNotificationError(
@ -524,11 +524,13 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
}
}
if (op.tries >= RETRY_MAX || unrecoverable) {
Log.w("Unrecoverable");
if (tries_left <= 0) {
Log.w("Send tries left=" + tries_left +
" unrecoverable=" + unrecoverable);
db.operation().deleteOperation(op.id);
ops.remove(op);
} else {
Log.i("Send retry wait");
Thread.sleep(RETRY_WAIT);
throw ex;
}