From 7b5d25b56c38a2ee07e5377a4c5fef2e76282f93 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 29 Mar 2021 20:08:35 +0200 Subject: [PATCH] Keep alive via the watchdog --- app/src/main/java/eu/faircode/email/ActivityMain.java | 2 +- .../main/java/eu/faircode/email/ApplicationEx.java | 11 +++-------- .../java/eu/faircode/email/ServiceSynchronize.java | 9 +++------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityMain.java b/app/src/main/java/eu/faircode/email/ActivityMain.java index db87b78526..e32a6b7c6a 100644 --- a/app/src/main/java/eu/faircode/email/ActivityMain.java +++ b/app/src/main/java/eu/faircode/email/ActivityMain.java @@ -115,7 +115,7 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack getMainHandler().postDelayed(new Runnable() { @Override public void run() { - ServiceSynchronize.eval(ActivityMain.this, "main"); + ServiceSynchronize.watchdog(ActivityMain.this); ServiceSend.watchdog(ActivityMain.this); } }, SERVICE_START_DELAY); diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index 67c0a8c941..a840ca8387 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -174,15 +174,10 @@ public class ApplicationEx extends Application DisconnectBlacklist.init(this); - boolean watchdog = prefs.getBoolean("watchdog", true); - boolean enabled = prefs.getBoolean("enabled", true); - if (watchdog && enabled) - WorkerWatchdog.init(this); - else { - ServiceSynchronize.watchdog(this); - ServiceSend.watchdog(this); - } + ServiceSynchronize.watchdog(this); + ServiceSend.watchdog(this); + WorkerWatchdog.init(this); WorkerCleanup.init(this); registerReceiver(onScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF)); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index f5f446e370..606b6b599b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -2502,12 +2502,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences } static void watchdog(Context context) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - boolean enabled = prefs.getBoolean("enabled", true); - if (enabled) - start(context, - new Intent(context, ServiceSynchronize.class) - .setAction("watchdog")); + start(context, + new Intent(context, ServiceSynchronize.class) + .setAction("watchdog")); } static void restart(Context context) {