1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-02 13:14:39 +00:00

Cancel watchdog

This commit is contained in:
M66B 2022-03-04 20:10:25 +01:00
parent 0f9d7c3ba4
commit fe163967ae

View file

@ -2972,6 +2972,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
pi = PendingIntentCompat.getForegroundService(context, PI_WATCHDOG, intent, PendingIntent.FLAG_UPDATE_CURRENT); pi = PendingIntentCompat.getForegroundService(context, PI_WATCHDOG, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.cancel(pi);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean watchdog = prefs.getBoolean("watchdog", true); boolean watchdog = prefs.getBoolean("watchdog", true);
boolean enabled = prefs.getBoolean("enabled", true); boolean enabled = prefs.getBoolean("enabled", true);
@ -2982,8 +2984,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
next += WATCHDOG_INTERVAL; next += WATCHDOG_INTERVAL;
EntityLog.log(context, "Watchdog next=" + new Date(next)); EntityLog.log(context, "Watchdog next=" + new Date(next));
AlarmManagerCompatEx.setAndAllowWhileIdle(context, am, AlarmManager.RTC_WAKEUP, next, pi); AlarmManagerCompatEx.setAndAllowWhileIdle(context, am, AlarmManager.RTC_WAKEUP, next, pi);
} else }
am.cancel(pi);
} }
static void eval(Context context, String reason) { static void eval(Context context, String reason) {