when swiping don't clean startup counter entirely. just don't count last startup

This commit is contained in:
Daniel Gultsch 2016-11-21 10:48:59 +01:00
parent 568d6c8392
commit 7b99346a4b
2 changed files with 10 additions and 5 deletions

View file

@ -1328,9 +1328,14 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return count >= Config.FREQUENT_RESTARTS_THRESHOLD; return count >= Config.FREQUENT_RESTARTS_THRESHOLD;
} }
public void clearStartTimeCounter() { public void clearStartTimeCounter(boolean justOne) {
Log.d(Config.LOGTAG,"resetting start time counter");
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("delete from "+START_TIMES_TABLE); if (justOne) {
db.execSQL("delete from "+START_TIMES_TABLE+" where timestamp in (select timestamp from "+START_TIMES_TABLE+" order by timestamp desc limit 1)");
Log.d(Config.LOGTAG,"do not count start up after being swiped away");
} else {
Log.d(Config.LOGTAG,"resetting start time counter");
db.execSQL("delete from " + START_TIMES_TABLE);
}
} }
} }

View file

@ -978,7 +978,7 @@ public class XmppConnectionService extends Service {
private void logoutAndSave(boolean stop) { private void logoutAndSave(boolean stop) {
int activeAccounts = 0; int activeAccounts = 0;
databaseBackend.clearStartTimeCounter(); // regular swipes don't count towards restart counter databaseBackend.clearStartTimeCounter(true); // regular swipes don't count towards restart counter
for (final Account account : accounts) { for (final Account account : accounts) {
if (account.getStatus() != Account.State.DISABLED) { if (account.getStatus() != Account.State.DISABLED) {
activeAccounts++; activeAccounts++;
@ -3611,7 +3611,7 @@ public class XmppConnectionService extends Service {
mDatabaseExecutor.execute(new Runnable() { mDatabaseExecutor.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
databaseBackend.clearStartTimeCounter(); databaseBackend.clearStartTimeCounter(false);
} }
}); });
} }