From 4d965e96edaa1d27a693d1d5a3986b5fac38d758 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 17 Nov 2016 10:58:26 +0100 Subject: reset startup count when swiped away (only count kills) --- .../java/eu/siacs/conversations/persistance/DatabaseBackend.java | 2 ++ .../eu/siacs/conversations/services/XmppConnectionService.java | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 56968853..71567356 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -1285,10 +1285,12 @@ public class DatabaseBackend extends SQLiteOpenHelper { count = 0; } cursor.close(); + Log.d(Config.LOGTAG,"start time counter reached "+count); return count >= Config.FREQUENT_RESTARTS_THRESHOLD; } public void clearStartTimeCounter() { + Log.d(Config.LOGTAG,"resetting start time counter"); SQLiteDatabase db = this.getWritableDatabase(); db.execSQL("delete from "+START_TIMES_TABLE); } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 9f3eea3f..9ebbcf63 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -969,6 +969,7 @@ public class XmppConnectionService extends Service { private void logoutAndSave(boolean stop) { int activeAccounts = 0; + databaseBackend.clearStartTimeCounter(); // regular swipes don't count towards restart counter for (final Account account : accounts) { if (account.getStatus() != Account.State.DISABLED) { activeAccounts++; @@ -989,13 +990,6 @@ public class XmppConnectionService extends Service { } } - private void cancelWakeUpCall(int requestCode) { - final AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); - final Intent intent = new Intent(this, EventReceiver.class); - intent.setAction("ping"); - alarmManager.cancel(PendingIntent.getBroadcast(this, requestCode, intent, 0)); - } - public void scheduleWakeUpCall(int seconds, int requestCode) { final long timeToWake = SystemClock.elapsedRealtime() + (seconds < 0 ? 1 : seconds + 1) * 1000; AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); -- cgit v1.2.3