mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-29 00:51:44 +01:00
Improved boot
This commit is contained in:
@@ -60,6 +60,8 @@ import androidx.lifecycle.Observer;
|
||||
public class ServiceSend extends LifecycleService {
|
||||
private int lastUnsent = 0;
|
||||
|
||||
private static boolean booted = false;
|
||||
|
||||
private static final int IDENTITY_ERROR_AFTER = 30; // minutes
|
||||
|
||||
@Override
|
||||
@@ -413,6 +415,27 @@ public class ServiceSend extends LifecycleService {
|
||||
}
|
||||
}
|
||||
|
||||
static void boot(final Context context) {
|
||||
if (!booted) {
|
||||
booted = true;
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DB db = DB.getInstance(context);
|
||||
EntityFolder outbox = db.folder().getOutbox();
|
||||
if (outbox != null && db.operation().getOperations(outbox.id).size() > 0)
|
||||
start(context);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
||||
static void start(Context context) {
|
||||
context.startService(new Intent(context, ServiceSend.class));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user