From 06dc32d51211536b68422febabbb4afd5caf04bc Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 13 Dec 2019 08:08:18 +0100 Subject: [PATCH] Conditionally init --- app/src/main/java/eu/faircode/email/ServiceSend.java | 7 +++++-- .../main/java/eu/faircode/email/ServiceSynchronize.java | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index 78ccee5a90..3dce43d341 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -516,8 +516,11 @@ public class ServiceSend extends ServiceBase { try { DB db = DB.getInstance(context); EntityFolder outbox = db.folder().getOutbox(); - if (outbox != null) - start(context); + if (outbox != null) { + int operations = db.operation().getOperations(outbox.id).size(); + if (operations > 0) + start(context); + } } catch (Throwable ex) { Log.e(ex); } diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index bb12deee92..a174f4a12b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1456,7 +1456,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences schedule(context); // Init service - eval(context, "boot"); + int accounts = db.account().getSynchronizingAccounts().size(); + if (accounts > 0) + eval(context, "boot"); } catch (Throwable ex) { Log.e(ex); }