From d11d15d77199364c804ee8912fdb914743d39157 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 28 Dec 2019 19:47:18 +0100 Subject: [PATCH] Record max idle time --- app/src/main/java/eu/faircode/email/Core.java | 16 ++++++++++++++++ .../eu/faircode/email/ServiceSynchronize.java | 1 + 2 files changed, 17 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 1601aff009..ba442b7967 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -3308,6 +3308,22 @@ class Core { } } + private long maxIdle = 0; + private long lastActivity = 0; + + synchronized void activity() { + long now = SystemClock.elapsedRealtime(); + if (lastActivity > 0 && now - lastActivity > maxIdle) { + maxIdle = now - lastActivity; + Log.i("Max idle=" + (maxIdle / 1000)); + } + lastActivity = now; + } + + long getMaxIdle() { + return maxIdle; + } + @NonNull @Override public String toString() { diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index a936ef7027..3c707cc12b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1020,6 +1020,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences while (ifolder.isOpen() && state.isRunning() && state.isRecoverable()) { Log.i(folder.name + " do idle"); ifolder.idle(false); + state.activity(); } } catch (Throwable ex) { Log.e(folder.name, ex);