From fe2cc0a8582c70e64780a0e84fdd8762b9ddba29 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 29 Mar 2021 15:24:22 +0200 Subject: [PATCH] Earlier quit cancel --- .../eu/faircode/email/ServiceSynchronize.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 955afc9ce1..eb8bc761be 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -114,7 +114,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences private static final long BACKUP_DELAY = 30 * 1000L; // milliseconds private static final long PURGE_DELAY = 30 * 1000L; // milliseconds - private static final long QUIT_DELAY = 5 * 1000L; // milliseconds + private static final int QUIT_DELAY = 5; // seconds private static final long STILL_THERE_THRESHOLD = 3 * 60 * 1000L; // milliseconds static final int DEFAULT_POLL_INTERVAL = 0; // minutes private static final int OPTIMIZE_KEEP_ALIVE_INTERVAL = 12; // minutes @@ -531,15 +531,17 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences MessageClassifier.save(ServiceSynchronize.this); } else { // Yield update notifications/widgets - try { - Thread.sleep(QUIT_DELAY); - } catch (InterruptedException ex) { - Log.w(ex); - } + for (int i = 0; i < QUIT_DELAY; i++) { + try { + Thread.sleep(1000L); + } catch (InterruptedException ex) { + Log.w(ex); + } - if (!eventId.equals(lastEventId)) { - EntityLog.log(ServiceSynchronize.this, "### quit cancelled eventId=" + eventId + "/" + lastEventId); - return; + if (!eventId.equals(lastEventId)) { + EntityLog.log(ServiceSynchronize.this, "### quit cancelled eventId=" + eventId + "/" + lastEventId); + return; + } } // Stop service