diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index f9936e9ce8..e97eb09476 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -65,6 +65,7 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.LinkedHashMap; @@ -129,6 +130,7 @@ public class EmailService implements AutoCloseable { private final static int FETCH_SIZE = 1024 * 1024; // bytes, default 16K private final static int POOL_SIZE = 1; // connections private final static int POOL_TIMEOUT = 60 * 1000; // milliseconds, default 45 sec + private final static long PROTOCOL_LOG_DURATION = 12 * 3600 * 1000L; private final static int MAX_IPV4 = 2; private final static int MAX_IPV6 = 1; @@ -166,7 +168,13 @@ public class EmailService implements AutoCloseable { properties = MessageHelper.getSessionProperties(); + long now = new Date().getTime(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + long protocol_since = prefs.getLong("protocol_since", 0); + if (protocol_since == 0) + prefs.edit().putLong("protocol_since", now).apply(); + else if (protocol_since + PROTOCOL_LOG_DURATION < now) + prefs.edit().putBoolean("protocol", false).apply(); this.log = prefs.getBoolean("protocol", false); this.harden = prefs.getBoolean("ssl_harden", false); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 6a7edebf15..1119e901fe 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -78,6 +78,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.List; import java.util.Locale; import java.util.SortedMap; @@ -809,7 +810,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("protocol", checked).apply(); - if (!checked) + if (checked) + prefs.edit().putLong("protocol_since", new Date().getTime()).apply(); + else EntityLog.clear(compoundButton.getContext()); } });