mirror of https://github.com/M66B/FairEmail.git
Auto prolong oneshot
This commit is contained in:
parent
0816a5deb1
commit
6fa14c93e7
|
@ -107,7 +107,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
private static final long RECONNECT_BACKOFF = 90 * 1000L; // milliseconds
|
||||
private static final int ACCOUNT_ERROR_AFTER = 60; // minutes
|
||||
private static final int BACKOFF_ERROR_AFTER = 16; // seconds
|
||||
private static final long ONESHOT_DURATION = 120 * 1000L; // milliseconds
|
||||
private static final long ONESHOT_DURATION = 90 * 1000L; // milliseconds
|
||||
private static final long STOP_DELAY = 5000L; // milliseconds
|
||||
|
||||
static final int PI_ALARM = 1;
|
||||
|
@ -129,10 +129,19 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
DB db = DB.getInstance(this);
|
||||
|
||||
db.account().liveStats().observe(this, new Observer<TupleAccountStats>() {
|
||||
private TupleAccountStats lastStats = null;
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nullable TupleAccountStats stats) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(stats).build());
|
||||
if (stats != null && !stats.equals(lastStats)) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(stats).build());
|
||||
|
||||
if (oneshot && stats.operations > 0)
|
||||
onOneshot(true);
|
||||
}
|
||||
|
||||
lastStats = stats;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -19,7 +19,21 @@ package eu.faircode.email;
|
|||
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class TupleAccountStats {
|
||||
public Integer accounts = 0;
|
||||
public Integer operations = 0;
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof TupleAccountStats) {
|
||||
TupleAccountStats other = (TupleAccountStats) obj;
|
||||
return (Objects.equals(this.accounts, other.accounts) &&
|
||||
Objects.equals(this.operations, other.operations));
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue