mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 15:11:03 +00:00
Limit number of crash reports
This commit is contained in:
parent
84d80ce1b8
commit
5653dc2e9b
2 changed files with 11 additions and 1 deletions
|
@ -83,6 +83,7 @@ import javax.mail.Part;
|
|||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
public class Log {
|
||||
private static final int MAX_CRASH_REPORTS = 5;
|
||||
private static final String TAG = "fairemail";
|
||||
|
||||
public static int d(String msg) {
|
||||
|
@ -201,6 +202,12 @@ public class Log {
|
|||
config.beforeSend(new BeforeSend() {
|
||||
@Override
|
||||
public boolean run(@NonNull Report report) {
|
||||
int count = prefs.getInt("crash_report_count", 0);
|
||||
count++;
|
||||
prefs.edit().putInt("crash_report_count", count).apply();
|
||||
if (count > MAX_CRASH_REPORTS)
|
||||
return false;
|
||||
|
||||
Throwable ex = report.getError().getException();
|
||||
|
||||
if (ex instanceof MessagingException &&
|
||||
|
|
|
@ -185,7 +185,10 @@ public class WorkerCleanup extends Worker {
|
|||
Log.i("End cleanup");
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putLong("last_cleanup", new Date().getTime()).apply();
|
||||
prefs.edit()
|
||||
.remove("crash_report_count")
|
||||
.putLong("last_cleanup", new Date().getTime())
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue